llvmPackages_17.{clang,tblgen}: fix builds on aarch64 (#381163)

This commit is contained in:
Tristan Ross
2025-03-13 13:42:34 -07:00
committed by GitHub
3 changed files with 62 additions and 7 deletions
@@ -0,0 +1,39 @@
diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def
index ef0dad0f2..afd101b00 100644
--- a/include/clang/Basic/TokenKinds.def
+++ b/include/clang/Basic/TokenKinds.def
@@ -753,7 +753,7 @@ KEYWORD(__builtin_sycl_unique_stable_name, KEYSYCL)
// Keywords defined by Attr.td.
#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/include/clang/Basic/TokenKinds.h b/include/clang/Basic/TokenKinds.h
index e4857405b..ff117bd5a 100644
--- a/include/clang/Basic/TokenKinds.h
+++ b/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/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp
index b5813c6ab..79db17501 100644
--- a/utils/TableGen/ClangAttrEmitter.cpp
+++ b/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";
}
@@ -117,7 +117,11 @@ let
];
stripLen = 1;
hash = "sha256-1NKej08R9SPlbDY/5b0OKUsHjX07i9brR84yXiPwi7E=";
});
})
++ lib.optional (stdenv.isAarch64 && lib.versions.major release_version == "17")
# Fixes llvm17 tblgen builds on aarch64.
# https://github.com/llvm/llvm-project/issues/106521#issuecomment-2337175680
(getVersionFile "clang/aarch64-tblgen.patch");
nativeBuildInputs = [ cmake ]
++ (lib.optional (lib.versionAtLeast release_version "15") ninja)
@@ -106,6 +106,13 @@ let
path = ../12;
}
];
"clang/aarch64-tblgen.patch" = [
{
after = "17";
before = "18";
path = ../17;
}
];
"lld/add-table-base.patch" = [
{
after = "16";
@@ -373,12 +380,17 @@ let
# Crude method to drop polly patches if present, they're not needed for tblgen.
(p: (!lib.hasInfix "-polly" p))
tools.libllvm.patches;
clangPatches = [
# Would take tools.libclang.patches, but this introduces a cycle due
# to replacements depending on the llvm outpath (e.g. the LLVMgold patch).
# So take the only patch known to be necessary.
(metadata.getVersionFile "clang/gnu-install-dirs.patch")
];
clangPatches =
[
# Would take tools.libclang.patches, but this introduces a cycle due
# to replacements depending on the llvm outpath (e.g. the LLVMgold patch).
# So take the only patch known to be necessary.
(metadata.getVersionFile "clang/gnu-install-dirs.patch")
]
++ lib.optional (stdenv.isAarch64 && lib.versions.major metadata.release_version == "17")
# Fixes llvm17 tblgen builds on aarch64.
# https://github.com/llvm/llvm-project/issues/106521#issuecomment-2337175680
(metadata.getVersionFile "clang/aarch64-tblgen.patch");
};
libclang = callPackage ./clang {