[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
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 Date: Fri, 1 Dec 2023 10:37:08 -0800 Subject: [PATCH 1/3] [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 000..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 000..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 Date: Fri, 1 Dec 2023 12:12:46 -0800 Subject: [PATCH 2/3] 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__ >From 3e5fee705f1203cbaef0d347492d9fd5f433f4c9 Mon Sep 17 00:00:00 2001 From: Artem Belevich Date: Fri, 1 Dec 2023 14:25:42 -0800 Subject: [PATCH 3/3] Use `#include <...>` --- 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 92e9a27eec2d8e5..c9966bdc7ef9bff 100644 --- a/clang/lib/Headers/cuda_wrappers/__config +++ b/clang/lib/Headers/cuda_wrappers/__config @@ -5,6 +5,6 @@ #pragma push_macro("__noinline__") #undef __noinline__ #define __noinline__ __noinline__ -#include_next "__config" +#include_next <__config> #pragma pop_macro("__noinline__") diff --git a/clang/lib/Headers/cuda_wrappers/string b/clang/lib/Headers/cuda_wrappers/string index 1a969fd065c21a7..b63647055f01ce4 100644 --- a/clang/lib/Headers/cuda_wrappers/string +++ b/clang/lib/Headers/cuda_wrappers/string @@ -5,6 +5,6 @@ #pragma push_macro("__noinline__") #undef __noinline__ #define __noinline__
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
Artem-B wrote: > 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. https://github.com/llvm/llvm-project/pull/74123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
@@ -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 libc++ header. + +#pragma push_macro("__noinline__") +#undef __noinline__ +#define __noinline__ __noinline__ +#include_next "string" ldionne wrote: ```suggestion #include_next ``` https://github.com/llvm/llvm-project/pull/74123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
https://github.com/ldionne commented: 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. https://github.com/llvm/llvm-project/pull/74123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
@@ -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 libc++ header. + +#pragma push_macro("__noinline__") +#undef __noinline__ +#define __noinline__ __noinline__ +#include_next "__config" ldionne wrote: ```suggestion #include_next <__config> ``` https://github.com/llvm/llvm-project/pull/74123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
https://github.com/ldionne edited https://github.com/llvm/llvm-project/pull/74123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
Artem-B wrote: > I think we can find a solution to work around this in libc++ within a > reasonable timeframe OK. I'll hold off on landing the patch. I believe we're not blocked on it at the moment. https://github.com/llvm/llvm-project/pull/74123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
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 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 000..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 000..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 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__ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/74123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
@@ -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. philnik777 wrote: ```suggestion // temporarily unset __noinline__ when we include affected libc++ header. ``` https://github.com/llvm/llvm-project/pull/74123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
@@ -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. philnik777 wrote: ```suggestion // temporarily unset __noinline__ when we include affected libc++ header. ``` https://github.com/llvm/llvm-project/pull/74123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
Artem-B wrote: Yes, I've mentioned that in https://github.com/llvm/llvm-project/pull/73838. However, we need something to fix the issue right now while we're figuring out a better solution. In any case `__noinline__` is unlikely to be widely used, so the wrappers may be manageable, at least for the short-to-medium term. https://github.com/llvm/llvm-project/pull/74123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
gribozavr wrote: I don't mind this, but should libc++ start using `_LIBCPP_NOINLINE`, we would be playing a catch-up game here. https://github.com/llvm/llvm-project/pull/74123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Artem Belevich (Artem-B) Changes https://github.com/llvm/llvm-project/pull/73838 --- Full diff: https://github.com/llvm/llvm-project/pull/74123.diff 3 Files Affected: - (modified) clang/lib/Headers/CMakeLists.txt (+2) - (added) clang/lib/Headers/cuda_wrappers/__config (+10) - (added) clang/lib/Headers/cuda_wrappers/string (+10) ``diff 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 000..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 000..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__") `` https://github.com/llvm/llvm-project/pull/74123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)
https://github.com/Artem-B created https://github.com/llvm/llvm-project/pull/74123 https://github.com/llvm/llvm-project/pull/73838 >From 71e24fc704c82c11162313613691d09b9a653bd5 Mon Sep 17 00:00:00 2001 From: Artem Belevich Date: Fri, 1 Dec 2023 10:37:08 -0800 Subject: [PATCH] [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 000..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 000..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__") ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits