Source level dependencies could exist, just like a C library could be written in C++. Then contributors must pay attention to only use struct/enum definitions that do not compiled to code/data that could lead to conflicts.
An arbitrary #include
might lead to undefined symbols. A robust approach is to extract the shared part to a .inc
file with no llvm includes, as [LLVM][compiler-rt][AArch64] Refactor AArch64 CPU features by boomanaiden154 · Pull Request #97777 · llvm/llvm-project · GitHub does.
However, stand-alone builds, used by some distributions, probably do not like true header sharing. For example, the following needs to work. Perhaps a new CMake variable is needed to customize the relevant llvm include path.
cmake -GNinja -Scompiler-rt -B/tmp/out/rt-aarch64 -DCMAKE_CROSSCOMPILING=on -DCMAKE_C_COMPILER=/tmp/Rel/bin/clang -DCMAKE_CXX_COMPILER=/tmp/Rel/bin/clang++ -DCMAKE_{ASM,C,CXX}_COMPILER_TARGET=aarch64-unknown-linux-gnu -DCMAKE_{C,CXX}_FLAGS='-fPIC -D_GNU_SOURCE' -DCMAKE_{EXE,SHARED}_LINKER_FLAGS=-fuse-ld=lld -DLLVM_CMAKE_DIR=/tmp/Rel -DLLVM_APPEND_VC_REV=OFF -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on -DCOMPILER_RT_DEFAULT_TARGET_ONLY=on -DCOMPILER_RT_EMULATOR='qemu-aarch64-static -L /usr/aarch64-linux-gnu' -DCOMPILER_RT_HAS_LLD=on -DCOMPILER_RT_TEST_USE_LLD=on -DCOMPILER_RT_INCLUDE_TESTS=on -DCOMPILER_RT_TEST_COMPILER_CFLAGS=--target=aarch64-unknown-linux-gnu
ninja -C /tmp/out/rt-aarch64
ln -s /tmp/out/rt-aarch64/lib/aarch64-unknown-linux-gnu -t /tmp/Rel/lib/clang/16/lib
In GCC, libsanitizer is based on compiler-rt’s sanitizer libraries. It only uses one file in builtins
, so extra LLVM includes in builtins
should not be a problem.
% ls libsanitizer/builtins/
assembly.h