[llvm] [CMake] Remove SetTargetTriple (PR #66464)
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 14 23:34:47 PDT 2023
https://github.com/petrhosek created https://github.com/llvm/llvm-project/pull/66464
This module is only used in two places and its logic can be inlined and simplified.
>From 0f3e2e50a762ad711f5d4c6ac38b1e121e74ec7d Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Fri, 15 Sep 2023 06:31:53 +0000
Subject: [PATCH] [CMake] Remove SetTargetTriple
This module is only used in two places and its logic can be inlined
and simplified.
---
llvm/CMakeLists.txt | 11 +++++++----
llvm/cmake/config-ix.cmake | 1 +
llvm/cmake/modules/SetTargetTriple.cmake | 13 -------------
runtimes/CMakeLists.txt | 12 ++++++++----
4 files changed, 16 insertions(+), 21 deletions(-)
delete mode 100644 llvm/cmake/modules/SetTargetTriple.cmake
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 1103172d8bc6fef..fa39c7554de1f61 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -875,16 +875,19 @@ include(config-ix)
# invocation time. Except on 64-bit AIX, where the system toolchain
# expect 32-bit objects by default.
if("${LLVM_HOST_TRIPLE}" MATCHES "^powerpc64-ibm-aix")
- string(REGEX REPLACE "^powerpc64" "powerpc" LLVM_DEFAULT_TARGET_TRIPLE_default "${LLVM_HOST_TRIPLE}")
+ string(REGEX REPLACE "^powerpc64" "powerpc" LLVM_DEFAULT_TARGET_TRIPLE_DEFAULT "${LLVM_HOST_TRIPLE}")
else()
# Only set default triple when native target is enabled.
if (LLVM_NATIVE_TARGET)
- set(LLVM_DEFAULT_TARGET_TRIPLE_default "${LLVM_HOST_TRIPLE}")
+ set(LLVM_DEFAULT_TARGET_TRIPLE_DEFAULT "${LLVM_HOST_TRIPLE}")
endif()
endif()
-include(SetTargetTriple)
-set_llvm_target_triple()
+set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE_DEFAULT}" CACHE STRING
+ "Default target for which LLVM will generate code." )
+message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
+
+set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
if(WIN32 OR CYGWIN)
if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index f63c3f1a351f4d6..a01e17de8677aa7 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -461,6 +461,7 @@ get_host_triple(LLVM_INFERRED_HOST_TRIPLE)
set(LLVM_HOST_TRIPLE "${LLVM_INFERRED_HOST_TRIPLE}" CACHE STRING
"Host on which LLVM binaries will run")
+message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")
# Determine the native architecture.
string(TOLOWER "${LLVM_TARGET_ARCH}" LLVM_NATIVE_ARCH)
diff --git a/llvm/cmake/modules/SetTargetTriple.cmake b/llvm/cmake/modules/SetTargetTriple.cmake
deleted file mode 100644
index ed0a53ca3ec9631..000000000000000
--- a/llvm/cmake/modules/SetTargetTriple.cmake
+++ /dev/null
@@ -1,13 +0,0 @@
-macro(set_llvm_target_triple)
- set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE_default}" CACHE STRING
- "Default target for which LLVM will generate code." )
- if (TARGET_TRIPLE)
- message(WARNING "TARGET_TRIPLE is deprecated and will be removed in a future release. "
- "Please use LLVM_DEFAULT_TARGET_TRIPLE instead.")
- set(LLVM_TARGET_TRIPLE "${TARGET_TRIPLE}")
- else()
- set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
- endif()
- message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")
- message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
-endmacro()
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 599529852688f25..58af4c8b131b0bd 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -160,8 +160,15 @@ find_package(Python3 REQUIRED COMPONENTS Interpreter)
# Host triple is used by tests to check if they are running natively.
include(GetHostTriple)
get_host_triple(LLVM_HOST_TRIPLE)
+message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")
+
+# TODO: We shouldn't be using LLVM_DEFAULT_TARGET_TRIPLE for runtimes since we
+# aren't generating code, LLVM_TARGET_TRIPLE is a better fit.
set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING
- "Default target for which the runtimes will be built.")
+ "Default target for which the runtimes will be built.")
+message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
+
+set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
option(LLVM_INCLUDE_TESTS "Generate build targets for the runtimes unit tests." ON)
option(LLVM_INCLUDE_DOCS "Generate build targets for the runtimes documentation." ON)
@@ -175,9 +182,6 @@ endif()
# This can be used to detect whether we're in the runtimes build.
set(LLVM_RUNTIMES_BUILD ON)
-include(SetTargetTriple)
-set_llvm_target_triple()
-
foreach(entry ${runtimes})
get_filename_component(projName ${entry} NAME)
More information about the llvm-commits
mailing list