[llvm] [Offload] Only issue a warning for building `offload` on the GPU (PR #179240)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 2 06:28:09 PST 2026


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

Summary:
Right now this will fail because the GPU architectures will attempt to
build all of `offload` with the GPU, which obviously won't work. In the
future we will proably have some utility library that we will route
through this, but for now just silently return. This is useful because
the documentation states to use this, but it doesn't work right now.
```
-DLLVM_ENABLE_RUNTIMES=offload;openmp
-DLLVM_RUNTIME_TARGETS=default;amdgcn-amd-amdhsa
```

This PR makes this work.


>From 366272eb3be98d857daceceb76df511b2bb07ba4 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 2 Feb 2026 08:21:17 -0600
Subject: [PATCH] [Offload] Only issue a warning for building `offload` on the
 GPU

Summary:
Right now this will fail because the GPU architectures will attempt to
build all of `offload` with the GPU, which obviously won't work. In the
future we will proably have some utility library that we will route
through this, but for now just silently return. This is useful because
the documentation states to use this, but it doesn't work right now.
```
-DLLVM_ENABLE_RUNTIMES=offload;openmp
-DLLVM_RUNTIME_TARGETS=default;amdgcn-amd-amdhsa
```

This PR makes this work.
---
 offload/CMakeLists.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index 81e246d9f8892..8e8bcf34c1869 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -16,6 +16,9 @@ endif()
 if(APPLE OR WIN32 OR WASM)
   message(WARNING "libomptarget cannot be built on Windows and MacOS X!")
   return()
+elseif("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^(amdgcn|nvptx|spirv)" OR
+       "${CMAKE_CXX_COMPILER_TARGET}" MATCHES "^(amdgcn|nvptx|spirv)")
+  message(WARNING "offload cannot be built on GPU targets yet.")
 elseif(NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
   message(WARNING "Host compiler must support C++17 to build libomptarget!")
   return()



More information about the llvm-commits mailing list