Skip to content

Commit 3c06f28

Browse files
committed
llvm17: fix build with gcc14 on ARM
1 parent 53af683 commit 3c06f28

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
Source: https://src.fedoraproject.org/rpms/clang17/blob/f42/f/0001-Clang-Fix-build-with-GCC-14-on-ARM.patch
2+
3+
From bd2e848f15c0f25231126eb10cb0ab350717dfc0 Mon Sep 17 00:00:00 2001
4+
From: Nikita Popov <npopov@redhat.com>
5+
Date: Fri, 19 Jan 2024 12:09:13 +0100
6+
Subject: [PATCH] [Clang] Fix build with GCC 14 on ARM
7+
8+
GCC 14 defines `__arm_streaming` as a macro expanding to
9+
`[[arm::streaming]]`. Due to the nested macro use, this gets
10+
expanded prior to concatenation.
11+
12+
It doesn't look like C++ has a really clean way to prevent
13+
macro expansion. The best I have found is to use `EMPTY ## X` where
14+
`EMPTY` is an empty macro argument, so this is the hack I'm
15+
implementing here.
16+
17+
Fixes https://github.com/llvm/llvm-project/issues/78691.
18+
---
19+
clang/include/clang/Basic/TokenKinds.def | 3 ++-
20+
clang/include/clang/Basic/TokenKinds.h | 2 +-
21+
clang/utils/TableGen/ClangAttrEmitter.cpp | 2 +-
22+
3 files changed, 4 insertions(+), 3 deletions(-)
23+
24+
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
25+
index ef0dad0f2dcd..3add13c079f3 100644
26+
--- a/clang/include/clang/Basic/TokenKinds.def
27+
+++ b/clang/include/clang/Basic/TokenKinds.def
28+
@@ -752,8 +752,9 @@ KEYWORD(__builtin_available , KEYALL)
29+
KEYWORD(__builtin_sycl_unique_stable_name, KEYSYCL)
30+
31+
// Keywords defined by Attr.td.
32+
+// The "EMPTY ## X" is used to prevent early macro-expansion of the keyword.
33+
#ifndef KEYWORD_ATTRIBUTE
34+
-#define KEYWORD_ATTRIBUTE(X) KEYWORD(X, KEYALL)
35+
+#define KEYWORD_ATTRIBUTE(X, EMPTY) KEYWORD(EMPTY ## X, KEYALL)
36+
#endif
37+
#include "clang/Basic/AttrTokenKinds.inc"
38+
39+
diff --git a/clang/include/clang/Basic/TokenKinds.h b/clang/include/clang/Basic/TokenKinds.h
40+
index e4857405bc7f..ff117bd5afc5 100644
41+
--- a/clang/include/clang/Basic/TokenKinds.h
42+
+++ b/clang/include/clang/Basic/TokenKinds.h
43+
@@ -109,7 +109,7 @@ bool isPragmaAnnotation(TokenKind K);
44+
45+
inline constexpr bool isRegularKeywordAttribute(TokenKind K) {
46+
return (false
47+
-#define KEYWORD_ATTRIBUTE(X) || (K == tok::kw_##X)
48+
+#define KEYWORD_ATTRIBUTE(X, ...) || (K == tok::kw_##X)
49+
#include "clang/Basic/AttrTokenKinds.inc"
50+
);
51+
}
52+
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
53+
index b5813c6abc2b..79db17501b64 100644
54+
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
55+
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
56+
@@ -3430,7 +3430,7 @@ void EmitClangAttrTokenKinds(RecordKeeper &Records, raw_ostream &OS) {
57+
"RegularKeyword attributes with arguments are not "
58+
"yet supported");
59+
OS << "KEYWORD_ATTRIBUTE("
60+
- << S.getSpellingRecord().getValueAsString("Name") << ")\n";
61+
+ << S.getSpellingRecord().getValueAsString("Name") << ", )\n";
62+
}
63+
OS << "#undef KEYWORD_ATTRIBUTE\n";
64+
}
65+
--
66+
2.43.0
67+

0 commit comments

Comments
 (0)