Skip to content

Commit 75a2559

Browse files
committed
Runtimes: specify whether to leverage a target triple for default builds
The default builds for runtimes currently set `CMAKE_C_COMPILER_TARGET` and `CMAKE_CXX_COMPILER_TARGET`, which causes all compilation commands to have a matching `--target` argument -- this can cause issues when building for Apple platforms, where that interferes with the detection of the SDKs and subsequent builds. rdar://146304200
1 parent 512ef4c commit 75a2559

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

llvm/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,11 @@ message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
10041004

10051005
set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
10061006

1007+
set(LLVM_USE_TARGET_TRIPLE_WHEN_BUILDING_DEFAULT_TARGET_FOR_RUNTIMES
1008+
ON CACHE BOOL
1009+
"Disable this if the underlying runtime build detects and builds for multiple platform
1010+
at once (like it's the case for compiler-rt on Apple platforms)")
1011+
10071012
if(WIN32 OR CYGWIN)
10081013
if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)
10091014
set(LLVM_ENABLE_PLUGINS_default ON)

llvm/runtimes/CMakeLists.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,22 @@ macro(set_enable_per_target_runtime_dir)
8282
endif()
8383
endmacro()
8484

85+
macro(set_target_triple_for_default_runtime_build)
86+
if(NOT DEFINED LLVM_USE_TARGET_TRIPLE_WHEN_BUILDING_DEFAULT_TARGET_FOR_RUNTIMES
87+
OR "${LLVM_USE_TARGET_TRIPLE_WHEN_BUILDING_DEFAULT_TARGET_FOR_RUNTIMES}")
88+
list(APPEND TARGET_TRIPLE_ARGUMENTS TARGET_TRIPLE ${LLVM_TARGET_TRIPLE})
89+
else()
90+
list(APPEND TARGET_TRIPLE_ARGUMENTS)
91+
endif()
92+
endmacro()
93+
8594
function(builtin_default_target compiler_rt_path)
8695
cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
8796

8897
set_enable_per_target_runtime_dir()
8998

99+
set_target_triple_for_default_runtime_build()
100+
90101
llvm_ExternalProject_Add(builtins
91102
${compiler_rt_path}/lib/builtins
92103
DEPENDS ${ARG_DEPENDS}
@@ -103,7 +114,7 @@ function(builtin_default_target compiler_rt_path)
103114
DARWIN
104115
SANITIZER
105116
USE_TOOLCHAIN
106-
TARGET_TRIPLE ${LLVM_TARGET_TRIPLE}
117+
${TARGET_TRIPLE_ARGUMENTS}
107118
FOLDER "Compiler-RT"
108119
${EXTRA_ARGS})
109120
endfunction()
@@ -258,6 +269,8 @@ function(runtime_default_target)
258269

259270
set_enable_per_target_runtime_dir()
260271

272+
set_target_triple_for_default_runtime_build()
273+
261274
llvm_ExternalProject_Add(runtimes
262275
${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
263276
DEPENDS ${ARG_DEPENDS}
@@ -287,7 +300,7 @@ function(runtime_default_target)
287300
${SUB_CHECK_TARGETS}
288301
${SUB_INSTALL_TARGETS}
289302
USE_TOOLCHAIN
290-
TARGET_TRIPLE ${LLVM_TARGET_TRIPLE}
303+
${TARGET_TRIPLE_ARGUMENTS}
291304
FOLDER "Runtimes"
292305
${EXTRA_ARGS} ${ARG_EXTRA_ARGS})
293306
endfunction()

0 commit comments

Comments
 (0)