Skip to content

runtimes builds may fail due to missing llvm-link despite llvm being enabled #139673

Open
@nolongerwait

Description

@nolongerwait

Hi, all

llvm-project version: 20.1.4

I'm running a monorepo CMake build using both LLVM_ENABLE_PROJECTS and LLVM_ENABLE_RUNTIMES, and I'm seeing an issue where the compiler-rt runtime fails to build due to a missing llvm-link binary, even though llvm is explicitly listed in LLVM_ENABLE_PROJECTS.

Here is my CMake invocation:

cmake -G Ninja \
  -DCMAKE_C_COMPILER="${TOOLCHAIN_GCC_INSTALL_DIR}/bin/gcc" \
  -DCMAKE_CXX_COMPILER="${TOOLCHAIN_GCC_INSTALL_DIR}/bin/g++" \
  -DLLVM_ENABLE_PROJECTS="clang;llvm;clang-tools-extra;lld;lldb;openmp" \
  -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \
  -DLLVM_TARGETS_TO_BUILD="${LLVM_ARCH}" \
  -DLLVM_RUNTIME_TARGETS="default;${LLVM_RUNTIME_ARCH}" \
  -DCMAKE_INSTALL_PREFIX="${TOOLCHAIN_TRUNK_LLVM_INSTALL_DIR}" \
  -DCLANG_DEFAULT_LINKER=lld \
  -DLLVM_USE_LINKER=lld \
  -DLLVM_ENABLE_TERMINFO=0 \
  -DLLVM_ENABLE_ASSERTIONS=OFF \
  -DLLVM_BUILD_TESTS=OFF \
  -DLIBOMPTARGET_BUILD_DEVICERTL_BCLIB=OFF \
  -DCOMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER=ON \
  -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
  -DCMAKE_BUILD_TYPE=Release \
  "${TOOLCHAIN_PUBLISH_WORKSPACE}/llvm" &&
  ninja install

❗ Problem
The build fails at this step:

+ for F in $CC $CXX $TBLGEN $LINK $OPT $AR
+ [[ ! -x /home/*****/llvm-project/trunk_llvm_build/bin/llvm-link ]]
+ echo '/home/*****/llvm-project/trunk_llvm_build/bin/llvm-link'
Missing /home/*****/llvm-project/trunk_llvm_build/bin/llvm-link
+ exit 1
FAILED: compiler-rt/lib/sanitizer_common/symbolizer/RTSanitizerCommonSymbolizerInternal.x86_64.o /home/*****/llvm-project/trunk_llvm_build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/compiler-rt/lib/sanitizer_common/symbolizer/RTSanitizerCommonSymbolizerInternal.x86_64.o
cd /home/*****/llvm-project/trunk_llvm_build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/compiler-rt/lib/sanitizer_common/symbolizer/RTSanitizerCommonSymbolizerInternal.x86_64 && FLAGS= CLANG=/home/*****/llvm-project/trunk_llvm_build/./bin/clang /home/*****/llvm-project/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh /home/*****/trunk_llvm_build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/compiler-rt/lib/sanitizer_common/symbolizer/RTSanitizerCommonSymbolizerInternal.x86_64.o

This occurs in build_symbolizer.sh which expects llvm-link, llvm-ar, opt, etc., to be present before runtime components (e.g., compiler-rt) are built.

Even though llvm is part of LLVM_ENABLE_PROJECTS, these tools apparently haven't been built yet when runtimes starts building.

🔍 Question
Should the CMake system enforce that tools like llvm-link are available before attempting to build runtimes, especially compiler-rt?

Or is it the user's responsibility to manually build such tools before running ninja?

🧪 Notes
I can workaround this by manually running ninja llvm-link before full build.

A fully separated two-stage build (build tools → build runtimes) also avoids the issue, but it would be nice to clarify whether this is expected behavior or a missing dependency declaration.

Thanks in advance for your help!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions