Open Zingam opened 2 months ago
Same if I install LLVM20:
[cmake] The imported target "LibcTableGenUtil" references the file [cmake] [cmake] "/usr/lib/llvm-20/lib/libLibcTableGenUtil.a"
Same if I install LLVM18:
[cmake] CMake Error at /usr/lib/llvm-18/lib/cmake/clang/ClangTargets.cmake:833 (message): [cmake] The imported target "clangBasic" references the file [cmake] [cmake] "/usr/lib/llvm-18/lib/libclangBasic.a"
@Zingam, can you please explain how this was fixed or can be worked around? I am running into this same issue when trying to build a -fsanitize=memory
instrumented libc++
on a Debian Sid system, using clang-19
from 1:19.1.0~++20240813124017+28f2d04b3ca3-1~exp1~20240813124123.26
and invoking this script attached to this ticket with CLANG=19
.
It would be very convenient if a -fsanitize=memory
instrumented libc++.so
could be made available in the LLVM package repositories, because it would basically bring the same level of support for C and C++. (For C, there are built-in interceptors for the GNU libc
.)
@dr-m Have you tried installing libllvmlibc-20-dev
:
Thank you. I was missing the packages libllvmlibc-19-dev
and libclang-19-dev
.
I also adjusted my build script slightly (not sure if all that is needed):
--- build-msan18.sh
+++ build-msan19.sh
@@ -1,6 +1,6 @@
#!/bin/sh
set -eux
-: ${CLANG=18}
+: ${CLANG=19}
: ${MSAN_LIBDIR=..}
: ${PARALLEL=$(nproc)}
@@ -15,14 +15,17 @@
fi
sudo apt -o APT::Get::Assume-Yes=true install \
- clang-$CLANG libc++-$CLANG-dev libc++abi-$CLANG-dev automake
+ clang-$CLANG libc++-$CLANG-dev libc++abi-$CLANG-dev \
+ libclang-$CLANG-dev libllvmlibc-$CLANG-dev automake
apt -o APT::Get::Assume-Yes=true source \
llvm-toolchain-$CLANG libgnutls28-dev libnettle8 libidn2 libgmp10
mkdir -p ll-build
cd ll-build
cmake ../llvm-toolchain-$CLANG-$CLANG.*/runtimes -DCMAKE_BUILD_TYPE=Release \
- -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
+ -DLLVM_ENABLE_RUNTIMES="libc;libcxx;libcxxabi;libunwind" \
+ -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_DOCS=OFF \
+ -DLLVM_ENABLE_SPHINX=OFF \
-DCMAKE_C_COMPILER=clang-$CLANG \
-DCMAKE_CXX_COMPILER=clang++-$CLANG \
-DLLVM_USE_SANITIZER=MemoryWithOrigins
This exercise was rewarded: I got the fix D158943 that I was looking for. (Note: the automake
in the above diff is not related to clang, but some other libraries that I need to compile with -fsanitize=memory
.)
Still, it would be really great if a -fsanitize=memory
instrumented libc++
package could be provided. After all, -fsanitize=memory
is rather useless for pretty much any C++ code without that.
Thank you. I was missing the packages
libllvmlibc-19-dev
andlibclang-19-dev
.
Great! Now the real question would be: Why the llvm.sh
script fails to install these?
I’m sorry, I just now realize that there could be an officially maintained llvm.sh
script that I might use to avoid issues when compiling libc++
for various LLVM versions. Where is that script available? I could not find it on my system or in the package search at https://packages.debian.org.
I am using my own script, which my comments identify. The title of this ticket does exactly match my usage scenario: trying to build a -fsanitizer=memory
instrumented version of libc++
. There was no build-time dependency on libclang-18-dev
or libllvmlibc-18-dev
for the libc++
of LLVM 18.
@dr-m Please check: https://apt.llvm.org/
@Zingam Thank you. I see that https://apt.llvm.org/llvm.sh would install some packages, some of which would be redundant for what I am trying to achieve. I only want to build libc++
with -fsanitize=memory
, possibly as part of a minimal Docker image. I don’t think that tools like clang-tidy
, clang-format
, or lldb
would be needed to achieve that.
[cmake] CMake Error at /usr/lib/llvm-20/lib/cmake/clang/ClangTargets.cmake:847 (message): [cmake] The imported target "clangBasic" references the file [cmake] [cmake] "/usr/lib/llvm-20/lib/libclangBasic.a" [cmake] [cmake] but this file does not exist. Possible reasons include: [cmake] [cmake] The file was deleted, renamed, or moved to another location. [cmake] [cmake] An install or uninstall procedure did not complete successfully. [cmake] [cmake] * The installation package was faulty and contained [cmake] [cmake] "/usr/lib/llvm-20/lib/cmake/clang/ClangTargets.cmake" [cmake] [cmake] but not all the files it references.
libclang-20-dev Clang library - Development package
[cmake] CMake Error at /usr/lib/llvm-20/lib/cmake/clang/ClangTargets.cmake:847 (message): [cmake] The imported target "clang-cpp" references the file [cmake] [cmake] "/usr/lib/llvm-20/lib/libclang-cpp.so.20.0" [cmake] [cmake] but this file does not exist. Possible reasons include: [cmake] [cmake] The file was deleted, renamed, or moved to another location. [cmake] [cmake] An install or uninstall procedure did not complete successfully. [cmake] [cmake] * The installation package was faulty and contained [cmake] [cmake] "/usr/lib/llvm-20/lib/cmake/clang/ClangTargets.cmake"
libclang-cpp20-dev C++ interface to the Clang library
[cmake] CMake Error at /usr/lib/llvm-20/lib/cmake/clang/ClangTargets.cmake:847 (message): [cmake] The imported target "clang-cpp" references the file [cmake] [cmake] "/usr/lib/llvm-20/lib/libclang-cpp.so.20.0" [cmake] [cmake] but this file does not exist.
Does the package contain the wrong path:
@Zingam please open new issues as they are different problems. Also, please don't share screenshot, they are terrible for accessibility and search thanks
Superseded by the linked issue.
@sylvestre Thanks. I already created a new issue and closed this one: https://github.com/llvm/llvm-project/issues/109153
I noticed this issue in the libc++ CI now: https://github.com/llvm/llvm-project/actions/runs/11008128330/job/30565201169?pr=109291
Maybe it wasn't fixed.
ok, working on it i started a build to see if my fix worked
@zibi2 which versions ? (ubuntu and llvm)
@zibi2 which versions ? (ubuntu and llvm)
Not sure about version of Ubuntu since I don't have access to CI systems. All I can do is look at logs in the link I provided. I see the version of llvm must be 19 based on this from the log:
2024-09-25T15:08:12.9312931Z Ubuntu clang version 19.1.0 (++20240920111944+64075837b553-1~exp1~20240920111958.43)
2024-09-25T15:08:12.9314477Z Target: x86_64-pc-linux-gnu
2024-09-25T15:08:12.9314921Z Thread model: posix
2024-09-25T15:08:12.9315400Z InstalledDir: /usr/lib/llvm-19/bin
Note: I've disabled the clang-tidy checks from the libc++ CI to get our CI back online, so this issue shouldn't be visible when running the libc++ CI anymore. But the issue is real, thanks for investigating it.
@sylvestre reporting as suggested here: https://github.com/llvm/llvm-project/issues/92359 I am trying to build libc++ on WSL Ubuntu 24.04. LLVM19 was installed originally via llvm.sh. I updated today.
$ clang --version Ubuntu clang version 19.0.0 (++20240721081714+0caf0c93e759-1~exp1~20240721081828.299) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/lib/llvm-19/bin
I build via VSCode and I have the following CMakePresets.json file put in /runtimes