Skip to content

Commit

Permalink
Merge pull request #1059 from messense/override-wasm-flags
Browse files Browse the repository at this point in the history
Allow user to override default Emscripten settings
  • Loading branch information
messense authored Aug 15, 2022
2 parents c1e93e0 + 6bca66c commit bd7b16e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

* Allow user to override default Emscripten settings in [#1059](https://github.com/PyO3/maturin/pull/1059)

## [0.13.2] - 2022-08-14

* Deprecate manylinux 2010 support in [#858](https://github.com/PyO3/maturin/pull/858).
Expand Down
29 changes: 22 additions & 7 deletions src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,28 @@ fn compile_target(
}
} else if target.is_emscripten() {
let flags = rust_flags.get_or_insert_with(Default::default);
flags.push(" -Z link-native-libraries=no");
let emscripten_args = [
"-C".to_string(),
"link-arg=-sSIDE_MODULE=2".to_string(),
"-C".to_string(),
"link-arg=-sWASM_BIGINT".to_string(),
];
// Allow user to override these default flags
if !flags.to_string_lossy().contains("link-native-libraries") {
flags.push(" -Z link-native-libraries=no");
}
let mut emscripten_args = Vec::new();
// Allow user to override these default settings
if !cargo_rustc
.args
.iter()
.any(|arg| arg.contains("SIDE_MODULE"))
{
emscripten_args.push("-C".to_string());
emscripten_args.push("link-arg=-sSIDE_MODULE=2".to_string());
}
if !cargo_rustc
.args
.iter()
.any(|arg| arg.contains("WASM_BIGINT"))
{
emscripten_args.push("-C".to_string());
emscripten_args.push("link-arg=-sWASM_BIGINT".to_string());
}
cargo_rustc.args.extend(emscripten_args);
}

Expand Down

0 comments on commit bd7b16e

Please sign in to comment.