Don't export non-function symbols with emscripten

Emscripten only provides an export mechanism for functions.
Exporting statics does not make sense conceptually in this case,
and will result in emcc undefined function errors.
This commit is contained in:
Nikita Popov 2018-11-02 20:16:17 +01:00
parent 131fda40af
commit c14bc575d6
1 changed files with 10 additions and 0 deletions

View File

@ -388,6 +388,16 @@ fn symbol_export_level(tcx: TyCtxt, sym_def_id: DefId) -> SymbolExportLevel {
codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL);
if is_extern && !std_internal {
// Emscripten cannot export statics, so reduce their export level here
if tcx.sess.target.target.options.is_like_emscripten {
if let Some(Node::Item(&hir::Item {
node: hir::ItemKind::Static(..),
..
})) = tcx.hir.get_if_local(sym_def_id) {
return SymbolExportLevel::Rust;
}
}
SymbolExportLevel::C
} else {
SymbolExportLevel::Rust