[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 1 12:13:51 PST 2023
https://github.com/Artem-B updated https://github.com/llvm/llvm-project/pull/74123
>From 71e24fc704c82c11162313613691d09b9a653bd5 Mon Sep 17 00:00:00 2001
From: Artem Belevich <tra at google.com>
Date: Fri, 1 Dec 2023 10:37:08 -0800
Subject: [PATCH 1/2] [CUDA] work around more __noinline__ conflicts with
libc++
https://github.com/llvm/llvm-project/pull/73838
---
clang/lib/Headers/CMakeLists.txt | 2 ++
clang/lib/Headers/cuda_wrappers/__config | 10 ++++++++++
clang/lib/Headers/cuda_wrappers/string | 10 ++++++++++
3 files changed, 22 insertions(+)
create mode 100644 clang/lib/Headers/cuda_wrappers/__config
create mode 100644 clang/lib/Headers/cuda_wrappers/string
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index fdd54c05eedf825..f562c354327f2fb 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -283,10 +283,12 @@ set(files
)
set(cuda_wrapper_files
+ cuda_wrappers/__config
cuda_wrappers/algorithm
cuda_wrappers/cmath
cuda_wrappers/complex
cuda_wrappers/new
+ cuda_wrappers/string
)
set(cuda_wrapper_bits_files
diff --git a/clang/lib/Headers/cuda_wrappers/__config b/clang/lib/Headers/cuda_wrappers/__config
new file mode 100644
index 000000000000000..04038b0fa3437ee
--- /dev/null
+++ b/clang/lib/Headers/cuda_wrappers/__config
@@ -0,0 +1,10 @@
+// CUDA headers define __noinline__ which interferes with libc++'s use of
+// `__attribute((__noinline__))`. In order to avoid compilation error,
+// temporarily unset __noinline__ when we include affected libstdc++ header.
+
+#pragma push_macro("__noinline__")
+#undef __noinline__
+#define __noinline__ __noinline__
+#include_next "__config"
+
+#pragma pop_macro("__noinline__")
diff --git a/clang/lib/Headers/cuda_wrappers/string b/clang/lib/Headers/cuda_wrappers/string
new file mode 100644
index 000000000000000..d612710393623b5
--- /dev/null
+++ b/clang/lib/Headers/cuda_wrappers/string
@@ -0,0 +1,10 @@
+// CUDA headers define __noinline__ which interferes with libc++'s use of
+// `__attribute((__noinline__))`. In order to avoid compilation error,
+// temporarily unset __noinline__ when we include affected libstdc++ header.
+
+#pragma push_macro("__noinline__")
+#undef __noinline__
+#define __noinline__ __noinline__
+#include_next "string"
+
+#pragma pop_macro("__noinline__")
>From 0f67fcd9bc1da6149dc2bde9b3524d219c957112 Mon Sep 17 00:00:00 2001
From: Artem Belevich <tra at google.com>
Date: Fri, 1 Dec 2023 12:12:46 -0800
Subject: [PATCH 2/2] libstdc++ -> libc++ in the comments.
---
clang/lib/Headers/cuda_wrappers/__config | 2 +-
clang/lib/Headers/cuda_wrappers/string | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Headers/cuda_wrappers/__config b/clang/lib/Headers/cuda_wrappers/__config
index 04038b0fa3437ee..92e9a27eec2d8e5 100644
--- a/clang/lib/Headers/cuda_wrappers/__config
+++ b/clang/lib/Headers/cuda_wrappers/__config
@@ -1,6 +1,6 @@
// CUDA headers define __noinline__ which interferes with libc++'s use of
// `__attribute((__noinline__))`. In order to avoid compilation error,
-// temporarily unset __noinline__ when we include affected libstdc++ header.
+// temporarily unset __noinline__ when we include affected libc++ header.
#pragma push_macro("__noinline__")
#undef __noinline__
diff --git a/clang/lib/Headers/cuda_wrappers/string b/clang/lib/Headers/cuda_wrappers/string
index d612710393623b5..1a969fd065c21a7 100644
--- a/clang/lib/Headers/cuda_wrappers/string
+++ b/clang/lib/Headers/cuda_wrappers/string
@@ -1,6 +1,6 @@
// CUDA headers define __noinline__ which interferes with libc++'s use of
// `__attribute((__noinline__))`. In order to avoid compilation error,
-// temporarily unset __noinline__ when we include affected libstdc++ header.
+// temporarily unset __noinline__ when we include affected libc++ header.
#pragma push_macro("__noinline__")
#undef __noinline__
More information about the cfe-commits
mailing list