diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2022-05-06 17:20:42 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2022-06-03 17:02:14 +0000 |
| commit | 5cc3593c17360edd92977301ca66551a45119619 (patch) | |
| tree | b8869e04fb13b870d74f9bbbe4f6cfc6b1431afd | |
| parent | 606848a61ea6d303b2aa3d4cf01881a11971c0c1 (diff) | |
| download | rust-5cc3593c17360edd92977301ca66551a45119619.tar.gz rust-5cc3593c17360edd92977301ca66551a45119619.zip | |
Fix emscripten linker invocation
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/Cargo.toml | 1 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/linker.rs | 19 |
3 files changed, 8 insertions, 13 deletions
diff --git a/Cargo.lock b/Cargo.lock index e0f6ee6c791..dd1869fb01f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3686,6 +3686,7 @@ dependencies = [ "rustc_span", "rustc_symbol_mangling", "rustc_target", + "serde_json", "smallvec", "snap", "tempfile", diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml index 93b10a07e44..fd8c4f78b2f 100644 --- a/compiler/rustc_codegen_ssa/Cargo.toml +++ b/compiler/rustc_codegen_ssa/Cargo.toml @@ -16,6 +16,7 @@ jobserver = "0.1.22" tempfile = "3.2" thorin-dwp = "0.2" pathdiff = "0.2.0" +serde_json = "1.0.59" snap = "1" smallvec = { version = "1.6.1", features = ["union", "may_dangle"] } regex = "1.4" diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index dca11a8e00c..a24e4347839 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -1146,24 +1146,17 @@ impl<'a> Linker for EmLinker<'a> { } fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, symbols: &[String]) { - use std::fmt::Write; - debug!("EXPORTED SYMBOLS:"); - let mut encoded = "[".to_string(); - let mut symbols = symbols.iter(); - if let Some(first_symbol) = symbols.next() { - write!(encoded, "{:?}", first_symbol).unwrap(); - } - for symbol in symbols { - write!(encoded, ",{:?}", symbol).unwrap(); - } - encoded.push(']'); - debug!("{}", encoded); - self.cmd.arg("-s"); let mut arg = OsString::from("EXPORTED_FUNCTIONS="); + let encoded = serde_json::to_string( + &symbols.iter().map(|sym| "_".to_owned() + sym).collect::<Vec<_>>(), + ) + .unwrap(); + debug!("{}", encoded); + arg.push(encoded); self.cmd.arg(arg); |
