[compiler-rt] 0ecd4f6 - [compiler-rt] Check for missing CMAKE_C_COMPILER_TARGET when using COMPILER_RT_DEFAULT_TARGET_ONLY

David Spickett via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 6 05:55:57 PDT 2023


Author: David Spickett
Date: 2023-04-06T12:55:48Z
New Revision: 0ecd4f6c55c0cb4e9ba0e03758925da8cef66088

URL: https://github.com/llvm/llvm-project/commit/0ecd4f6c55c0cb4e9ba0e03758925da8cef66088
DIFF: https://github.com/llvm/llvm-project/commit/0ecd4f6c55c0cb4e9ba0e03758925da8cef66088.diff

LOG: [compiler-rt] Check for missing CMAKE_C_COMPILER_TARGET when using COMPILER_RT_DEFAULT_TARGET_ONLY

COMPILER_RT_DEFAULT_TARGET_ONLY is the goto workaround for building
only one of a multilib setup while still being able to autodetect the native target.
For example only building 64 bit libraries on Intel instead of 32 and 64 bit.
Which may fail without 32 bit compatibility libs installed.

As reported in https://discourse.llvm.org/t/configuring-compiler-rt-to-use-default-target-only-does-not-work/62727
this build config hasn't worked in a while.

It relies on a variable usually set during cross compliation,
though my testing shows you can set it in other scenarios too.
https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_TARGET.html

So the options you need to provide are:
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DCMAKE_C_COMPILER_TARGET="aarch64-unknown-linux-gnu"

And we should error if CMAKE_C_COMPILER_TARGET isn't set.

Reviewed By: glaubitz

Differential Revision: https://reviews.llvm.org/D147598

Added: 
    

Modified: 
    compiler-rt/cmake/Modules/CompilerRTUtils.cmake

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index eefc466a46103..f15917f7872b5 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -358,6 +358,10 @@ macro(construct_compiler_rt_default_triple)
     if(DEFINED COMPILER_RT_DEFAULT_TARGET_TRIPLE)
       message(FATAL_ERROR "COMPILER_RT_DEFAULT_TARGET_TRIPLE isn't supported when building for default target only")
     endif()
+    if ("${CMAKE_C_COMPILER_TARGET}" STREQUAL "")
+      message(FATAL_ERROR "CMAKE_C_COMPILER_TARGET must also be set when COMPILER_RT_DEFAUT_TARGET_ONLY is ON")
+    endif()
+    message(STATUS "cmake c compiler target: ${CMAKE_C_COMPILER_TARGET}")
     set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${CMAKE_C_COMPILER_TARGET})
   else()
     set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${LLVM_TARGET_TRIPLE} CACHE STRING


        


More information about the llvm-commits mailing list