Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel
if is_extern && !std_internal {
let target = &tcx.sess.target.target.llvm_target;
// WebAssembly cannot export data symbols, so reduce their export level
if target.contains("wasm32") || target.contains("emscripten") {
if target.contains("emscripten") {
if let Some(Node::Item(&hir::Item { kind: hir::ItemKind::Static(..), .. })) =
tcx.hir().get_if_local(sym_def_id)
{
Expand Down
3 changes: 3 additions & 0 deletions src/test/run-make/wasm-export-all-symbols/bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

#[no_mangle]
pub extern fn foo() {}

#[no_mangle]
pub static FOO: u64 = 42;
14 changes: 9 additions & 5 deletions src/test/run-make/wasm-export-all-symbols/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ console.log('exports', list);

const my_exports = {};
let nexports = 0;

for (const entry of list) {
if (entry.kind !== 'function')
continue;
my_exports[entry.name] = true;
nexports += 1;
if (entry.kind == 'function'){
nexports += 1;
}
my_exports[entry.name] = entry.kind;
}

if (my_exports.foo === undefined)
if (my_exports.foo != "function")
throw new Error("`foo` wasn't defined");

if (my_exports.FOO != "global")
throw new Error("`FOO` wasn't defined");

if (my_exports.main === undefined) {
if (nexports != 1)
throw new Error("should only have one function export");
Expand Down