Skip to content

Deprecate the use of LLVM_ENABLE_PROJECTS for compiler-rt #124012

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

Open
petrhosek opened this issue Jan 22, 2025 · 4 comments
Open

Deprecate the use of LLVM_ENABLE_PROJECTS for compiler-rt #124012

petrhosek opened this issue Jan 22, 2025 · 4 comments
Labels
cmake Build system in general and CMake in particular compiler-rt

Comments

@petrhosek
Copy link
Member

We should deprecate the use of LLVM_ENABLE_PROJECTS for compiler-rt in favor of LLVM_ENABLE_RUNTIMES which would greatly simplify the build and allow improvements that are currently not possible.

petrhosek added a commit to petrhosek/llvm-project that referenced this issue Jan 22, 2025
…RUNTIMES

We plan to make this a hard error in the LLVM 21 release.

Link llvm#124012
@EugeneZelenko EugeneZelenko added the cmake Build system in general and CMake in particular label Jan 22, 2025
petrhosek added a commit that referenced this issue Jan 28, 2025
…RUNTIMES (#124016)

We plan to make this a hard error in the LLVM 21 release.

Link #124012
@KyunLFA
Copy link

KyunLFA commented Jan 31, 2025

Build failure here when choosing compiler-rt as runtime. Works a-OK as a project build.
It appears the runtime build is somehow building compiler-rt with the system ld (not even my overriden lld but ld.bfd instead), symlinking /usr/bin/ld to the just built lld did not resolve. Will try to find the specific compilation flag that is breaking by 01/Feb 0 AM UTC-3.

inxi --basic
System:
  Host: cachyos Kernel: 6.13.0-smol arch: x86_64 bits: 64
  Desktop: N/A Distro: CachyOS
Machine:
  Type: Desktop System: ASRock product: B650M-HDV/M.2 v: N/A
    serial: 
  Mobo: ASRock model: B650M-HDV/M.2 serial: 
    UEFI: American Megatrends LLC. v: 3.15 date: 12/10/2024
CPU:
  Info: 12-core AMD Ryzen 9 7900X [MT MCP] speed (MHz): avg: 3431
    min/max: 545/5911
Graphics:
  Device-1: Advanced Micro Devices [AMD/ATI] Navi 32 [Radeon RX 7700 XT /
    7800 XT] driver: amdgpu v: kernel
  Display: wayland server: X.org v: 1.21.1.15 with: Xwayland v: 21.1.99
    driver: X: loaded: modesetting unloaded: vesa dri: radeonsi gpu: amdgpu
    resolution: 1920x1080~75Hz
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: amd mesa v: 25.0.0-devel
    renderer: AMD Radeon RX 7800 XT (radeonsi navi32 ACO DRM 3.59 6.13.0-smol)
  Info: Tools: api: clinfo, eglinfo, glxinfo, vulkaninfo
    de: kscreen-console,kscreen-doctor gpu: amdgpu_top, lact, umr
    wl: wayland-info,wlr-randr x11: xdriinfo, xdpyinfo, xprop, xrandr
Network:
  Device-1: Realtek RTL8125 2.5GbE driver: r8169
  Device-2: Sony DualSense wireless controller (PS5)
    driver: playstation,snd-usb-audio,usbhid type: USB
Drives:
  Local Storage: total: 2.39 TiB used: 1.9 TiB (79.5%)
Info:
  Memory: total: 96 GiB note: est. available: 93.84 GiB used: 8.68 GiB (9.2%)
  Processes: 528 Uptime: 16h 19m Shell: fish inxi: 3.3.37
Build error
[1071/1092] Linking CXX static library /home/deck/.cache/paru/clone/llvm-git/src/_build/lib/clang/21/lib/x86_64-pc-linux-gnu/libclang_rt.fuzzer_interceptors.a
FAILED: /home/deck/.cache/paru/clone/llvm-git/src/_build/lib/clang/21/lib/x86_64-pc-linux-gnu/libclang_rt.fuzzer_interceptors.a 
: && /usr/bin/cmake -E rm -f /home/deck/.cache/paru/clone/llvm-git/src/_build/lib/clang/21/lib/x86_64-pc-linux-gnu/libclang_rt.fuzzer_interceptors.a && /home/deck/.cache/paru/clone/llvm-git/src/_build/bin/llvm-ar Dqc /home/deck/.cache/paru/clone/llvm-git/src/_build/lib/clang/21/lib/x86_64-pc-linux-gnu/libclang_rt.fuzzer_interceptors.a  compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer_interceptors.x86_64.dir/FuzzerInterceptors.cpp.o && /home/deck/.cache/paru/clone/llvm-git/src/_build/bin/llvm-ranlib -D /home/deck/.cache/paru/clone/llvm-git/src/_build/lib/clang/21/lib/x86_64-pc-linux-gnu/libclang_rt.fuzzer_interceptors.a && cd /home/deck/.cache/paru/clone/llvm-git/src/_build/runtimes/runtimes-bins/compiler-rt/lib/fuzzer/cxx_x86_64_merge.dir && /home/deck/.cache/paru/clone/llvm-git/src/_build/bin/clang++ --target=x86_64-pc-linux-gnu -m64 -Wl,--whole-archive /home/deck/.cache/paru/clone/llvm-git/src/_build/lib/clang/21/lib/x86_64-pc-linux-gnu/libclang_rt.fuzzer_interceptors.a -Wl,--no-whole-archive /home/deck/.cache/paru/clone/llvm-git/src/_build/runtimes/runtimes-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a -r -o fuzzer_interceptors.o && /home/deck/.cache/paru/clone/llvm-git/src/_build/./bin/llvm-objcopy --localize-hidden fuzzer_interceptors.o && /usr/bin/cmake -E remove /home/deck/.cache/paru/clone/llvm-git/src/_build/lib/clang/21/lib/x86_64-pc-linux-gnu/libclang_rt.fuzzer_interceptors.a && /home/deck/.cache/paru/clone/llvm-git/src/_build/bin/llvm-ar qcs /home/deck/.cache/paru/clone/llvm-git/src/_build/lib/clang/21/lib/x86_64-pc-linux-gnu/libclang_rt.fuzzer_interceptors.a fuzzer_interceptors.o
/usr/bin/ld: /home/deck/.cache/paru/clone/llvm-git/src/_build/lib/clang/21/lib/x86_64-pc-linux-gnu/libclang_rt.fuzzer_interceptors.a: member /home/deck/.cache/paru/clone/llvm-git/src/_build/lib/clang/21/lib/x86_64-pc-linux-gnu/libclang_rt.fuzzer_interceptors.a(FuzzerInterceptors.cpp.o) in archive is not an object 
CMake build arguments:
cmake \
        -B _build \
        -S "$srcdir"/llvm-project/llvm  \
        -G Ninja \
        -D CMAKE_BUILD_TYPE=Release \
        -D CMAKE_INSTALL_PREFIX=/usr \
        -D LLVM_BINUTILS_INCDIR=/usr/include \
        -D LLVM_APPEND_VC_REV=ON \
        -D LLVM_VERSION_SUFFIX="" \
        -D LLVM_DEFAULT_TARGET_TRIPLE="x86_64-pc-linux-gnu" \
        -D LLVM_TARGETS_TO_BUILD="X86;AMDGPU;BPF;AArch64;ARM;WebAssembly;SPIRV" \
        -D BOLT_TARGETS_TO_BUILD="X86;AArch64" \
        -D LLVM_HOST_TRIPLE=$CHOST \
        -D LLVM_LINK_LLVM_DYLIB=ON \
        -D LLVM_ENABLE_RTTI=ON \
        -D FFI_INCLUDE_DIR:PATH="$(pkg-config --variable=includedir libffi)" \
        -D LLVM_BUILD_LLVM_DYLIB=ON \
        -D LLVM_ENABLE_FFI=ON \
        -D LLVM_INSTALL_UTILS=ON \
        -D LLVM_BUILD_DOCS=ON \
        -D LLVM_ENABLE_DOXYGEN=OFF \
        -D LLVM_ENABLE_SPHINX=ON \
        -D SPHINX_OUTPUT_HTML:BOOL=OFF \
        -D SPHINX_WARNINGS_AS_ERRORS=OFF \
        -D LLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;offload;openmp;compiler-rt" \
        -D LLVM_ENABLE_PROJECTS="llvm;polly;lldb;lld;clang-tools-extra;clang;bolt;mlir" \
        -D LLVM_LIT_ARGS="-sv --ignore-fail" \
        -D LLVM_ENABLE_DUMP=ON \
        -Wno-dev
FLAGS:
CFLAGS="-Wno-unused-command-line-argument -flto=full -mtune=znver4 -march=znver4 -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-protector-all --param=ssp-buffer-size=4 -fcf-protection -fno-semantic-interposition -mllvm -polly -fwhole-program-vtables -pthread -fopenmp -mllvm -polly-parallel-force -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=24 -mllvm -polly-vectorizer=stripmine -mllvm -polly-position=before-vectorizer -fopenmp-extensions -foptimize-sibling-calls -funroll-loops -fslp-vectorize -fvectorize -mllvm -polly-reschedule -mllvm -polly-tc-opt -mllvm -polly-tiling -mllvm -polly-2nd-level-tiling -mllvm -polly-matmul-opt -mllvm -polly-optimized-scops -mllvm -polly-pattern-matching-based-opts -mllvm -polly-postopts -mllvm -polly-register-tiling -ffp-contract=fast -fbinutils-version=2.43 -fveclib=AMDLIBM -fstrict-enums -fstrict-aliasing -fopenmp -fopenmp-extensions"
CXXFLAGS="-Wno-unused-command-line-argument -flto=full -mtune=znver4 -march=znver4 -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-protector-all --param=ssp-buffer-size=4 -fcf-protection -fno-semantic-interposition -mllvm -polly -fwhole-program-vtables -pthread -fopenmp -mllvm -polly-parallel-force -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=24 -mllvm -polly-vectorizer=stripmine -mllvm -polly-position=before-vectorizer -fopenmp-extensions -foptimize-sibling-calls -funroll-loops -fslp-vectorize -fvectorize -mllvm -polly-reschedule -mllvm -polly-tc-opt -mllvm -polly-tiling -mllvm -polly-2nd-level-tiling -mllvm -polly-matmul-opt -mllvm -polly-optimized-scops -mllvm -polly-pattern-matching-based-opts -mllvm -polly-postopts -mllvm -polly-register-tiling -ffp-contract=fast -fbinutils-version=2.43 -fveclib=AMDLIBM -Wp,-D_GLIBCXX_ASSERTIONS -fstrict-enums -fstrict-aliasing -fopenmp -fopenmp-extensions"
LDFLAGS="-v -fuse-ld=lld -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now,--threads=24,-z,pack-relative-relocs,--lto-O3,--lto-CGO3,-lpthread,--icf=safe,--ignore-data-address-equality,-z,stack-size=8192,-lomp,-lpthread"

@rorth
Copy link
Collaborator

rorth commented Feb 3, 2025

When doing a runtimes build, the compiler-rt builtins tests still aren't run, unlike in a projects build. This was reported as part of Issue #72511 almost a year and a half ago, and is still unfixed. IMO this is a showstopper for switching to runtimes builds (and it shame it's been ignored for so long).

