From 36bd230ffa246ef45260e6f8b28379380f4e2da9 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Sun, 21 Nov 2021 22:38:33 +0100 Subject: [PATCH] Toolchain/Clang: Fix CMake using utilities from the LLVM port If we have the LLVM port installed, CMake might pick up some of the tools installed as part of it (`llvm-ar`, `llvm-strip`, etc.) instead of the ones belonging to the host toolchain. These, of course, can't be run on the host platform, so builds would eventually fail. This made it impossible to rebuild the LLVM toolchain. We now set these variables explicitly when compiling the LLVM runtime libraries in order to avoid this issue. --- Toolchain/CMake/LLVMRuntimesConfig.cmake | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Toolchain/CMake/LLVMRuntimesConfig.cmake b/Toolchain/CMake/LLVMRuntimesConfig.cmake index cca7fc4949..6112fae2be 100644 --- a/Toolchain/CMake/LLVMRuntimesConfig.cmake +++ b/Toolchain/CMake/LLVMRuntimesConfig.cmake @@ -29,10 +29,15 @@ set(CMAKE_CXX_COMPILER_WORKS ON CACHE BOOL "") set(CMAKE_ASM_COMPILER "${SERENITY_TOOLCHAIN_ROOT}/bin/clang" CACHE PATH "") set(CMAKE_ASM_COMPILER_WORKS ON CACHE BOOL "") set(CMAKE_LINKER "${SERENITY_TOOLCHAIN_ROOT}/bin/ld.lld" CACHE PATH "") -foreach(tool ranlib;nm;objdump;objcopy;strip) - string(TOUPPER tool Tool) - set(CMAKE_${Tool} "${SERENITY_TOOLCHAIN_ROOT}/bin/llvm-${tool}" CACHE PATH "") -endforeach() + +set(CMAKE_ADDR2LINE "${SERENITY_TOOLCHAIN_ROOT}/bin/llvm-addr2line" CACHE PATH "") +set(CMAKE_AR "${SERENITY_TOOLCHAIN_ROOT}/bin/llvm-ar" CACHE PATH "") +set(CMAKE_NM "${SERENITY_TOOLCHAIN_ROOT}/bin/llvm-nm" CACHE PATH "") +set(CMAKE_OBJCOPY "${SERENITY_TOOLCHAIN_ROOT}/bin/llvm-objcopy" CACHE PATH "") +set(CMAKE_OBJDUMP "${SERENITY_TOOLCHAIN_ROOT}/bin/llvm-objdump" CACHE PATH "") +set(CMAKE_RANLIB "${SERENITY_TOOLCHAIN_ROOT}/bin/llvm-ranlib" CACHE PATH "") +set(CMAKE_READELF "${SERENITY_TOOLCHAIN_ROOT}/bin/llvm-readelf" CACHE PATH "") +set(CMAKE_STRIP "${SERENITY_TOOLCHAIN_ROOT}/bin/llvm-strip" CACHE PATH "") set(CMAKE_C_COMPILER_TARGET ${target_triple} CACHE STRING "") set(CMAKE_CXX_COMPILER_TARGET ${target_triple} CACHE STRING "")