[llvm] 4ec7dff - [CMake] Only set LLVM_DEFAULT_TARGET_TRIPLE to LLVM_HOST_TRIPLE when native target is enabled

Xiang Li via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 4 14:34:43 PDT 2022


Author: Xiang Li
Date: 2022-11-04T14:34:38-07:00
New Revision: 4ec7dff27d90d7abe263cfae115cc959c05f0080

URL: https://github.com/llvm/llvm-project/commit/4ec7dff27d90d7abe263cfae115cc959c05f0080
DIFF: https://github.com/llvm/llvm-project/commit/4ec7dff27d90d7abe263cfae115cc959c05f0080.diff

LOG: [CMake] Only set LLVM_DEFAULT_TARGET_TRIPLE to LLVM_HOST_TRIPLE when native target is enabled

This is for case when native target like X86 is not in LLVM_TARGETS_TO_BUILD.
Right now LLVM_DEFAULT_TARGET_TRIPLE is set to LLVM_HOST_TRIPLE even when native target is not enabled,
As a result, many lit tests will fail because default_triple is set for lit test but not enabled when build LLVM.

Reviewed By: smeenai

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

Added: 
    

Modified: 
    llvm/CMakeLists.txt
    llvm/test/Examples/OrcV2Examples/lljit-with-remote-debugging.test
    llvm/test/Examples/OrcV2Examples/lljit-with-thinlto-summaries.test

Removed: 
    


################################################################################
diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 62a3fe96cb937..aafdbbe0ef298 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -837,7 +837,10 @@ include(config-ix)
 if("${LLVM_HOST_TRIPLE}" MATCHES "^powerpc64-ibm-aix")
   string(REGEX REPLACE "^powerpc64" "powerpc" LLVM_DEFAULT_TARGET_TRIPLE_default "${LLVM_HOST_TRIPLE}")
 else()
-  set(LLVM_DEFAULT_TARGET_TRIPLE_default "${LLVM_HOST_TRIPLE}")
+  # Only set default triple when native target is enabled.
+  if (LLVM_NATIVE_TARGET)
+    set(LLVM_DEFAULT_TARGET_TRIPLE_default "${LLVM_HOST_TRIPLE}")
+  endif()
 endif()
 
 set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE_default}" CACHE STRING

diff  --git a/llvm/test/Examples/OrcV2Examples/lljit-with-remote-debugging.test b/llvm/test/Examples/OrcV2Examples/lljit-with-remote-debugging.test
index a09d72a76bef9..d34208136c3e2 100644
--- a/llvm/test/Examples/OrcV2Examples/lljit-with-remote-debugging.test
+++ b/llvm/test/Examples/OrcV2Examples/lljit-with-remote-debugging.test
@@ -1,6 +1,8 @@
 # This test makes sure that the example builds and executes as expected.
 # Instructions for debugging can be found in LLJITWithRemoteDebugging.cpp
 
+# REQUIRES: default_triple
+
 # RUN: LLJITWithRemoteDebugging %p/Inputs/argc_sub1_elf.ll | FileCheck --check-prefix=CHECK0 %s
 # CHECK0: Parsing input IR code from: {{.*}}/Inputs/argc_sub1_elf.ll
 # CHECK0: Running: main()

diff  --git a/llvm/test/Examples/OrcV2Examples/lljit-with-thinlto-summaries.test b/llvm/test/Examples/OrcV2Examples/lljit-with-thinlto-summaries.test
index f82ac41bce38d..21112b825ba5b 100644
--- a/llvm/test/Examples/OrcV2Examples/lljit-with-thinlto-summaries.test
+++ b/llvm/test/Examples/OrcV2Examples/lljit-with-thinlto-summaries.test
@@ -2,6 +2,8 @@
 # RUN: opt -module-summary %p/Inputs/foo-mod.ll -o foo-mod.bc
 # RUN: opt -module-summary %p/Inputs/bar-mod.ll -o bar-mod.bc
 
+# REQUIRES: default_triple
+
 # RUN: llvm-lto -thinlto -o main-foo-bar main-mod.bc foo-mod.bc bar-mod.bc
 
 # RUN: LLJITWithThinLTOSummaries main-foo-bar.thinlto.bc 2>&1 | FileCheck %s


        


More information about the llvm-commits mailing list