From fd60c48fa7c0281201a34fa42f12240a511ef02e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= Date: Wed, 27 Dec 2023 09:20:02 +0100 Subject: [PATCH] clang: update to curent Msys2 pkgrel 5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes git-for-windows/git#4747 Signed-off-by: Matthias Aßhauer --- .../0002-Fix-Findzstd-on-MINGW.patch | 8 +- mingw-w64-clang/0005-aarch64-unwind-seh.patch | 75 ------------------- mingw-w64-clang/PKGBUILD | 29 +++++-- mingw-w64-clang/update-clang-from-msys2.sh | 3 +- 4 files changed, 30 insertions(+), 85 deletions(-) delete mode 100644 mingw-w64-clang/0005-aarch64-unwind-seh.patch mode change 100644 => 100755 mingw-w64-clang/update-clang-from-msys2.sh diff --git a/mingw-w64-clang/0002-Fix-Findzstd-on-MINGW.patch b/mingw-w64-clang/0002-Fix-Findzstd-on-MINGW.patch index 108fb0e6a2ef6..f68fb5a29b01a 100644 --- a/mingw-w64-clang/0002-Fix-Findzstd-on-MINGW.patch +++ b/mingw-w64-clang/0002-Fix-Findzstd-on-MINGW.patch @@ -1,6 +1,6 @@ --- a/cmake/modules/Findzstd.cmake +++ b/cmake/modules/Findzstd.cmake -@@ -29,11 +29,11 @@ +@@ -29,14 +29,14 @@ ) if(zstd_FOUND) @@ -13,4 +13,8 @@ + if(WIN32) # IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library". get_filename_component(zstd_DIRNAME "${zstd_LIBRARY}" DIRECTORY) - string(REGEX REPLACE "${CMAKE_INSTALL_LIBDIR}$" "${CMAKE_INSTALL_BINDIR}" zstd_DIRNAME "${zstd_DIRNAME}") +- string(REGEX REPLACE "${CMAKE_INSTALL_LIBDIR}$" "${CMAKE_INSTALL_BINDIR}" zstd_DIRNAME "${zstd_DIRNAME}") ++ string(REGEX REPLACE "\\${CMAKE_INSTALL_LIBDIR}$" "${CMAKE_INSTALL_BINDIR}" zstd_DIRNAME "${zstd_DIRNAME}") + get_filename_component(zstd_BASENAME "${zstd_LIBRARY}" NAME) + string(REGEX REPLACE "\\${CMAKE_LINK_LIBRARY_SUFFIX}$" "${CMAKE_SHARED_LIBRARY_SUFFIX}" zstd_BASENAME "${zstd_BASENAME}") + set_target_properties(zstd::libzstd_shared PROPERTIES diff --git a/mingw-w64-clang/0005-aarch64-unwind-seh.patch b/mingw-w64-clang/0005-aarch64-unwind-seh.patch deleted file mode 100644 index ff4385cd3a52b..0000000000000 --- a/mingw-w64-clang/0005-aarch64-unwind-seh.patch +++ /dev/null @@ -1,75 +0,0 @@ -From cef120a2e5abba06c1d7a699a4fd4a17e488d6af Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Martin=20Storsj=C3=B6?= -Date: Sun, 1 Oct 2023 00:08:23 +0300 -Subject: [PATCH] [AArch64] Disable loop alignment for Windows targets - -This should fix #66912. When emitting SEH unwind info, we need to -be able to calculate the exact length of functions before alignments -are fixed. Until that limitation is overcome, just disable all -loop alignment on Windows targets. ---- - llvm/lib/MC/MCWin64EH.cpp | 3 +++ - .../Target/AArch64/AArch64ISelLowering.cpp | 7 ++++++- - llvm/test/CodeGen/AArch64/sched-loop-align.ll | 21 +++++++++++++++++++ - 3 files changed, 30 insertions(+), 1 deletion(-) - create mode 100644 llvm/test/CodeGen/AArch64/sched-loop-align.ll - -diff --git a/lib/MC/MCWin64EH.cpp b/lib/MC/MCWin64EH.cpp -index a2d61da722af870..bb3492bec8aad8a 100644 ---- a/lib/MC/MCWin64EH.cpp -+++ b/lib/MC/MCWin64EH.cpp -@@ -1402,6 +1402,9 @@ static void ARM64EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info, - // here, but we'd have to emit the pdata, the xdata header, and the - // epilogue scopes later, since they depend on whether the we need to - // split the unwind data. -+ // -+ // If this is fixed, remove code in AArch64ISelLowering.cpp that -+ // disables loop alignment on Windows. - RawFuncLength = GetAbsDifference(streamer, info->FuncletOrFuncEnd, - info->Begin); - } -diff --git a/lib/Target/AArch64/AArch64ISelLowering.cpp b/lib/Target/AArch64/AArch64ISelLowering.cpp -index 932b36587f0694e..46064bc7e46783f 100644 ---- a/lib/Target/AArch64/AArch64ISelLowering.cpp -+++ b/lib/Target/AArch64/AArch64ISelLowering.cpp -@@ -1051,7 +1051,12 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM, - // Set required alignment. - setMinFunctionAlignment(Align(4)); - // Set preferred alignments. -- setPrefLoopAlignment(STI.getPrefLoopAlignment()); -+ -+ // Don't align loops on Windows. The SEH unwind info generation needs to -+ // know the exact length of functions before the alignments have been -+ // expanded. -+ if (!Subtarget->isTargetWindows()) -+ setPrefLoopAlignment(STI.getPrefLoopAlignment()); - setMaxBytesForAlignment(STI.getMaxBytesForLoopAlignment()); - setPrefFunctionAlignment(STI.getPrefFunctionAlignment()); - -diff --git a/test/CodeGen/AArch64/sched-loop-align.ll b/test/CodeGen/AArch64/sched-loop-align.ll -new file mode 100644 -index 000000000000000..5b8e42c2790a439 ---- /dev/null -+++ b/test/CodeGen/AArch64/sched-loop-align.ll -@@ -0,0 +1,21 @@ -+; RUN: llc < %s -mtriple=aarch64-windows | FileCheck %s --check-prefix=WINDOWS -+; RUN: llc < %s -mtriple=aarch64-linux | FileCheck %s --check-prefix=LINUX -+ -+define dso_local void @b() #0 { -+entry: -+ br label %for.cond -+ -+for.cond: -+ tail call void @a() -+ br label %for.cond -+} -+ -+declare dso_local void @a(...) -+ -+attributes #0 = { noreturn nounwind uwtable "tune-cpu"="cortex-a53" } -+ -+; LINUX-LABEL: b: -+; LINUX: .p2align 4 -+ -+; WINDOWS-LABEL: b: -+; WINDOWS-NOT: .p2align diff --git a/mingw-w64-clang/PKGBUILD b/mingw-w64-clang/PKGBUILD index 49f14133b1ffb..ca6fe6a9dd628 100644 --- a/mingw-w64-clang/PKGBUILD +++ b/mingw-w64-clang/PKGBUILD @@ -32,7 +32,7 @@ _version=17.0.6 _rc= _tag=llvmorg-${_version}${_rc} pkgver=${_version}${_rc/-/} -pkgrel=3 +pkgrel=4 pkgdesc="C language family frontend for LLVM (mingw-w64)" arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64') @@ -69,7 +69,10 @@ source=("${_url}/llvm-${pkgver}.src.tar.xz"{,.sig} "0004-enable-emutls-for-mingw.patch" "0101-link-pthread-with-mingw.patch" "0102-Rename-flang-new-flang-experimental-exec-to-flang.patch" - "0303-ignore-new-bfd-options.patch") + "0303-ignore-new-bfd-options.patch" + https://github.com/llvm/llvm-project/commit/10b78cc8cea65e7e77d227af4027963f39402724.patch + https://github.com/llvm/llvm-project/commit/1709e8c656de69f6d823a3ae6773bf815e373909.patch + https://github.com/llvm/llvm-project/commit/9e3d915d8ebf86e24c9ff58766be8e7c6aa7b0c0.patch) # Some patch notes :) #0001-0099 -> llvm #0101-0199 -> clang @@ -91,12 +94,15 @@ sha256sums=('b638167da139126ca11917b6880207cc6e8f9d1cbb1a48d87d017f697ef78188' '3054d0a9c9375dab1a4539cc2cc45ab340341c5d71475f9599ba7752e222947b' 'SKIP' 'eb03df53671df6627768141b3aaa76abe176a14e5e47911c97bec544387c4aff' - 'd7d58ad5d0e77f2803070a8fb7f4138a6f49a2cbf30c55ff059c31f40ca6b65c' + '70930739511f0934bafad518cd02acbccd03915ca4c6bec4b272eb5bcec33e1e' '7f0c64cd87b61e894be632f180ae5291e1aa9f1d9d382608f659067eeeda7146' '5f86e542dd1ec92b2fe06ee59061c3e23512df7bafabe82206f2b7d80b81836b' '715cb8862753854b2d9256e0b70003e2d1f57083d83eaeaf5a095fc72b8a4e26' '2770cadf8ccf6b31aece6aee8f76dceb71e6e9d01fdf3be74c3743480ce34899' - 'de631ab199a6fe83b3f695350bffaad067a2f95fc2ba9c8fe57dc85665d3653c') + 'de631ab199a6fe83b3f695350bffaad067a2f95fc2ba9c8fe57dc85665d3653c' + '88c4994341b4de2a23929e31a98031cb94b6d42575f9d8fd6e120f61ae0c5747' + '0f3dcb8b2d5f90f8ff2e77896d3b0ef6c87af8214e679917898e35dd678daef5' + 'e745aa71c903445c86639507256a5ca775e69b569b58f2ff48d6047703cfc81a') validpgpkeys=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D' # Hans Wennborg, Google. '474E22316ABF4785A88C6E8EA2C794A986419D8A' # Tom Stellard 'D574BD5D1D0E98895E3BF90044F2485E45D59042') # Tobias Hieta @@ -128,6 +134,13 @@ prepare() { mv ${pkg}-$pkgver.src ${pkg} done + # Backports for llvm-windres, for improved compat with binutils 3.26+ + # https://github.com/msys2/MINGW-packages/pull/19157#issuecomment-1825285063 + apply_patch_with_msg \ + "10b78cc8cea65e7e77d227af4027963f39402724.patch" \ + "1709e8c656de69f6d823a3ae6773bf815e373909.patch" \ + "9e3d915d8ebf86e24c9ff58766be8e7c6aa7b0c0.patch" + # Patch llvm cd "${srcdir}/llvm" apply_patch_with_msg \ @@ -179,10 +192,13 @@ build() { FFI_INCLUDE_DIR=$(echo $FFI_INCLUDE_DIR | sed 's|-I||g') if check_option "debug" "y"; then - common_cmake_args+=(-DCMAKE_BUILD_TYPE=Debug) + common_cmake_args+=(-DCMAKE_BUILD_TYPE=Debug + -DLLVM_ENABLE_ASSERTIONS=ON) VERBOSE="VERBOSE=1" else - common_cmake_args+=(-DCMAKE_BUILD_TYPE=MinSizeRel) + common_cmake_args+=(-DCMAKE_BUILD_TYPE=MinSizeRel + -DLLVM_ENABLE_ASSERTIONS=OFF + -DLLVM_ENABLE_DUMP=ON) fi common_cmake_args+=(-Wno-dev -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} @@ -192,7 +208,6 @@ build() { -DPython3_FIND_REGISTRY=NEVER -DPython3_ROOT_DIR=${MINGW_PREFIX} -DFFI_INCLUDE_DIR="${FFI_INCLUDE_DIR}" - -DLLVM_ENABLE_ASSERTIONS=OFF -DLLVM_ENABLE_FFI=ON -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_BENCHMARKS=OFF diff --git a/mingw-w64-clang/update-clang-from-msys2.sh b/mingw-w64-clang/update-clang-from-msys2.sh old mode 100644 new mode 100755 index 2e83377935fe3..0e5cc775aa866 --- a/mingw-w64-clang/update-clang-from-msys2.sh +++ b/mingw-w64-clang/update-clang-from-msys2.sh @@ -49,7 +49,8 @@ mv upstream/$pkgname/README-patches.md ./ || die "$0: failed to replace existing sed -e "s/pkgrel=[.0-9]\+\(.*\)/pkgrel=$new_pkgrel\1/" \ -e 's/-DCMAKE_BUILD_TYPE=Release/-DCMAKE_BUILD_TYPE=MinSizeRel/' \ - -e 's/-DLLVM_TARGETS_TO_BUILD=.*/-DLLVM_TARGETS_TO_BUILD=Native/' \ + -e 's/-DLLVM_TARGETS_TO_BUILD=".*"/-DLLVM_TARGETS_TO_BUILD=Native/' \ + -e 's/-DLLVM_TARGETS_TO_BUILD=[A-Za-z0-9;]*/-DLLVM_TARGETS_TO_BUILD=Native/' \ -e 's/-DLLVM_ENABLE_SPHINX=ON/-DLLVM_ENABLE_SPHINX=OFF/'\ -e '/^check()/,/^}/d' \ -i PKGBUILD