[llvm] [Offload] Prevent by default passing CMAKE_CXX_FLAGS to GPU build (PR #160881)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 26 06:10:38 PDT 2025


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/160881

Summary:
People will use this to pass incompatible flags. The default behavior is
to inherit the top level options for all the runtimes. Some of these
aren't compatible. The cache file should put users in a most-useful
state, and this also serves as documentation. Just override it so users
need to explicit if they want a non-standard flag on their GPU build.


>From 113d6eb65d04d1bf448e39536d3f1eb119525de9 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Fri, 26 Sep 2025 08:08:24 -0500
Subject: [PATCH] [Offload] Prevent by default passing CMAKE_CXX_FLAGS to GPU
 build

Summary:
People will use this to pass incompatible flags. The default behavior is
to inherit the top level options for all the runtimes. Some of these
aren't compatible. The cache file should put users in a most-useful
state, and this also serves as documentation. Just override it so users
need to explicit if they want a non-standard flag on their GPU build.
---
 offload/cmake/caches/Offload.cmake | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/offload/cmake/caches/Offload.cmake b/offload/cmake/caches/Offload.cmake
index 3747a1d3eb299..09262f8ce6d1e 100644
--- a/offload/cmake/caches/Offload.cmake
+++ b/offload/cmake/caches/Offload.cmake
@@ -7,3 +7,9 @@ set(RUNTIMES_nvptx64-nvidia-cuda_CACHE_FILES "${CMAKE_SOURCE_DIR}/../libcxx/cmak
 set(RUNTIMES_amdgcn-amd-amdhsa_CACHE_FILES "${CMAKE_SOURCE_DIR}/../libcxx/cmake/caches/AMDGPU.cmake" CACHE STRING "")
 set(RUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES "compiler-rt;libc;openmp;libcxx;libcxxabi" CACHE STRING "")
 set(RUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES "compiler-rt;libc;openmp;libcxx;libcxxabi" CACHE STRING "")
+
+# Prevent people mistakenly sending CPU flags to the GPU build.
+set(RUNTIMES_nvptx64-nvidia-cuda_CMAKE_CXX_FLAGS "" CACHE STRING "")
+set(RUNTIMES_amdgcn-amd-amdhsa_CMAKE_CXX_FLAGS "" CACHE STRING "")
+set(RUNTIMES_nvptx64-nvidia-cuda_CMAKE_C_FLAGS "" CACHE STRING "")
+set(RUNTIMES_amdgcn-amd-amdhsa_CMAKE_C_FLAGS "" CACHE STRING "")



More information about the llvm-commits mailing list