]> git.lizzy.rs Git - rust.git/commitdiff
Don't export `__heap_base` and `__data_end` on wasm32-wasi.
authorDan Gohman <dev@sunfishcode.online>
Wed, 28 Sep 2022 00:33:59 +0000 (17:33 -0700)
committerDan Gohman <dev@sunfishcode.online>
Wed, 28 Sep 2022 00:42:33 +0000 (17:42 -0700)
`__heap_base` and `__data_end` are exported for use by wasm-bindgen, which
uses the wasm32-unknown-unknown target. On wasm32-wasi, as a step toward
implementing the Canonical ABI, and as an aid to building speicalized WASI
API polyfill wrappers, don't export `__heap_base` and `__data_end` on
wasm32-wasi.

compiler/rustc_codegen_ssa/src/back/linker.rs

index e0bd7a33f7373c6d93a217937906a00c04f4049b..061053ef2ac97508eed2714f748397b367048374 100644 (file)
@@ -1320,10 +1320,12 @@ fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, symbols: &[
 
         // LLD will hide these otherwise-internal symbols since it only exports
         // symbols explicitly passed via the `--export` flags above and hides all
-        // others. Various bits and pieces of tooling use this, so be sure these
-        // symbols make their way out of the linker as well.
-        self.cmd.arg("--export=__heap_base");
-        self.cmd.arg("--export=__data_end");
+        // others. Various bits and pieces of wasm32-unknown-unknown tooling use
+        // this, so be sure these symbols make their way out of the linker as well.
+        if self.sess.target.os == "unknown" {
+            self.cmd.arg("--export=__heap_base");
+            self.cmd.arg("--export=__data_end");
+        }
     }
 
     fn subsystem(&mut self, _subsystem: &str) {}