diff --git a/pkgs/development/compilers/llvm/17/clang/aarch64-tblgen.patch b/pkgs/development/compilers/llvm/17/clang/aarch64-tblgen.patch new file mode 100644 index 0000000000000..34957087726e6 --- /dev/null +++ b/pkgs/development/compilers/llvm/17/clang/aarch64-tblgen.patch @@ -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"; + } diff --git a/pkgs/development/compilers/llvm/common/default.nix b/pkgs/development/compilers/llvm/common/default.nix index a40ffd4044b41..cd72991a3d46f 100644 --- a/pkgs/development/compilers/llvm/common/default.nix +++ b/pkgs/development/compilers/llvm/common/default.nix @@ -106,6 +106,13 @@ let path = ../12; } ]; + "clang/aarch64-tblgen.patch" = [ + { + after = "17"; + before = "18"; + path = ../17; + } + ]; "lld/add-table-base.patch" = [ { after = "16"; @@ -522,12 +529,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 { @@ -608,7 +620,12 @@ let ]; stripLen = 1; hash = "sha256-1NKej08R9SPlbDY/5b0OKUsHjX07i9brR84yXiPwi7E="; - }); + }) + ++ + 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"); }; clang-unwrapped = tools.libclang;