#224 Fix build with GCC 14 on ARM
Merged 4 months ago by nikic. Opened 4 months ago by nikic.
rpms/ nikic/clang gcc-14-fix  into  rawhide

@@ -0,0 +1,65 @@ 

+ From bd2e848f15c0f25231126eb10cb0ab350717dfc0 Mon Sep 17 00:00:00 2001

+ From: Nikita Popov <npopov@redhat.com>

+ Date: Fri, 19 Jan 2024 12:09:13 +0100

+ Subject: [PATCH] [Clang] Fix build with GCC 14 on ARM

+ 

+ GCC 14 defines `__arm_streaming` as a macro expanding to

+ `[[arm::streaming]]`. Due to the nested macro use, this gets

+ expanded prior to concatenation.

+ 

+ It doesn't look like C++ has a really clean way to prevent

+ macro expansion. The best I have found is to use `EMPTY ## X` where

+ `EMPTY` is an empty macro argument, so this is the hack I'm

+ implementing here.

+ 

+ Fixes https://github.com/llvm/llvm-project/issues/78691.

+ ---

+  clang/include/clang/Basic/TokenKinds.def  | 3 ++-

+  clang/include/clang/Basic/TokenKinds.h    | 2 +-

+  clang/utils/TableGen/ClangAttrEmitter.cpp | 2 +-

+  3 files changed, 4 insertions(+), 3 deletions(-)

+ 

+ diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def

+ index ef0dad0f2dcd..3add13c079f3 100644

+ --- a/clang/include/clang/Basic/TokenKinds.def

+ +++ b/clang/include/clang/Basic/TokenKinds.def

+ @@ -752,8 +752,9 @@ KEYWORD(__builtin_available              , KEYALL)

+  KEYWORD(__builtin_sycl_unique_stable_name, KEYSYCL)

+  

+  // Keywords defined by Attr.td.

+ +// The "EMPTY ## X" is used to prevent early macro-expansion of the keyword.

+  #ifndef KEYWORD_ATTRIBUTE

+ -#define KEYWORD_ATTRIBUTE(X) KEYWORD(X, KEYALL)

+ +#define KEYWORD_ATTRIBUTE(X, EMPTY) KEYWORD(EMPTY ## X, KEYALL)

+  #endif

+  #include "clang/Basic/AttrTokenKinds.inc"

+  

+ diff --git a/clang/include/clang/Basic/TokenKinds.h b/clang/include/clang/Basic/TokenKinds.h

+ index e4857405bc7f..ff117bd5afc5 100644

+ --- a/clang/include/clang/Basic/TokenKinds.h

+ +++ b/clang/include/clang/Basic/TokenKinds.h

+ @@ -109,7 +109,7 @@ bool isPragmaAnnotation(TokenKind K);

+  

+  inline constexpr bool isRegularKeywordAttribute(TokenKind K) {

+    return (false

+ -#define KEYWORD_ATTRIBUTE(X) || (K == tok::kw_##X)

+ +#define KEYWORD_ATTRIBUTE(X, ...) || (K == tok::kw_##X)

+  #include "clang/Basic/AttrTokenKinds.inc"

+    );

+  }

+ diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp

+ index b5813c6abc2b..79db17501b64 100644

+ --- a/clang/utils/TableGen/ClangAttrEmitter.cpp

+ +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp

+ @@ -3430,7 +3430,7 @@ void EmitClangAttrTokenKinds(RecordKeeper &Records, raw_ostream &OS) {

+                       "RegularKeyword attributes with arguments are not "

+                       "yet supported");

+          OS << "KEYWORD_ATTRIBUTE("

+ -           << S.getSpellingRecord().getValueAsString("Name") << ")\n";

+ +           << S.getSpellingRecord().getValueAsString("Name") << ", )\n";

+        }

+    OS << "#undef KEYWORD_ATTRIBUTE\n";

+  }

+ -- 

+ 2.43.0

+ 

file modified
+7 -3
@@ -55,7 +55,7 @@ 

  

  Name:		%pkg_name

  Version:	%{clang_version}%{?rc_ver:~rc%{rc_ver}}%{?llvm_snapshot_version_suffix:~%{llvm_snapshot_version_suffix}}

- Release:	3%{?dist}

+ Release:	4%{?dist}

  Summary:	A C language family front-end for LLVM

  

  License:	Apache-2.0 WITH LLVM-exception OR NCSA
@@ -92,6 +92,7 @@ 

  # Remove in clang 18.

  Patch6:     cfg.patch

  Patch7:     tsa.patch

+ Patch8:     0001-Clang-Fix-build-with-GCC-14-on-ARM.patch

  

  

  # RHEL specific patches
@@ -622,11 +623,14 @@ 

  

  %endif

  %changelog

+ %{?llvm_snapshot_changelog_entry}

+ 

+ * Mon Jan 22 2024 Nikita Popov <npopov@redhat.com> - 17.0.6-4

+ - Fix build with GCC 14 on ARM. Fix rhbz#2259254.

+ 

  * Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 17.0.6-3

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

  

- %{?llvm_snapshot_changelog_entry}

- 

  * Mon Dec 18 2023 Jeremy Newton <alexjnewt at hotmail dot com> - 17.0.6-2

  - Add clang-devel(major) provides

  

This backports the fix from https://github.com/llvm/llvm-project/pull/78704 to fix building of Clang with GCC 14 on ARM. This does not affect our own builds (as we build with clang), but can affect other projects including clang headers. In particular, mesa ran into this issue.

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/27b538ca99654faa9ac1c05858ad8ba1

rebased onto f221534

4 months ago

Rebased over the mass rebuild.

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/4b08c0cdf1e84c08bff42086547208b0

Pull-Request has been merged by nikic

4 months ago