@KyunLFA
Copy link

KyunLFA commented Feb 16, 2025

Build failure here when choosing compiler-rt as runtime. Works a-OK as a project build. It appears the runtime build is somehow building compiler-rt with the system ld (not even my overriden lld but ld.bfd instead), symlinking /usr/bin/ld to the just built lld did not resolve. Will try to find the specific compilation flag that is breaking by 01/Feb 0 AM UTC-3.
inxi --basic

Build error

CMake build arguments:

FLAGS:

Found my issue. It was LTO... Full LTO enforced on the C[XX]FLAGS level on the LLVM build with compiler-rt as runtime hard fails, unless -ffat-lto-objects is passed.

@ilovepi
Copy link
Contributor

ilovepi commented Feb 18, 2025

@KyunLFA I doubt you just want to pass -ffat-lto-objects to the build. Passing -ffat-lto-objects to clang will make it emit FatLTO objects (ELF objects with an .llvm.lto section containing bitcode). If you want to use the bitcode section for LTO linking, LLD needs to be passed --fat-lto-objects to select those sections from FatLTO object files. Clang will do this automatically when used as a linker, but I see you're setting CFLAGS and LDFLAGS, so I'm guessing those aren't doing what you expect, and you're just getting normal non-LTO linking. (see for more info https://llvm.org/docs/FatLTO.html).

Do note that there is some support int he CMake for building the toolchain and runtimes with LTO and FatLTO.
In your CMake invocation or cache file, you can set LLVM_ENABLE_LTO=On LLVM_ENABLE_FATLTO=On If you want to enable LTO for runtimes, RUNTIMES_LLVM_EABLE_LTO=On RUNTIMES_LLVM_ENABLE_FATLTO=On. Note, that if you use the per target runtimes build, you'll need to set the RUNTIMES_<target>_LLVM_* prefix appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular compiler-rt
Projects
None yet
Development

No branches or pull requests

5 participants