Skip to content

Commit e1e80a9

Browse files
committed
Work around #483
This commit adds a hack to the `wasm-bindgen` CLI tool to work around #483 which is present on nightly Rust with the recent LLVM upgrade. Hopefully this'll carry us forward until the [upstream bug][1] is fixed. Closes #483 [1]: https://bugs.llvm.org/show_bug.cgi?id=38184
1 parent 1d3e8f4 commit e1e80a9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

crates/cli-support/src/lib.rs

+15
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,28 @@ fn extract_programs(module: &mut Module) -> Result<Vec<shared::Program>, Error>
291291
to_remove.push(i);
292292

293293
let mut payload = custom.payload();
294+
let mut added_programs = Vec::new();
294295
while payload.len() > 0 {
295296
let len = ((payload[0] as usize) << 0)
296297
| ((payload[1] as usize) << 8)
297298
| ((payload[2] as usize) << 16)
298299
| ((payload[3] as usize) << 24);
299300
let (a, b) = payload[4..].split_at(len as usize);
300301
payload = b;
302+
303+
// Due to a nasty LLVM bug it's currently possible for LLVM to
304+
// duplicate custom section directives in intermediate object files.
305+
// This means that we could see multiple program directives when in
306+
// fact we were originally only meant to see one!
307+
//
308+
// Work around the issue here until the upstream bug,
309+
// https://bugs.llvm.org/show_bug.cgi?id=38184, is hopefully fixed
310+
// via some other means.
311+
if added_programs.iter().any(|p| a == *p) {
312+
continue
313+
}
314+
added_programs.push(a);
315+
301316
let p: shared::ProgramOnlySchema = match serde_json::from_slice(&a) {
302317
Ok(f) => f,
303318
Err(e) => bail!("failed to decode what looked like wasm-bindgen data: {}", e),

0 commit comments

Comments
 (0)