[compiler-rt] [compiler-rt] Make SANITIZER_AMDHSA an explicit opt-in CMake option. (PR #200358)
Amit Kumar Pandey via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 03:02:03 PDT 2026
https://github.com/ampandey-1995 updated https://github.com/llvm/llvm-project/pull/200358
>From 43a974262e53d578fdd496b6a3369da9041697a6 Mon Sep 17 00:00:00 2001
From: Amit Pandey <pandey.kumaramit2023 at gmail.com>
Date: Fri, 29 May 2026 14:51:50 +0530
Subject: [PATCH] [compiler-rt] Make SANITIZER_AMDHSA an explicit opt-in CMake
option
Add a dedicated `SANITIZER_AMDHSA` option for host ASan HSA interceptors
and remove the legacy mapping from SANITIZER_AMDGPU, which is unrelated
to `__AMDGPU__` device builds and should not silently enable HSA support.
This is required for host-side ASan HSA interceptors in PR #192240.
---
compiler-rt/CMakeLists.txt | 7 +++++++
compiler-rt/lib/sanitizer_common/sanitizer_platform.h | 4 ++++
2 files changed, 11 insertions(+)
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 39034fd9ba67d..12f9275f687c0 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -219,6 +219,9 @@ endif()
option(SANITIZER_ALLOW_CXXABI "Allow use of C++ ABI details in ubsan" ON)
+option(SANITIZER_AMDHSA
+ "Build host ASan with ROCm HSA API interceptors" OFF)
+
set(SANITIZER_CAN_USE_CXXABI OFF)
if (cxxabi_supported AND SANITIZER_ALLOW_CXXABI)
set(SANITIZER_CAN_USE_CXXABI ON)
@@ -549,6 +552,10 @@ elseif(COMPILER_RT_HAS_G_FLAG)
list(APPEND SANITIZER_COMMON_CFLAGS -g)
endif()
+if(SANITIZER_AMDHSA)
+ list(APPEND SANITIZER_COMMON_CFLAGS -DSANITIZER_AMDHSA=1)
+endif()
+
if(LLVM_ENABLE_MODULES)
# Sanitizers cannot be built with -fmodules. The interceptors intentionally
# don't include system headers, which is incompatible with modules.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
index 3d85959ac94a6..2fb689916d62d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
@@ -321,6 +321,10 @@
# define SANITIZER_AMDGPU 0
#endif
+#ifndef SANITIZER_AMDHSA
+# define SANITIZER_AMDHSA 0
+#endif
+
#if defined(__NVPTX__)
# define SANITIZER_NVPTX 1
#else
More information about the llvm-commits
mailing list