Skip to content

eld fails to build/install with CPack #737

@jonathonpenix

Description

@jonathonpenix

Description
CPack is a packaging tool commonly used with cmake (used by ATfE, Zephyr's LLVM SDK, soon-to-be-used by cpullvm). Right now, trying to use CPack to package something including eld results in failures like below:

CPack: - Install project: example []
CMake Error at /local/mnt/workspace/jpenix/toolchains/eld/llvm-project/eld/tools/eld/ld_eld_symlink.cmake:5 (include):
  include could not find requested file:

    /tools/eld/eld_install.cmake

The issue here is that ld_eld_symlink.cmake uses ${CMAKE_BINARY_DIR}, but that isn't defined by default when CPack is running, so we end up with a broken path. It seems this is (sort of, at least) expected behavior: https://discourse.cmake.org/t/cpack-script-not-recognizing-cmake-binary-dir/2191

I think there's a few other variables that might have the same issue there.

Reproducer
The below should fail with the error shown above. Removing the eld bits from the top-level CMakeLists.txt will let the package step succeed.

cat > CMakeLists.txt << '!'
cmake_minimum_required(VERSION 3.16)

project(example)

set(LLVM_ENABLE_PROJECTS clang;lld CACHE STRING "")
set(LLVM_TARGETS_TO_BUILD AArch64;ARM;RISCV CACHE STRING "")
set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")

set(llvmproject_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/llvm-project)
set(LLVM_EXTERNAL_PROJECTS eld)
set(LLVM_EXTERNAL_ELD_SOURCE_DIR ${llvmproject_src_dir}/eld)

add_subdirectory(
    ${llvmproject_src_dir}/llvm llvm
)

include(CPack)
!

cmake -G Ninja \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_C_COMPILER_LAUNCHER=ccache \
      -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
      -DCMAKE_INSTALL_PREFIX=$PWD/install \
      -B $PWD/build \
      -S .

cmake --build build
# (or, directly invoke `cpack -G...`, etc.)
ninja -C build/ package

Thoughts
https://discourse.cmake.org/t/cpack-script-not-recognizing-cmake-binary-dir/2191 mentions that you could always configure a file with the appropriate variables and there's other hacks we could do by passing variables prefixed with CPACK_, etc.

But, given that #710 I think we should just transition to llvm's utilities to define/install symlinks--I think that solves both these issues and lets us delete a bunch of cmake in eld, which seems like a win. I'll explore this route.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcmake

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions