clover: fix compilation with clang + llvm 12.
authorDave Airlie <airlied@redhat.com>
Wed, 11 Nov 2020 01:33:33 +0000 (11:33 +1000)
committerMarge Bot <eric+marge@anholt.net>
Tue, 10 Aug 2021 21:38:39 +0000 (21:38 +0000)
clang in llvm 12 no longer accepts "-cl-denorms-are-zero" as a cc1
options which is how this code uses it.

For now just pick the correct cc1 equivalent.

This fixes a crash with llvm master and CL conversions tests

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12286>

src/gallium/frontends/clover/llvm/invocation.cpp

index aada225..c3f54c1 100644 (file)
@@ -224,8 +224,18 @@ namespace {
       // Parse the compiler options.  A file name should be present at the end
       // and must have the .cl extension in order for the CompilerInvocation
       // class to recognize it as an OpenCL source file.
+#if LLVM_VERSION_MAJOR >= 12
+      std::vector<const char *> copts;
+      for (auto &opt : opts) {
+         if (opt == "-cl-denorms-are-zero")
+            copts.push_back("-fdenormal-fp-math=positive-zero");
+         else
+            copts.push_back(opt.c_str());
+      }
+#else
       const std::vector<const char *> copts =
          map(std::mem_fn(&std::string::c_str), opts);
+#endif
 
       const target &target = ir_target;
       const cl_version device_clc_version = dev.device_clc_version();