Skip to content

Commit

Permalink
fix CI errors in wasm-bindgen
Browse files Browse the repository at this point in the history
  • Loading branch information
google-yfyang committed Mar 4, 2025
1 parent 718b6fe commit 9130158
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 33 deletions.
7 changes: 4 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
runner = 'cargo run -p wasm-bindgen-cli --bin wasm-bindgen-test-runner --'

[build]

[target.'cfg(all(target_arch = "wasm32", target_os = "emscripten"))']
rustflags = [
"-Cllvm-args=-enable-emscripten-cxx-exceptions=0",
"-Clink-arg=-Wno-undefined",
"-Crelocation-model=static",
"-Cllvm-args=-enable-emscripten-cxx-exceptions=0",
"-Clink-arg=-Wno-undefined",
"-Crelocation-model=static",
]
2 changes: 1 addition & 1 deletion crates/cli-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ version = "0.2.100"
anyhow = "1.0"
base64 = "0.22"
log = "0.4"
regex = "1"
rustc-demangle = "0.1.13"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tempfile = "3.0"
walrus = { version = "0.23", features = ['parallel'] }
regex = "1"
wasm-bindgen-externref-xform = { path = '../externref-xform', version = '=0.2.100' }
wasm-bindgen-multi-value-xform = { path = '../multi-value-xform', version = '=0.2.100' }
wasm-bindgen-shared = { path = "../shared", version = '=0.2.100' }
Expand Down
3 changes: 1 addition & 2 deletions crates/cli-support/src/js/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1660,8 +1660,7 @@ impl Invocation {
if cx.import_never_log_error(import) {
*log_error = false;
}
let ret = cx.invoke_import(import, kind, args, variadic, prelude, import_deps);
return ret;
cx.invoke_import(import, kind, args, variadic, prelude, import_deps)
}
}
}
Expand Down
40 changes: 18 additions & 22 deletions crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,11 +987,7 @@ __wbg_set_wasm(wasm);"
}

let js = match &self.config.mode {
OutputMode::Emscripten => format!(
"\
{imports_init}",
imports_init = imports_init
),
OutputMode::Emscripten => imports_init.to_string(),
_ => format!(
"\
async function __wbg_load(module, imports) {{
Expand Down Expand Up @@ -2654,15 +2650,15 @@ __wbg_set_wasm(wasm);"
}
let table = self.export_function_table()?;
if matches!(self.config.mode, OutputMode::Emscripten) {
self.emscripten_library.push_str(&format!(
self.emscripten_library.push_str(
"
$CLOSURE_DTORS: `(typeof FinalizationRegistry === 'undefined')
? {{ register: () => {{}}, unregister: () => {{}} }}
: new FinalizationRegistry(state => {{
wasmExports.__indirect_function_table.get(state.dtor)(state.a, state.b)
}})`,\n
"
));
",
);
} else {
self.global(&format!(
"
Expand Down Expand Up @@ -3187,20 +3183,20 @@ __wbg_set_wasm(wasm);"
"function() {{ return logError(function {}, arguments) }}",
code
)
} else {
if !import_deps.is_empty() {
for dep in &import_deps {
self.emscripten_deps.insert(dep.clone());
}
format!(
"function{},\n{}__deps: [{}]",
code,
self.module.imports.get(core).name,
import_deps.join(",")
)
} else {
format!("function{}\n", code)
} else if (matches!(self.config.mode, OutputMode::Emscripten)
&& !import_deps.is_empty())
{
for dep in &import_deps {
self.emscripten_deps.insert(dep.clone());
}
format!(
"function{},\n{}__deps: [{}]",
code,
self.module.imports.get(core).name,
import_deps.join(",")
)
} else {
format!("function{}\n", code)
};

self.wasm_import_definitions.insert(core, code);
Expand All @@ -3210,7 +3206,7 @@ __wbg_set_wasm(wasm);"
assert!(!log_error);

if matches!(self.config.mode, OutputMode::Emscripten) {
self.emscripten_library.push_str("$");
self.emscripten_library.push('$');
self.emscripten_library.push_str(&self.adapter_name(id));
self.emscripten_library.push_str(": function");
self.emscripten_library
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/bin/wasm-bindgen-test-runner/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn main() -> anyhow::Result<()> {
.map(Path::new)
.context("file to test is not a valid file, can't extract file name")?;

let mut file_name_buf = PathBuf::from(cli.file.clone());
let mut file_name_buf = cli.file.clone();

// Repoint the file to be read from "name.js" to "name.wasm" in the case of emscripten.
// Rustc generates a .js and a .wasm file when targeting emscripten. It lists the .js
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/bin/wasm-bindgen-test-runner/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ pub(crate) fn spawn(
response
})
.map_err(|e| anyhow!("{}", e))?;
return Ok(srv);
Ok(srv)
}

pub(crate) fn spawn_emscripten(
Expand Down Expand Up @@ -390,7 +390,7 @@ pub(crate) fn spawn_emscripten(
response
})
.map_err(|e| anyhow!("{}", e))?;
return Ok(srv);
Ok(srv)
}

fn try_asset(request: &Request, dir: &Path) -> Response {
Expand Down
4 changes: 2 additions & 2 deletions src/convert/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl WasmAbi for i128 {

#[inline]
fn join(low: u64, high: u64, _: (), _: ()) -> Self {
((high as u128) << 64 | low as u128) as i128
(((high as u128) << 64) | low as u128) as i128
}
}
impl WasmAbi for u128 {
Expand All @@ -62,7 +62,7 @@ impl WasmAbi for u128 {

#[inline]
fn join(low: u64, high: u64, _: (), _: ()) -> Self {
(high as u128) << 64 | low as u128
((high as u128) << 64) | low as u128
}
}

Expand Down

0 comments on commit 9130158

Please sign in to comment.