Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems building libc++ for MemorySanitizer #1770

Open
Desperado17 opened this issue Jul 1, 2024 · 1 comment
Open

Problems building libc++ for MemorySanitizer #1770

Desperado17 opened this issue Jul 1, 2024 · 1 comment

Comments

@Desperado17
Copy link

I try to build an instrumented libc++ to avoid false positives with memorysanitizer according to this manual:
https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo

Clang 14, Ubuntu 22.04, x64

Unfortunately, it doesn't work.

First of all the call

cmake -GNinja ../llvm
-DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi"
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DLLVM_USE_SANITIZER=MemoryWithOrigins

fails with

CMake Error at CMakeLists.txt:130 (MESSAGE):
libcxx isn't a known project:
bolt;clang;clang-tools-extra;compiler-rt;cross-project-tests;libc;libclc;lld;lldb;mlir;openmp;polly;pstl;flang.
Did you mean to enable it as a runtime in LLVM_ENABLE_RUNTIMES?

So I try

cmake -GNinja ../llvm
-DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DLLVM_USE_SANITIZER=MemoryWithOrigins

and it fails with

[221/1510] Building IntrinsicsS390.h...
FAILED: include/llvm/IR/IntrinsicsS390.h /home/user/instrumentedlibcpp/llvm-project/build/include/llvm/IR/IntrinsicsS390.h
cd /home/user/instrumentedlibcpp/llvm-project/build && /home/user/instrumentedlibcpp/llvm-project/build/bin/llvm-min-tblgen -gen-intrinsic-enums -intrinsic-prefix=s390 -I /home/user/instrumentedlibcpp/llvm-project/llvm/include/llvm/IR -I/home/user/instrumentedlibcpp/llvm-project/build/include -I/home/user/instrumentedlibcpp/llvm-project/llvm/include /home/user/instrumentedlibcpp/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsS390.h -d include/llvm/IR/IntrinsicsS390.h.d
==59846==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x5575aa91fc4d in _M_is_local /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/basic_string.h:275:6
#1 0x5575aa91fc4d in operator= /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/basic_string.h:867:12
#2 0x5575aa91fc4d in ParseCommandLineOptions /home/user/instrumentedlibcpp/llvm-project/llvm/lib/Support/CommandLine.cpp:1502:15
#3 0x5575aa91fc4d in llvm::cl::ParseCommandLineOptions(int, char const* const*, llvm::StringRef, llvm::raw_ostream*, char const*, bool) /home/user/instrumentedlibcpp/llvm-project/llvm/lib/Support/CommandLine.cpp:1451:24
#4 0x5575aa82a765 in main /home/user/instrumentedlibcpp/llvm-project/llvm/utils/TableGen/TableGen.cpp:82:3
#5 0x7c2a48229d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#6 0x7c2a48229e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#7 0x5575aa78ef54 in _start (/home/user/instrumentedlibcpp/llvm-project/build/bin/llvm-min-tblgen+0x2df54) (BuildId: 4841a2ffffe3c7bb16513e25069a7e3d1d433c62)

Uninitialized value was created by an allocation of 'ref.tmp13.i' in the stack frame of function '_ZN4llvm2cl23ParseCommandLineOptionsEiPKPKcNS_9StringRefEPNS_11raw_ostreamES2_b'
#0 0x5575aa9121d0 in llvm::cl::ParseCommandLineOptions(int, char const* const*, llvm::StringRef, llvm::raw_ostream*, char const*, bool) /home/user/instrumentedlibcpp/llvm-project/llvm/lib/Support/CommandLine.cpp:1431

SUMMARY: MemorySanitizer: use-of-uninitialized-value /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/basic_string.h:275:6 in _M_is_local
Exiting
[228/1510] Building CXX object lib/DebugInfo/CodeView/CMakeFiles/LLVMDebugInfoCodeView.dir/LazyRandomTypeCollection.cpp.o
ninja: build stopped: subcommand failed.

Any ideas how to fix this?

Regards

@jpflori
Copy link

jpflori commented Jul 8, 2024

Same issue for me.
Isn't there a bootstrap issue with llvm-min-tblgen?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants