1
0
forked from rpms/mesa

Fix build due a clang bug on nested macros

Prior to GCC14, the `__arm_streaming` macro was not spelled as an attribute
using the CXX11 syntax (e.g: [[arm::streaming]]) and so clang expanded that
macro macro.

But since GCC14, it's spelled as `[[arm::streaming]]` which makes clang to
try expanding the attribute again and generating an invalid preprocessing
token due the nested macro usage:

/usr/include/clang/Basic/AttrTokenKinds.inc:9:1: error: pasting "kw_" and "[" does not give a valid preprocessing token
    9 | KEYWORD_ATTRIBUTE(__arm_streaming)

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2024-01-19 14:20:19 +01:00
parent 3f054a8ee8
commit 0e9100b78f
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
2 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,96 @@
From bc99ffc770879ff8633128f74dad3159ce3206d3 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Fri, 19 Jan 2024 12:21:07 +0100
Subject: [PATCH] gallium: Undef __arm_streaming macro to workaround clang
nested expansion
Prior to GCC14, the `__arm_streaming` macro was not spelled as an attribute
using the CXX11 syntax (e.g: [[arm::streaming]]) and so clang expanded that
macro macro.
But since GCC14, it's spelled as `[[arm::streaming]]` which makes clang to
try expanding the attribute again and generating an invalid preprocessing
token due the nested macro usage:
/usr/include/clang/Basic/AttrTokenKinds.inc:9:1: error: pasting "kw_" and "[" does not give a valid preprocessing token
9 | KEYWORD_ATTRIBUTE(__arm_streaming)
Until this is fixed in clang, let's undefine the __arm_streaming macro.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
src/compiler/clc/clc_helpers.cpp | 2 ++
src/gallium/frontends/clover/llvm/codegen/bitcode.cpp | 2 ++
src/gallium/frontends/clover/llvm/codegen/common.cpp | 2 ++
src/gallium/frontends/clover/llvm/codegen/native.cpp | 2 ++
src/gallium/frontends/clover/llvm/invocation.cpp | 2 ++
5 files changed, 10 insertions(+)
diff --git a/src/compiler/clc/clc_helpers.cpp b/src/compiler/clc/clc_helpers.cpp
index 15af4b44c6ce..f8cf4afe74a7 100644
--- a/src/compiler/clc/clc_helpers.cpp
+++ b/src/compiler/clc/clc_helpers.cpp
@@ -23,6 +23,8 @@
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
+#undef __arm_streaming
+
#include <filesystem>
#include <sstream>
#include <mutex>
diff --git a/src/gallium/frontends/clover/llvm/codegen/bitcode.cpp b/src/gallium/frontends/clover/llvm/codegen/bitcode.cpp
index 568bdd993f59..00e10672f973 100644
--- a/src/gallium/frontends/clover/llvm/codegen/bitcode.cpp
+++ b/src/gallium/frontends/clover/llvm/codegen/bitcode.cpp
@@ -31,6 +31,8 @@
/// after linking against other bitcode object files.
///
+#undef __arm_streaming
+
#include <llvm/Support/Allocator.h>
#include "llvm/codegen.hpp"
diff --git a/src/gallium/frontends/clover/llvm/codegen/common.cpp b/src/gallium/frontends/clover/llvm/codegen/common.cpp
index fe5fc768bcd5..f659b35283b5 100644
--- a/src/gallium/frontends/clover/llvm/codegen/common.cpp
+++ b/src/gallium/frontends/clover/llvm/codegen/common.cpp
@@ -30,6 +30,8 @@
/// understood by pipe drivers.
///
+#undef __arm_streaming
+
#include <llvm/IR/Type.h>
#include <llvm/Support/Allocator.h>
diff --git a/src/gallium/frontends/clover/llvm/codegen/native.cpp b/src/gallium/frontends/clover/llvm/codegen/native.cpp
index 72046c8a1881..e115e06cbbb6 100644
--- a/src/gallium/frontends/clover/llvm/codegen/native.cpp
+++ b/src/gallium/frontends/clover/llvm/codegen/native.cpp
@@ -27,6 +27,8 @@
/// executable code as an ELF object file.
///
+#undef __arm_streaming
+
#include <llvm/Target/TargetMachine.h>
#include <llvm/Transforms/Utils/Cloning.h>
diff --git a/src/gallium/frontends/clover/llvm/invocation.cpp b/src/gallium/frontends/clover/llvm/invocation.cpp
index 6ab32befbcd3..287af9891015 100644
--- a/src/gallium/frontends/clover/llvm/invocation.cpp
+++ b/src/gallium/frontends/clover/llvm/invocation.cpp
@@ -24,6 +24,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+#undef __arm_streaming
+
#include <llvm/IR/DiagnosticPrinter.h>
#include <llvm/IR/DiagnosticInfo.h>
#include <llvm/IR/LLVMContext.h>
--
2.43.0

View File

@ -74,6 +74,8 @@ Source0: https://archive.mesa3d.org/mesa-%{ver}.tar.xz
Source1: Mesa-MLAA-License-Clarification-Email.txt
Patch10: gnome-shell-glthread-disable.patch
# Workaround for llvm/clang bug: https://github.com/llvm/llvm-project/issues/78691
Patch11: gallium-Undef-__arm_streaming-macro-to-workaround-cl.patch
BuildRequires: meson >= 1.2.0
BuildRequires: gcc