Skip to content

Commit 7b03a55

Browse files
authoredSep 15, 2023
[CMake] Remove SetTargetTriple (#66464)
This module is only used in two places and its logic can be inlined and simplified.
1 parent e9e3868 commit 7b03a55

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed
 

‎llvm/CMakeLists.txt

+7-4
Original file line numberDiff line numberDiff line change
@@ -875,16 +875,19 @@ include(config-ix)
875875
# invocation time. Except on 64-bit AIX, where the system toolchain
876876
# expect 32-bit objects by default.
877877
if("${LLVM_HOST_TRIPLE}" MATCHES "^powerpc64-ibm-aix")
878-
string(REGEX REPLACE "^powerpc64" "powerpc" LLVM_DEFAULT_TARGET_TRIPLE_default "${LLVM_HOST_TRIPLE}")
878+
string(REGEX REPLACE "^powerpc64" "powerpc" LLVM_DEFAULT_TARGET_TRIPLE_DEFAULT "${LLVM_HOST_TRIPLE}")
879879
else()
880880
# Only set default triple when native target is enabled.
881881
if (LLVM_NATIVE_TARGET)
882-
set(LLVM_DEFAULT_TARGET_TRIPLE_default "${LLVM_HOST_TRIPLE}")
882+
set(LLVM_DEFAULT_TARGET_TRIPLE_DEFAULT "${LLVM_HOST_TRIPLE}")
883883
endif()
884884
endif()
885885

886-
include(SetTargetTriple)
887-
set_llvm_target_triple()
886+
set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE_DEFAULT}" CACHE STRING
887+
"Default target for which LLVM will generate code." )
888+
message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
889+
890+
set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
888891

889892
if(WIN32 OR CYGWIN)
890893
if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)

‎llvm/cmake/config-ix.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ get_host_triple(LLVM_INFERRED_HOST_TRIPLE)
461461

462462
set(LLVM_HOST_TRIPLE "${LLVM_INFERRED_HOST_TRIPLE}" CACHE STRING
463463
"Host on which LLVM binaries will run")
464+
message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")
464465

465466
# Determine the native architecture.
466467
string(TOLOWER "${LLVM_TARGET_ARCH}" LLVM_NATIVE_ARCH)

‎llvm/cmake/modules/SetTargetTriple.cmake

-13
This file was deleted.

‎runtimes/CMakeLists.txt

+8-4
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,15 @@ find_package(Python3 REQUIRED COMPONENTS Interpreter)
160160
# Host triple is used by tests to check if they are running natively.
161161
include(GetHostTriple)
162162
get_host_triple(LLVM_HOST_TRIPLE)
163+
message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")
164+
165+
# TODO: We shouldn't be using LLVM_DEFAULT_TARGET_TRIPLE for runtimes since we
166+
# aren't generating code, LLVM_TARGET_TRIPLE is a better fit.
163167
set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING
164-
"Default target for which the runtimes will be built.")
168+
"Default target for which the runtimes will be built.")
169+
message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
170+
171+
set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
165172

166173
option(LLVM_INCLUDE_TESTS "Generate build targets for the runtimes unit tests." ON)
167174
option(LLVM_INCLUDE_DOCS "Generate build targets for the runtimes documentation." ON)
@@ -175,9 +182,6 @@ endif()
175182
# This can be used to detect whether we're in the runtimes build.
176183
set(LLVM_RUNTIMES_BUILD ON)
177184

178-
include(SetTargetTriple)
179-
set_llvm_target_triple()
180-
181185
foreach(entry ${runtimes})
182186
get_filename_component(projName ${entry} NAME)
183187

0 commit comments

Comments
 (0)
Please sign in to comment.