From a902b32938f7e9bdd48086be76b6a612d1286093 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Fri, 2 Oct 2026 23:29:42 +0200 Subject: [PATCH] fix(packaging): assemble compiler-rt's wasm stubs for wasm32 wasi-sdk's sysroot build hands its compiler-rt sub-build CMAKE_C_COMPILER_TARGET but nothing for the ASM language, so the two wasm/*.S stubs in the builtins (the setjmp/longjmp and C++ exception tags) were assembled for x86-64. wasm-ld warned on every wasm link that the archive members were neither Wasm objects nor bitcode, and anything that reaches those tags, which crafter-build's -wasm-enable-sjlj does, would fail to link. wasi-sdk's own toolchain never sees it because its clang defaults to wasm32-wasip1; the sysroot-only mode against a host clang does. A one-line patch adds CMAKE_ASM_COMPILER_TARGET to that sub-build; it belongs upstream. Co-Authored-By: Claude Fable 5.1 --- .../flatpak/net.catcrafts.CrafterBuild.yaml | 5 +++++ packaging/flatpak/wasi-sdk-asm-target.patch | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 packaging/flatpak/wasi-sdk-asm-target.patch diff --git a/packaging/flatpak/net.catcrafts.CrafterBuild.yaml b/packaging/flatpak/net.catcrafts.CrafterBuild.yaml index 7226ad1..a8b769a 100644 --- a/packaging/flatpak/net.catcrafts.CrafterBuild.yaml +++ b/packaging/flatpak/net.catcrafts.CrafterBuild.yaml @@ -154,6 +154,11 @@ modules: url: https://github.com/WebAssembly/wasi-sdk.git tag: wasi-sdk-34 disable-submodules: true + # The compiler-rt sub-build gets the C target but not the ASM target, so + # its two wasm/*.S stubs come out as host objects when the driving clang + # does not default to wasm32. Reported upstream; drop once wasi-sdk has it. + - type: patch + path: wasi-sdk-asm-target.patch - type: git url: https://github.com/WebAssembly/wasi-libc.git commit: 2e6fb9d8ee0cdf9e431fbcabe8af3115de000a13 diff --git a/packaging/flatpak/wasi-sdk-asm-target.patch b/packaging/flatpak/wasi-sdk-asm-target.patch new file mode 100644 index 0000000..055c72f --- /dev/null +++ b/packaging/flatpak/wasi-sdk-asm-target.patch @@ -0,0 +1,20 @@ +wasi-sdk-sysroot.cmake: tell the compiler-rt sub-build the ASM target too + +The sub-build gets CMAKE_C_COMPILER_TARGET but nothing for the ASM +language, so compiler-rt's wasm/*.S stubs (the setjmp/longjmp and C++ +exception tags) are assembled for the host when the driving clang is not +a wasm-default build. wasm-ld then warns that the archive members are +neither Wasm objects nor bitcode, and code that needs the tags fails to +link. wasi-sdk's own toolchain hides this because its clang defaults to +wasm32-wasip1; the sysroot-only mode against a host clang does not. + +--- a/cmake/wasi-sdk-sysroot.cmake ++++ b/cmake/wasi-sdk-sysroot.cmake +@@ -107,6 +107,7 @@ + -DCOMPILER_RT_BUILD_ORC=OFF + -DCOMPILER_RT_BUILD_GWP_ASAN=OFF + -DCMAKE_C_COMPILER_TARGET=${target} ++ -DCMAKE_ASM_COMPILER_TARGET=${target} + -DCMAKE_C_FLAGS=${WASI_SDK_CPU_CFLAGS} + -DCMAKE_CXX_FLAGS=${WASI_SDK_CPU_CFLAGS} + -DCMAKE_ASM_FLAGS=${WASI_SDK_CPU_CFLAGS}