Module: Mesa
Branch: main
Commit: e74e82ea77c34b6134838bffb4085e0a5a77a4fe
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e74e82ea77c34b6134838bffb4085e0a5a77a4fe

Author: Thomas Debesse <[email protected]>
Date:   Tue Oct 25 07:18:16 2022 +0200

gallium/clover: pass -opaque-pointers to Clang on LLVM 15 and 16

This does the exact opposite of 06e96074 from !16129.

Before LLVM commit 702d5de4 opaque pointers were supported but not enabled
by default when building LLVM. They were made default in commit 702d5de4.
LLVM commit d69e9f9d introduced -opaque-pointers/-no-opaque-pointers cc1
options to enable or disable them whatever the LLVM default is.

Those two commits follow llvmorg-15-init and precede llvmorg-15.0.0-rc1 tags.

Since LLVM commit d785a8ea, the CLANG_ENABLE_OPAQUE_POINTERS build option of
LLVM is removed, meaning there is no way to build LLVM with opaque pointers
enabled by default.
It was said at the time it was still possible to explicitly disable opaque
pointers via cc1 -no-opaque-pointers option, but it is known a later commit
broke backward compatibility provided by -no-opaque-pointers as verified with
arbitrary commit d7d586e5, so there is no way to use opaque pointers starting
with LLVM 16.

Those two commits follow llvmorg-16-init and precede llvmorg-16.0.0-rc1 tags.

Since Mesa commit 977dbfc9 opaque pointers are properly implemented in Clover
and used.

If we don't pass -opaque-pointers to Clang on LLVM versions supporting opaque
pointers but disabling them by default, there will be an API mismatch between
Mesa and LLVM and Clover will not work.

Signed-off-by: Thomas Debesse <[email protected]>
Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19290>

---

 src/gallium/frontends/clover/llvm/invocation.cpp | 27 ++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/gallium/frontends/clover/llvm/invocation.cpp 
b/src/gallium/frontends/clover/llvm/invocation.cpp
index 1e5f3266c26..7a50fea3323 100644
--- a/src/gallium/frontends/clover/llvm/invocation.cpp
+++ b/src/gallium/frontends/clover/llvm/invocation.cpp
@@ -226,6 +226,33 @@ namespace {
       // class to recognize it as an OpenCL source file.
 #if LLVM_VERSION_MAJOR >= 12
       std::vector<const char *> copts;
+#if LLVM_VERSION_MAJOR == 15 || LLVM_VERSION_MAJOR == 16
+      // Before LLVM commit 702d5de4 opaque pointers were supported but not 
enabled
+      // by default when building LLVM. They were made default in commit 
702d5de4.
+      // LLVM commit d69e9f9d introduced -opaque-pointers/-no-opaque-pointers 
cc1
+      // options to enable or disable them whatever the LLVM default is.
+
+      // Those two commits follow llvmorg-15-init and precede 
llvmorg-15.0.0-rc1 tags.
+
+      // Since LLVM commit d785a8ea, the CLANG_ENABLE_OPAQUE_POINTERS build 
option of
+      // LLVM is removed, meaning there is no way to build LLVM with opaque 
pointers
+      // enabled by default.
+      // It was said at the time it was still possible to explicitly disable 
opaque
+      // pointers via cc1 -no-opaque-pointers option, but it is known a later 
commit
+      // broke backward compatibility provided by -no-opaque-pointers as 
verified with
+      // arbitrary commit d7d586e5, so there is no way to use opaque pointers 
starting
+      // with LLVM 16.
+
+      // Those two commits follow llvmorg-16-init and precede 
llvmorg-16.0.0-rc1 tags.
+
+      // Since Mesa commit 977dbfc9 opaque pointers are properly implemented 
in Clover
+      // and used.
+
+      // If we don't pass -opaque-pointers to Clang on LLVM versions 
supporting opaque
+      // pointers but disabling them by default, there will be an API mismatch 
between
+      // Mesa and LLVM and Clover will not work.
+      copts.push_back("-opaque-pointers");
+#endif
       for (auto &opt : opts) {
          if (opt == "-cl-denorms-are-zero")
             copts.push_back("-fdenormal-fp-math=positive-zero");

Reply via email to