Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Mar 27, 2024

As part of #21502 some assertions were added to the wasm SjLj helpers.

Because calls to these functions can be generated during LTO we exclude compiler-rt from LTO and always build it as normal object files. Because these normal object files could be pulled in after LTO takes
place, they cannot themsleves refer to LTO objects. Sadly assert
referees to printf and stdout stuff which is compiled as LTO. This
leads the failures we are currently setting for
lto0.test_longjmp_standalone_standalone:

wasm-ld: error: /usr/local/google/home/sbc/dev/wasm/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/libc-debug.a(stderr.o): attempt to add bitcode file after LTO (__stderr_FILE)
wasm-ld: error: /usr/local/google/home/sbc/dev/wasm/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/libc-debug.a(fprintf.o): attempt to add bitcode file after LTO (fprintf)

Building with -DNDEBUG works around this issue by not actually including the assert code. Its also more correct to do so for compiler-rt which is not a debug library.

@sbc100 sbc100 requested review from dschuff and kripken March 27, 2024 16:57
As part of emscripten-core#21502 some assertions were added to the wasm SjLj helpers.

Because calls to these functions can be generated during LTO we exclude
compiler-rt from LTO and always build it as normal object files.
Because these normal object files could be pulled in after LTO takes
place, they cannot themsleves refer to LTO objects.   Sadly `assert`
referees to printf and stdout stuff which is compiled as LTO.  This
leads the failures we are currently setting for
lto0.test_longjmp_standalone_standalone:

```
wasm-ld: error: /usr/local/google/home/sbc/dev/wasm/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/libc-debug.a(stderr.o): attempt to add bitcode file after LTO (__stderr_FILE)
wasm-ld: error: /usr/local/google/home/sbc/dev/wasm/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/libc-debug.a(fprintf.o): attempt to add bitcode file after LTO (fprintf)
```

Building with `-DNDEBUG` works around this issue by not actually
including the assert code.  Its also more correct to do so for
compiler-rt which is not a debug library.
@sbc100 sbc100 enabled auto-merge (squash) March 27, 2024 16:58
@sbc100 sbc100 disabled auto-merge March 27, 2024 18:34
@sbc100 sbc100 merged commit b059a0c into emscripten-core:main Mar 27, 2024
@sbc100 sbc100 deleted the fix_lto_test branch March 27, 2024 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants