1
Fork 0

Fix emscripten linker invocation

This commit is contained in:
bjorn3 2022-05-06 17:20:42 +02:00
parent 606848a61e
commit 5cc3593c17
3 changed files with 8 additions and 13 deletions

View file

@ -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);