-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Open
Labels
build-problemcmakeBuild system in general and CMake in particularBuild system in general and CMake in particular
Description
While compiling 17.0.2 for Windows using mingw-w64 and a bootstrap compiler, I got the following error while configuring the native sub-build:
[136/5530] cd /home/ilg/Work/xpack-dev-tools/clang-xpack.git/build/win32-x64/x86_64-w64-mingw32/build/llvm-17.0.2/NATIVE && /home/ilg/.local/xPacks/@xpack-dev-tools/cmake/3.26.5-1.1/.content/bin/cmake -G Ninja -DCMAKE_MAKE_PROGRAM="/home/ilg/Work/xpack-dev-tools/clang-xpack.git/build/win32-x64/xpacks/.bin/ninja" -DCMAKE_C_COMPILER_LAUNCHER="" -DCMAKE_CXX_COMPILER_LAUNCHER="" /home/ilg/Work/xpack-dev-tools/clang-xpack.git/build/win32-x64/sources/llvm-project-17.0.2.src/llvm -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="" -DLLVM_DEFAULT_TARGET_TRIPLE="x86_64-w64-mingw32" -DLLVM_TARGET_ARCH="host" -DLLVM_ENABLE_PROJECTS="clang;lld;lldb;clang-tools-extra;polly" -DLLVM_EXTERNAL_PROJECTS="" -DLLVM_ENABLE_RUNTIMES="" -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN="OFF" -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_INCLUDE_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DLLVM_EXTERNAL_CLANG_SOURCE_DIR=/home/ilg/Work/xpack-dev-tools/clang-xpack.git/build/win32-x64/sources/llvm-project-17.0.2.src/llvm/../clang
FAILED: NATIVE/CMakeCache.txt /home/ilg/Work/xpack-dev-tools/clang-xpack.git/build/win32-x64/x86_64-w64-mingw32/build/llvm-17.0.2/NATIVE/CMakeCache.txt
cd /home/ilg/Work/xpack-dev-tools/clang-xpack.git/build/win32-x64/x86_64-w64-mingw32/build/llvm-17.0.2/NATIVE && /home/ilg/.local/xPacks/@xpack-dev-tools/cmake/3.26.5-1.1/.content/bin/cmake -G Ninja -DCMAKE_MAKE_PROGRAM="/home/ilg/Work/xpack-dev-tools/clang-xpack.git/build/win32-x64/xpacks/.bin/ninja" -DCMAKE_C_COMPILER_LAUNCHER="" -DCMAKE_CXX_COMPILER_LAUNCHER="" /home/ilg/Work/xpack-dev-tools/clang-xpack.git/build/win32-x64/sources/llvm-project-17.0.2.src/llvm -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="" -DLLVM_DEFAULT_TARGET_TRIPLE="x86_64-w64-mingw32" -DLLVM_TARGET_ARCH="host" -DLLVM_ENABLE_PROJECTS="clang;lld;lldb;clang-tools-extra;polly" -DLLVM_EXTERNAL_PROJECTS="" -DLLVM_ENABLE_RUNTIMES="" -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN="OFF" -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_INCLUDE_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DLLVM_EXTERNAL_CLANG_SOURCE_DIR=/home/ilg/Work/xpack-dev-tools/clang-xpack.git/build/win32-x64/sources/llvm-project-17.0.2.src/llvm/../clang
-- The C compiler identification is Clang 17.0.2
-- The CXX compiler identification is Clang 17.0.2
-- The ASM compiler identification is Clang with GNU-like command-line
...
-- Configuring done (18.2s)
CMake Error at cmake/modules/AddLLVM.cmake:967 (add_executable):
The install of the llvm-tblgen target requires changing an RPATH from the
build tree, but this is not supported with the Ninja generator unless on an
ELF-based or XCOFF-based platform. The CMAKE_BUILD_WITH_INSTALL_RPATH
variable may be set to avoid this relinking step.
Call Stack (most recent call first):
cmake/modules/TableGen.cmake:146 (add_llvm_executable)
utils/TableGen/CMakeLists.txt:33 (add_tablegen)
CMake Error at cmake/modules/AddLLVM.cmake:588 (add_library):
The install of the LTO target requires changing an RPATH from the build
tree, but this is not supported with the Ninja generator unless on an
ELF-based or XCOFF-based platform. The CMAKE_BUILD_WITH_INSTALL_RPATH
variable may be set to avoid this relinking step.
Call Stack (most recent call first):
cmake/modules/AddLLVM.cmake:848 (llvm_add_library)
tools/lto/CMakeLists.txt:32 (add_llvm_library)
CMake Error at cmake/modules/AddLLVM.cmake:588 (add_library):
The install of the LTO target requires changing an RPATH from the build
tree, but this is not supported with the Ninja generator unless on an
ELF-based or XCOFF-based platform. The CMAKE_BUILD_WITH_INSTALL_RPATH
variable may be set to avoid this relinking step.
Call Stack (most recent call first):
cmake/modules/AddLLVM.cmake:848 (llvm_add_library)
tools/lto/CMakeLists.txt:32 (add_llvm_library)
CMake Error at cmake/modules/AddLLVM.cmake:967 (add_executable):
The install of the llvm-ar target requires changing an RPATH from the build
tree, but this is not supported with the Ninja generator unless on an
ELF-based or XCOFF-based platform. The CMAKE_BUILD_WITH_INSTALL_RPATH
variable may be set to avoid this relinking step.
Call Stack (most recent call first):
cmake/modules/AddLLVM.cmake:1350 (add_llvm_executable)
cmake/modules/AddLLVM.cmake:1375 (llvm_add_tool)
tools/llvm-ar/CMakeLists.txt:14 (add_llvm_tool)
... and so on, lots of them...
My solution was to add CMAKE_BUILD_WITH_INSTALL_RPATH=ON
to the top CMakeLists.txt
, and to patch
CrossCompile.cmake
to propagate the CMAKE_BUILD_WITH_INSTALL_RPATH
variable down to the sub-build:
From ee0b12eaed9adb713793c9e286bbb2d9016ecd9f Mon Sep 17 00:00:00 2001
From: Liviu Ionescu <ilg@livius.net>
Date: Fri, 6 Oct 2023 15:46:21 +0300
Subject: [PATCH] CrossCompile.cmake: propagate CMAKE_BUILD_WITH_INSTALL_RPATH
---
llvm/cmake/modules/CrossCompile.cmake | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake
index 6af47b51d4c6..9c607f1a7590 100644
--- a/llvm/cmake/modules/CrossCompile.cmake
+++ b/llvm/cmake/modules/CrossCompile.cmake
@@ -74,6 +74,7 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
-DCMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER}"
${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_CURRENT_SOURCE_DIR}
${CROSS_TOOLCHAIN_FLAGS_${project_name}_${target_name}}
+ -DCMAKE_BUILD_WITH_INSTALL_RPATH="${CMAKE_BUILD_WITH_INSTALL_RPATH}"
-DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
-DLLVM_TARGETS_TO_BUILD="${targets_to_build_arg}"
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="${experimental_targets_to_build_arg}"
--
2.37.1 (Apple Git-137.1)
Martin, @mstorsjo, what do think about this issue? Should I submit a PR?
Metadata
Metadata
Assignees
Labels
build-problemcmakeBuild system in general and CMake in particularBuild system in general and CMake in particular