feat(wasm): link libsetjmp, so setjmp needs no flag
All checks were successful
Flatpak / flatpak (push) Successful in 17m58s
All checks were successful
Flatpak / flatpak (push) Successful in 17m58s
-mllvm -wasm-enable-sjlj, in every wasm compile because setjmp.h does not compile without it, turns setjmp and longjmp into calls to __wasm_setjmp, __wasm_setjmp_test and __wasm_longjmp and a throw of the __c_longjmp tag, all of which live in wasi-libc's libsetjmp. The driver does not link it, so a program that used setjmp, or a C library that handles its errors that way, failed to link with undefined __wasm_setjmp until the project put -lsetjmp in its linkFlags. Build() adds it to every wasm link, next to -lunwind. A static archive contributes only the members something references, so a program without setjmp gets nothing from it, and every sysroot that passes the exception check ships it. WasmExceptions drops its own -lsetjmp, and its C fixture now fails to link without this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3e125d83f0
commit
70ff11d0a1
3 changed files with 10 additions and 7 deletions
|
|
@ -12,7 +12,8 @@ using namespace Crafter;
|
|||
// libc++.a itself (stoi), and with an argument lets one escape main, which
|
||||
// has to end the run as an uncaught exception rather than exit 0, trap or
|
||||
// hang. Its C source uses setjmp, which compiles and links next to the C++
|
||||
// objects only when C gets the same wasm flags.
|
||||
// objects only when C gets the same wasm flags, and links at all only
|
||||
// because the build adds libsetjmp: the configuration asks for nothing.
|
||||
//
|
||||
// wasm builds used to be compiled with -fno-exceptions, so a throw did not
|
||||
// compile and libc++'s own throws aborted. Each part of turning them on fails
|
||||
|
|
@ -55,9 +56,6 @@ int main() {
|
|||
std::array<fs::path, 1> impls = { "main" };
|
||||
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
||||
cfg.cFiles = { cfg.path / "jump" };
|
||||
// setjmp and longjmp live in libsetjmp, which the build does not link
|
||||
// on its own.
|
||||
cfg.linkFlags.push_back("-lsetjmp");
|
||||
|
||||
std::unordered_map<fs::path, std::shared_future<BuildResult>> depResults;
|
||||
std::mutex depMutex;
|
||||
|
|
|
|||
Loading…
Reference in a new issue