-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CUDA] work around more __noinline__ conflicts with libc++ #74123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-clang Author: Artem Belevich (Artem-B) ChangesFull diff: https://github.com/llvm/llvm-project/pull/74123.diff 3 Files Affected:
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__")
|
I don't mind this, but should libc++ start using |
Yes, I've mentioned that in #73838. However, we need something to fix the issue right now while we're figuring out a better solution. In any case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can find a solution to work around this in libc++ within a reasonable timeframe, but I won't block this, since I don't really care about this part of the code base.
OK. I'll hold off on landing the patch. I believe we're not blocked on it at the moment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some review comments if we end up merging this.
FWIW I am not thrilled about using __config
here. That header is an implementation detail of libc++ and defining it and relying on it is somewhat brittle.
I'm all for having it fixed in libc++ or in CUDA SDK. Barring that, working around the specific implementation details is all I can do here. I'm open to other ideas on how this conflict can be worked around or solved in a better way. |
#73838 has landed, we can close this PR now. |
#73838