diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2018-11-02 20:16:17 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2018-11-04 18:50:58 +0100 |
| commit | c14bc575d6de85ebd5a71497eb2db103d56c64f5 (patch) | |
| tree | 2255f29418ea093e9a06ae0be1154e1261809d36 | |
| parent | 131fda40af3ced8db2cbea8b88e936e7176cce1c (diff) | |
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.
| -rw-r--r-- | src/librustc_codegen_utils/symbol_export.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/librustc_codegen_utils/symbol_export.rs b/src/librustc_codegen_utils/symbol_export.rs index 2d650f7f18d..6c40296b2ef 100644 --- a/src/librustc_codegen_utils/symbol_export.rs +++ b/src/librustc_codegen_utils/symbol_export.rs @@ -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 |
