[llvm] [LLVM][NFC] Ignore including the GNUInstallDirs on the GPU (PR #83910)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 15:38:44 PST 2024


https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/83910

>From 583cd73091a40ae2616f86fe308863c3647b8d12 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 4 Mar 2024 15:20:12 -0600
Subject: [PATCH 1/2] [LLVM][NFC] Ignore including the GNUInstallDirs on the
 GPU

Summary:
I've begun treating GPU runtimes builds as cross-compiling with the LLVM
infrastructure. However, we include a lot of random stuff that the GPU
build isn't prepared to handle. This currently emits a warning, and
while it's not striclty necessary, is annoying. This patch suppresses it
by not including the standard GNU install directory resources when used
from the GPU.
---
 llvm/cmake/modules/AddLLVM.cmake | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 828de4bd9940d6..07cdd972b151ef 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1,4 +1,8 @@
-include(GNUInstallDirs)
+if(NOT ("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn" OR
+        "${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx64"))
+  include(GNUInstallDirs)
+endif()
+
 include(LLVMDistributionSupport)
 include(LLVMProcessSources)
 include(LLVM-Config)

>From 5140a9d3d49fcda80a8060b0e62a65d1d422ced7 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 4 Mar 2024 17:38:32 -0600
Subject: [PATCH 2/2] Make more generic

---
 llvm/cmake/modules/AddLLVM.cmake           | 3 +--
 llvm/cmake/modules/HandleLLVMOptions.cmake | 3 +--
 runtimes/CMakeLists.txt                    | 6 ++++++
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 07cdd972b151ef..e18ec23fc76f18 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1,5 +1,4 @@
-if(NOT ("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn" OR
-        "${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx64"))
+if(NOT LLVM_RUNTIMES_GPU_BUILD)
   include(GNUInstallDirs)
 endif()
 
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 08ff49ded57a14..eca2962cf82071 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -122,8 +122,7 @@ endif()
 
 # If we are targeting a GPU architecture in a runtimes build we want to ignore
 # all the standard flag handling.
-if("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn" OR
-   "${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx64")
+if(LLVM_RUNTIMES_GPU_BUILD)
   return()
 endif()
 
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 634ffe710b06b8..29b47b862c219c 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -151,6 +151,12 @@ endif()
 # Avoid checking whether the compiler is working.
 set(LLVM_COMPILER_CHECKED ON)
 
+# This can be used to detect whether we're targeting a GPU architecture.
+if("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn" OR
+   "${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx64")
+  set(LLVM_RUNTIMES_GPU_BUILD ON)
+endif()
+
 # Handle common options used by all runtimes.
 include(AddLLVM)
 include(HandleLLVMOptions)



More information about the llvm-commits mailing list