** Description changed:
+ [ Impact ]
+
+ * Currently, clang-22 cannot be used to build for WASI targets on
+ 26.04 because clang searches for WASI compiler builtins in the
+ wrong place; i.e., it searches for
+ /usr/lib/llvm-22/lib/clang/22/lib/wasip1/libclang_rt.builtins-wasm32.a
+ instead of
+ /usr/lib/llvm-22/lib/clang/22/lib/wasi/libclang_rt.builtins-wasm32.a.
+
+ * This upload fixes the bug by fixing clang-22's searching logic; it
+ now knows to look for wasip{1,2,3} target builtins under the wasi
+ directory, not the wasip1 directory. clang already has explicit cases
+ for other OS names that don't match their library dir names (FreeBSD,
+ SunOS, etc.); WASI is simply missing from that list.
+
+ [ Test Plan ]
+
+ * This bug can be reproduced, and the fix tested, by simply trying to
+ build anything for the wasm32-wasip1 WASI preview target. Pre-fix,
+ clang will search for the compiler builtins in the wrong path and
+ immediately fail.
+
+ * The following steps were performed in a fresh 26.04 LXD container:
+ $ apt update
+ $ apt install -y clang-22 libclang-rt-22-dev-wasm32 libc++-22-dev-wasm32
lld-22
+ $ touch test.c
+ $ clang-22 --target=wasm32-wasip1 test.c
+
+ * The bugged version should produce an error message like the following:
+ wasm-ld-22: error: cannot open
/usr/lib/llvm-22/lib/clang/22/lib/wasm32-unknown-wasip1/libclang_rt.builtins.a:
No such file or directory
+ clang-22: error: linker command failed with exit code 1 (use -v to see
invocation)
+
+ * The fixed version should produce no such error message and compile
+ the empty C file without issue.
+
+ [ Where problems could occur ]
+
+ * The biggest regression risk is a situation in which someone using
+ clang-22 to build for WASI targets has manually moved the compiler
+ builtins to the location clang-22 (incorrectly) expects them to be.
+ Any packages or end-user systems which do this will suddenly fail
+ because clang-22 will no longer look for compiler builtins at that
+ incorrect path.
+
+ * The same problem will be experienced by those who install any other
+ files to the old incorrect directory--clang will no longer look for
+ *anything* in this directory.
+
+ * Luckily, systems which link the compiler builtins to that incorrect
+ path won't be affected, since the actual files will still be located
+ in the right spot. Issues will only occur if the user has actually
+ moved the compiler builtins out of their original location, or put
+ some other important libraries in the incorrect location.
+
+ * Finally, this problem still exists upstream. I've forwarded the fix
+ (https://github.com/llvm/llvm-project/pull/200501), but it's possible
+ that upstream eventually decides to fix the problem in a different
+ way; for example, by retroactively making the "incorrect" compiler
+ builtin paths the "correct" ones by making compiler-rt install the
+ files in the place clang expects them to be. This is very unlikely,
+ as this problem has already been addressed by upstream in the exact
+ same way for platforms like OpenBSD and SunOS, but there's always a
+ chance that upstream decides to make an exception for the various
+ WASI targets.
+
+ [ Other Info ]
+
+ * Currently, amd64 and arm64 autopkgtests are failing in a PPA, while
+ the other tests pass:
+ - amd64:
https://autopkgtest.ubuntu.com/results/autopkgtest-resolute-maxgmr-llvm-toolchains/resolute/amd64/l/llvm-toolchain-22/20260605_144759_21d6c@/log.gz
+ - arm64:
https://autopkgtest.ubuntu.com/results/autopkgtest-resolute-maxgmr-llvm-toolchains/resolute/arm64/l/llvm-toolchain-22/20260605_145055_9aeaa@/log.gz
+ - armhf:
https://autopkgtest.ubuntu.com/results/autopkgtest-resolute-maxgmr-llvm-toolchains/resolute/armhf/l/llvm-toolchain-22/20260605_144519_37b86@/log.gz
+ - ppc64el:
https://autopkgtest.ubuntu.com/results/autopkgtest-resolute-maxgmr-llvm-toolchains/resolute/ppc64el/l/llvm-toolchain-22/20260605_144852_c2362@/log.gz
+ - s390x:
https://autopkgtest.ubuntu.com/results/autopkgtest-resolute-maxgmr-llvm-toolchains/resolute/s390x/l/llvm-toolchain-22/20260605_154305_5837f@/log.gz
+
+ * This is not a regression. In fact, as shown by the autopkgtest page
+ (https://autopkgtest.ubuntu.com/packages/llvm-toolchain-22),
+ llvm-toolchain-22 has *never* passed an autopkgtest on *any*
+ architecture in 26.04. While we naturally want the autopkgtests to be
+ useful, fixing them is outside of the scope of this particular bug.
+
+ [ Original Bug Description ]
+
This concerns clang-22 version 1:22.1.2-1ubuntu1 in Ubuntu resolute.
In configuring a Firefox build using this compiler, I got the following
error:
DEBUG: Executing: `/usr/bin/clang-22 --target=wasm32-wasi
/tmp/conftesti06p4gt_.c -Werror -D_WASI_EMULATED_PROCESS_CLOCKS
-lwasi-emulated-process-clocks`
DEBUG: The command returned non-zero exit status 1.
DEBUG: Its error output was:
DEBUG: | clang-22: error: argument '--target=wasm32-wasi' is deprecated,
use --target=wasm32-wasip1 instead [-Werror,-Wdeprecated]
ERROR: Can't find clock() in wasi sysroot.
make[3]: *** [debian/rules:232: stamps/configure-browser] Error 1
Okay, so wasm32-wasi is a deprecated target, I'll make the build use
wasm32-wasip1. But then:
DEBUG: Executing: `/usr/bin/clang-22 --target=wasm32-wasip1
/tmp/conftestdc13dov3.c`
DEBUG: The command returned non-zero exit status 1.
DEBUG: Its error output was:
DEBUG: | wasm-ld-22: error: cannot open
/usr/lib/llvm-22/lib/clang/22/lib/wasm32-unknown-wasip1/libclang_rt.builtins.a:
No such file or directory
DEBUG: | clang-22: error: linker command failed with exit code 1 (use -v to
see invocation)
ERROR: Cannot find wasi libraries or problem with the wasm linker. Please
fix the problem. Or build with --without-wasm-sandboxed-libraries.
make[3]: *** [debian/rules:232: stamps/configure-browser] Error 1
Hmm. I see that there is a
/usr/lib/llvm-22/lib/clang/22/lib/wasi/libclang_rt.builtins-wasm32.a
library, but not a
/usr/lib/llvm-22/lib/clang/22/lib/wasm32-unknown-
wasip1/libclang_rt.builtins.a
one. The linker should probably be looking for the former.
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2152147
Title:
Broken wasm32-wasi(p1) support
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/llvm-toolchain-22/+bug/2152147/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs