#1138702 llvm-toolchain-22: WASI preview targets can't find compiler-rt builtins in flat library layout

#1138702#5
Date:
2026-06-02 15:15:43 UTC
From:
To:
Dear Maintainer,

Currently, clang searches for compiler-rt builtins for WASI preview
targets (wasm32-wasip{1,2,3}) in the wrong place. Namely, instead of
searching for
/usr/lib/llvm-22/lib/clang/22/lib/wasi/libclang_rt.builtins-wasm32.a,
clang-22 instead searches for
/usr/lib/llvm-22/lib/clang/22/lib/wasip{1,2,3}/libclang_rt.builtins-wasm32.a.

This bug was originally reported in Ubuntu LP: #2152147[1] but is also
reproducible upstream. I have submitted an issue[2] and a PR[3] to
the upstream LLVM project.

I have included a patch which fixes the problem by making clang search
for wasip{1,2,3} builtins under the "wasi" folder which compiler-rt
installs them in.

Steps to reproduce in a fresh Debian sid install:

# 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
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)

[1]:
https://bugs.launchpad.net/ubuntu/+source/llvm-toolchain-22/+bug/2152147
[2]: https://github.com/llvm/llvm-project/issues/200500
[3]: https://github.com/llvm/llvm-project/pull/200501

#1138702#10
Date:
2026-09-27 06:49:29 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
llvm-toolchain-22, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1138702@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Matthias Klose <doko@debian.org> (supplier of updated llvm-toolchain-22 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Sat, 25 Jul 2026 18:43:43 +0200
Source: llvm-toolchain-22
Architecture: source
Version: 1:22.1.8-2
Distribution: unstable
Urgency: medium
Maintainer: LLVM Packaging Team <pkg-llvm-team@lists.alioth.debian.org>
Changed-By: Matthias Klose <doko@debian.org>
Closes: 1137244 1138702 1141868 1142548 1142778 1147573
Changes:
 llvm-toolchain-22 (1:22.1.8-2) unstable; urgency=medium
 .
   [ Sylvestre Ledru ]
   * d/rules: retry the documentation build serially when sphinx's parallel
     workers die (bare "EOFError" from multiprocessing after a successful
     compile, trixie amd64/arm64 2026-09-02/03)
   * d/rules: set SCCACHE_IDLE_TIMEOUT=0 so the sccache server stays alive for
     the whole build; otherwise it idles out (default 600s) during the quiet
     final-link phase and the libfuzzer step auto-spawns a default-config server
     writing to $HOME/.cache/sccache, which fails with HOME=/nonexistent
   * d/rules: use the shared GCS sccache cache on arm64 too (add arm64 to the
     GCP arch filter)
   * d/rules: Disable sccache on the releases whose glibc is too old for the
     binary the build host provides. /opt/sccache/sccache comes from
     mozilla/sccache's latest release and, on s390x (the only arch without a
     static musl build), needs glibc >= 2.34 since v0.17.0. On focal
     (glibc 2.31) it cannot even start, and the build died at --start-server
     with "version `GLIBC_2.34' not found" in stamps/configure.
   * d/rules: Drop llvm-mt from the install list when it wasn't built.
     Upstream only builds llvm-mt when it detects libxml2 at configure
     time; on Ubuntu focal/arm64 the libxml2 symbol check fails and the
     tool is silently skipped, which made dh_install --fail-missing abort
     on usr/lib/llvm-22/bin/llvm-mt and usr/bin/llvm-mt-22.
   * Add a test for the wasi path detection. Thanks Max Gilmour for the work
     (Closes: #1138702)
   * d/control.in: libfuzzer-X.Y-dev now depends on libclang-rt-X.Y-dev.
     -fsanitize=fuzzer links libclang_rt.fuzzer*.a (and
     libclang_rt.ubsan_standalone.a) from the compiler-rt resource
     directory, which lives in libclang-rt-X.Y-dev. As it was only a
     Recommends of libclang-common-X.Y-dev, it was not pulled into build
     chroots and the link failed. Closes: #1147573.
   * d/debian-llvm-testsuite.bats: don't skip the libFuzzer compilation test
     when the compiler-rt libraries are missing, fail instead.
   * d/libmlir-X.Y.links.in: new, keep a /usr/lib/llvm-X.Y/lib symlink to the
     libMLIR SONAME now installed in /usr/lib/<triplet>. libmlir-X.Y-dev
     ships /usr/lib/llvm-X.Y/lib/libMLIR.so as a relative symlink to it and
     the mlir tools have that directory in their RUNPATH, so both were left
     dangling.
   * d/debian-llvm-testsuite.bats: link the fuzzer runtime from the
     compiler-rt resource directory instead of the removed
     /usr/lib/llvm-X.Y/lib/libFuzzer.a, and check that it is present.
   * d/control.in: document that libfuzzer-X.Y-dev is now a dependency
     package: the fuzzer runtime (libclang_rt.fuzzer*.a) and
     FuzzedDataProvider.h come from the compiler-rt resource directory in
     libclang-rt-X.Y-dev, which is what clang links for -fsanitize=fuzzer.
     This also avoids the empty-binary-package lintian warning.
 .
   [ Talha Can Havadar ]
   * d/p/amdgpu-fix-simulated-trap-continuation-block.diff: cherry-pick
     llvm/llvm-project@9429a1e809fd (PR #174774,
     "[AMDGPU] Fix insertSimulatedTrap to return correct continuation block")
     Fixes a codegen crash on gfx1100/gfx1101/gfx1102 (RDNA3 desktop:
     RX 7900/7800/7700/7600) where clang aborts with
     "fatal error: error in backend: Unsupported instruction : <MCInst NNNN ...>"
     from the AMDGPU AsmPrinter whenever a kernel contains a block that ends in
     llvm.trap() with no successors — an unlowered pseudo reaches the MC layer.
     Notably affects pytorch-rocm 2.12's Loss.hip (FTBFS). Reported upstream as
     llvm/llvm-project#208912. Fix landed on main branch on 2026-01-21 (LLVM 23);
     release/22.x was cut 8 days before and never received it. This cherry-pick
     lets 22.1.x carry the fix without waiting for a 22.1.9 or 22.2.0 point
     release upstream. (Closes: #1141868)
 .
   [ Matthias Klose ]
   * Fix removing RUNPATH, broken in Nov. 2025. Closes: #1142548.
   * Stop building, shipping and testing the obsolete libFuzzer.a.
     Closes: #1147573.
   * Install libmlir shared library in /usr/lib. Closes: #1142778.
   * libmlir: Remove provides, conflicts and replaces. Not needed.
     Closes: #1137244.
Checksums-Sha1:
 441066bfcd3adc8e2d99092a416906683559e6fb 15824 llvm-toolchain-22_22.1.8-2.dsc
 ac4e52194d08bd94088cc58c0a3afd9bc6823eae 183300 llvm-toolchain-22_22.1.8-2.debian.tar.xz
 58bf3666d647d57bc4e001cc8fcba9bf97cc8fe8 39282 llvm-toolchain-22_22.1.8-2_amd64.buildinfo
Checksums-Sha256:
 4df4e778010d03006998ff484996c9d12e7875da129bcaad1cf4e4dbc76abe62 15824 llvm-toolchain-22_22.1.8-2.dsc
 ecee9142cfd59c24ddd97710838cdad4c77558885911f97fa5a310c9e756d842 183300 llvm-toolchain-22_22.1.8-2.debian.tar.xz
 c01220676b53d2f10d65f51afe65d40e1390084263859b04526a3d0c21718f53 39282 llvm-toolchain-22_22.1.8-2_amd64.buildinfo
Files:
 d8b0a2317fb951bb40bd920273db37b9 15824 devel optional llvm-toolchain-22_22.1.8-2.dsc
 9c21723eb868497995784b37aa5c48d1 183300 devel optional llvm-toolchain-22_22.1.8-2.debian.tar.xz
 5772cfc89523702690dbaa2c71d9569e 39282 devel optional llvm-toolchain-22_22.1.8-2_amd64.buildinfo
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEtg21mU05vsTRqVzPfmUo2nUvG+EFAmq4uYEACgkQfmUo2nUv
G+F+2w//T1x5wwShiqYbEO5m37NwCnNo5ANLiHFmDotqPRZtWDcJQr7BRX+PMBUh
XaeumbpRBjid960fbOhCeRUO9250iBe3qvpxtX9naL6uhE1hYxFFzTM6HIOJkCc7
Wf7vvHY7p9IFFivvSh+WTPC+dQJveIfEg9h3CH+aauLvKzLnwqUMltc/WPfUTwxE
HnmT+JVQVJNqid74mPCmD3GByBvqewm6+IpLNvXpIPQdPsDQQ+YcxturAnYAei27
ybr1n9jozrdCu4MiCOhSL3Pvi0zFeoq+EaD9ptFPnAD7JdY+Z7pdd6VMqWSPU+uH
7B/omJQXinGMwKTtY/sRWM5nntvkkdS/LDk/kosUl/+xJ3o064o/8flZlnyvxV15
ndKU7K0qjzwAJLI8ML+1H+8sjiSkGPhpY3ZCVhIQJShywfhSPTMS/icCqUFq14pr
8zGAqDjKEMPRRf2YKC8H4SRU40t4k2PRDHJxiczGa65kAqDNIyXdwXjtYPIbSR+C
Cc7J7kwjRZyfJaZaMqdnpEzmqRJJUa0ddIjJNi30CobghdiCwhF5mHUjGmUPgKK/
oYMTlPwTsLX/BW6XLyXyusrADZWa8SVfWUwZZMP9k/ELZgNXcU/3gUDL7GgoWUXx
qflZVIqNhicqtdWTTo81NB1u4SXBJyKApXhSBxw9H4jYuoIiJwk=
=Q/6H
-----END PGP SIGNATURE-----