[PATCH] D127812: [AArch64] FMV support and necessary target features dependencies.
Mitch Phillips via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 21 12:48:40 PST 2022
hctim added a comment.
In D127812#4011372 <https://reviews.llvm.org/D127812#4011372>, @ilinpv wrote:
> Regular builds works fine for me, pthreads located here "/lib/x86_64-linux-gnu/libpthread.so" "/usr/lib/x86_64-linux-gnu/libpthread.so". Enabling "-DLLVM_USE_SANITIZER=Memory" resulted in many "WARNING: MemorySanitizer: use-of-uninitialized-value" on tblgen like:
>
> cd /data/ReleasesToCommit/llvm-project/build && /data/ReleasesToCommit/llvm-project/build/bin/llvm-tblgen -gen-intrinsic-enums -intrinsic-prefix=s390 -I /data/ReleasesToCommit/llvm-project/llvm/include/llvm/IR -I/data/ReleasesToCommit/llvm-project/build/include -I/data/ReleasesToCommit/llvm-project/llvm/include /data/ReleasesToCommit/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsS390.h -d include/llvm/IR/IntrinsicsS390.h.d
> [build] ==2441251==WARNING: MemorySanitizer: use-of-uninitialized-value
Yeah that's a false-positive because of bad-ordering. MSan is much tricker because it requires an instrumented libcxx. If you can't use the buildscript, an MVP for the right ordering should be something like:
1. Build a new clang.
$ cd /tmp/1/
$ cmake \
-DLLVM_ENABLE_PROJECTS="clang;compiler-rt;lld" \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_USE_LINKER=lld \
-DCMAKE_C_FLAGS="-Wall" \
-DCMAKE_CXX_FLAGS="-Wall" \
/path/to/llvm/llvm
$ ninja clang lld compiler-rt llvm-symbolizer
2. Build a sanitizer libcxx.
$ cd /tmp/2
$ cmake \
-DCMAKE_C_COMPILER=/tmp/1/bin/clang \
-DCMAKE_CXX_COMPILER=/tmp/1/bin/clang++ \
-GNinja \
-DLLVM_USE_SANITIZER=Memory \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RUNTIMES="'libcxx;libcxxabi'" \
-DLLVM_USE_LINKER="'lld'" \
/path/to/llvm/runtimes/ # <-------- Make sure this is *runtimes*, not llvm.
$ ninja cxx cxxabi
3. Build a msan-ified clang, and use the libcxx from step 2.
$ cd /tmp/3
$ cat .cmake_script.sh
#!/bin/bash -e
LDFLAGS="-lc++abi"
LDFLAGS="$LDFLAGS -Wl,--rpath=/tmp/2/lib" # <---- use the instrumented libcxx from step 2
LDFLAGS="$LDFLAGS -L/tmp/2/lib"
CFLAGS="$LDFLAGS"
CFLAGS="$CFLAGS -fsanitize=memory"
CFLAGS="$CFLAGS -nostdinc++"
CFLAGS="$CFLAGS -isystem /tmp/2/include" # <---- use the instrumented libcxx from step 2
CFLAGS="$CFLAGS -isystem /tmp/2/include/c++/v1"
CFLAGS="$CFLAGS -w"
CFLAGS="$CFLAGS -fsanitize-memory-use-after-dtor -fsanitize-memory-param-retval"
USE_SANITIZER="Memory"
# USE_SANITIZER="MemoryWithOrigins" # <-------------------+-- uncomment these and comment the USE_SANITIZER="Memory" above to get track-origins.
# CFLAGS="$CFLAGS -fsanitize-memory-track-origins=2" # <--+
cmake \
-DCMAKE_C_COMPILER=/tmp/1/bin/clang \
-DCMAKE_CXX_COMPILER=/tmp/1/bin/clang++ \
-DLLVM_ENABLE_LIBCXX=ON \
-GNinja \
-DLLVM_USE_SANITIZER="$USE_SANITIZER" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_C_FLAGS="$CFLAGS" \
-DCMAKE_CXX_FLAGS="$CFLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS" \
-DLLVM_ENABLE_PROJECTS="clang;lld;clang-tools-extra" \
-DLLVM_USE_LINKER="lld" \
/path/to/llvm/llvm
$ . .cmake_script.sh
$ ninja clang lld
$ ninja check-clang check-llvm # <----- finally, run your tests
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127812/new/
https://reviews.llvm.org/D127812
More information about the cfe-commits
mailing list