File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -291,13 +291,28 @@ fn extract_programs(module: &mut Module) -> Result<Vec<shared::Program>, Error>
291
291
to_remove. push ( i) ;
292
292
293
293
let mut payload = custom. payload ( ) ;
294
+ let mut added_programs = Vec :: new ( ) ;
294
295
while payload. len ( ) > 0 {
295
296
let len = ( ( payload[ 0 ] as usize ) << 0 )
296
297
| ( ( payload[ 1 ] as usize ) << 8 )
297
298
| ( ( payload[ 2 ] as usize ) << 16 )
298
299
| ( ( payload[ 3 ] as usize ) << 24 ) ;
299
300
let ( a, b) = payload[ 4 ..] . split_at ( len as usize ) ;
300
301
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
+
301
316
let p: shared:: ProgramOnlySchema = match serde_json:: from_slice ( & a) {
302
317
Ok ( f) => f,
303
318
Err ( e) => bail ! ( "failed to decode what looked like wasm-bindgen data: {}" , e) ,
You can’t perform that action at this time.
0 commit comments