From 761cc8a5d4ecd09b89377b520b5afc4a4970f141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= Date: Sat, 28 Jan 2023 14:19:44 +0100 Subject: [PATCH] llvm/clang: update to 16.0.0 --- .../0004-enable-emutls-for-mingw.patch | 10 +- ...0005-export-out-of-tree-mlir-targets.patch | 35 --- ...ed-exclude-symbols-directives-for-hi.patch | 221 ------------------ ...y-when-building-for-MinGW-with-Clang.patch | 88 ------- ...st-memrchr-as-unavailable-on-Windows.patch | 25 -- ...for-Flang-runtime-libraries-on-MinGW.patch | 13 ++ .../0303-ignore-new-bfd-options.patch | 6 +- mingw-w64-clang/PKGBUILD | 81 +++---- mingw-w64-clang/README-patches.md | 4 +- 9 files changed, 49 insertions(+), 434 deletions(-) delete mode 100644 mingw-w64-clang/0005-export-out-of-tree-mlir-targets.patch delete mode 100644 mingw-w64-clang/0008-COFF-Emit-embedded-exclude-symbols-directives-for-hi.patch delete mode 100644 mingw-w64-clang/0009-Use-hidden-visibility-when-building-for-MinGW-with-Clang.patch delete mode 100644 mingw-w64-clang/0011-List-memrchr-as-unavailable-on-Windows.patch create mode 100644 mingw-w64-clang/0301-Add-exceptions-for-Flang-runtime-libraries-on-MinGW.patch diff --git a/mingw-w64-clang/0004-enable-emutls-for-mingw.patch b/mingw-w64-clang/0004-enable-emutls-for-mingw.patch index 2388f67c39..0dbca65537 100644 --- a/mingw-w64-clang/0004-enable-emutls-for-mingw.patch +++ b/mingw-w64-clang/0004-enable-emutls-for-mingw.patch @@ -1,11 +1,11 @@ ---- llvm-10.0.0.src/include/llvm/ADT/Triple.h.orig 2020-05-15 15:49:40.073000000 +0200 -+++ llvm-10.0.0.src/include/llvm/ADT/Triple.h 2020-05-15 20:51:29.844520400 +0200 -@@ -809,7 +809,7 @@ - +--- a/include/llvm/TargetParser/Triple.h ++++ b/include/llvm/TargetParser/Triple.h +@@ -952,7 +952,7 @@ + /// Tests whether the target uses emulated TLS as default. bool hasDefaultEmulatedTLS() const { - return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment(); + return isAndroid() || isOSOpenBSD() || isOSCygMing(); } - + /// Tests whether the target uses -data-sections as default. diff --git a/mingw-w64-clang/0005-export-out-of-tree-mlir-targets.patch b/mingw-w64-clang/0005-export-out-of-tree-mlir-targets.patch deleted file mode 100644 index 10bc268471..0000000000 --- a/mingw-w64-clang/0005-export-out-of-tree-mlir-targets.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/cmake/modules/TableGen.cmake -+++ b/cmake/modules/TableGen.cmake -@@ -179,14 +179,18 @@ - endif() - - if ((${project} STREQUAL LLVM OR ${project} STREQUAL MLIR) AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS) -- set(export_to_llvmexports) -+ set(export_to_project_exports) - if(${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR - NOT LLVM_DISTRIBUTION_COMPONENTS) -- set(export_to_llvmexports EXPORT LLVMExports) -+ if(${CMAKE_PROJECT_NAME} STREQUAL "mlir" AND ${project} STREQUAL "MLIR") -+ set(export_to_project_exports EXPORT MLIRTargets) -+ else() -+ set(export_to_project_exports EXPORT LLVMExports) -+ endif() - endif() - - install(TARGETS ${target} -- ${export_to_llvmexports} -+ ${export_to_project_exports} - COMPONENT ${target} - RUNTIME DESTINATION ${LLVM_TOOLS_INSTALL_DIR}) - if(NOT LLVM_ENABLE_IDE) -@@ -195,5 +199,9 @@ - COMPONENT ${target}) - endif() - endif() -- set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${target}) -+ if(${CMAKE_PROJECT_NAME} STREQUAL "mlir" AND ${project} STREQUAL "MLIR") -+ set_property(GLOBAL APPEND PROPERTY MLIR_EXPORTS ${target}) -+ else() -+ set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${target}) -+ endif() - endmacro() diff --git a/mingw-w64-clang/0008-COFF-Emit-embedded-exclude-symbols-directives-for-hi.patch b/mingw-w64-clang/0008-COFF-Emit-embedded-exclude-symbols-directives-for-hi.patch deleted file mode 100644 index 4809dfa183..0000000000 --- a/mingw-w64-clang/0008-COFF-Emit-embedded-exclude-symbols-directives-for-hi.patch +++ /dev/null @@ -1,221 +0,0 @@ -From c5b3de6745c37dd991430b9b88ff97c35b6fc455 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Martin=20Storsj=C3=B6?= -Date: Tue, 19 Jul 2022 00:18:16 +0300 -Subject: [PATCH] [COFF] Emit embedded -exclude-symbols: directives for hidden - visibility for MinGW - -This works with the automatic export of all symbols; in MinGW mode, -when a DLL has no explicit dllexports, it exports all symbols (except -for some that are hardcoded to be excluded, including some toolchain -libraries). - -By hooking up the hidden visibility to the -exclude-symbols: directive, -the automatic export of all symbols can be controlled in an easier -way (with a mechanism that doesn't require strict annotation of every -single symbol, but which allows gradually marking more unnecessary -symbols as hidden). - -The primary use case is dylib builds of LLVM/Clang. These can be done -in MinGW mode but not in MSVC mode, as MinGW builds can export all -symbols (and the calling code can use APIs without corresponding -dllimport directives). However, as all symbols are exported, it can -easily overflow the max number of exported symbols in a DLL (65536). - -In the llvm-mingw distribution, only the X86, ARM and AArch64 backends -are enabled; for the LLVM 13.0.0 release, libLLVM-13.dll ended up with -58112 exported symbols. For LLVM 14.0.0, it was 62015 symbols. Current -builds of the 15.x branch end up at around 64650 symbols - i.e. extremely -close to the limit. - -The msys2 packages of LLVM have had to progressively disable more -of their backends in their builds, to be able to keep building with a -dylib. - -This allows improving the current mingw dylib situation significantly, -by using the same hidden visibility options and attributes as on Unix. -With those in place, a current build of LLVM git main ends up at 35142 -symbols instead of 64650. - -For code using hidden visibility, this now requires linking with either -a current git lld or ld.bfd. (Older lld error out on the unknown -directives, older ld.bfd will successfully link, but will print huge -amounts of warnings.) - -Differential Revision: https://reviews.llvm.org/D130121 ---- - lib/IR/Mangler.cpp | 60 +++++++++++++------- - test/CodeGen/X86/mingw-hidden.ll | 81 +++++++++++++++++++++++++++ - 2 files changed, 121 insertions(+), 20 deletions(-) - create mode 100644 test/CodeGen/X86/mingw-hidden.ll - -diff --git a/lib/IR/Mangler.cpp b/lib/IR/Mangler.cpp -index b8e3e40e4c1d..9011f5db6a40 100644 ---- a/lib/IR/Mangler.cpp -+++ b/lib/IR/Mangler.cpp -@@ -210,18 +210,46 @@ static bool canBeUnquotedInDirective(StringRef Name) { - - void llvm::emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV, - const Triple &TT, Mangler &Mangler) { -- if (!GV->hasDLLExportStorageClass() || GV->isDeclaration()) -- return; -+ if (GV->hasDLLExportStorageClass() && !GV->isDeclaration()) { - -- if (TT.isWindowsMSVCEnvironment()) -- OS << " /EXPORT:"; -- else -- OS << " -export:"; -+ if (TT.isWindowsMSVCEnvironment()) -+ OS << " /EXPORT:"; -+ else -+ OS << " -export:"; -+ -+ bool NeedQuotes = GV->hasName() && !canBeUnquotedInDirective(GV->getName()); -+ if (NeedQuotes) -+ OS << "\""; -+ if (TT.isWindowsGNUEnvironment() || TT.isWindowsCygwinEnvironment()) { -+ std::string Flag; -+ raw_string_ostream FlagOS(Flag); -+ Mangler.getNameWithPrefix(FlagOS, GV, false); -+ FlagOS.flush(); -+ if (Flag[0] == GV->getParent()->getDataLayout().getGlobalPrefix()) -+ OS << Flag.substr(1); -+ else -+ OS << Flag; -+ } else { -+ Mangler.getNameWithPrefix(OS, GV, false); -+ } -+ if (NeedQuotes) -+ OS << "\""; -+ -+ if (!GV->getValueType()->isFunctionTy()) { -+ if (TT.isWindowsMSVCEnvironment()) -+ OS << ",DATA"; -+ else -+ OS << ",data"; -+ } -+ } -+ if (GV->hasHiddenVisibility() && !GV->isDeclaration() && TT.isOSCygMing()) { -+ -+ OS << " -exclude-symbols:"; -+ -+ bool NeedQuotes = GV->hasName() && !canBeUnquotedInDirective(GV->getName()); -+ if (NeedQuotes) -+ OS << "\""; - -- bool NeedQuotes = GV->hasName() && !canBeUnquotedInDirective(GV->getName()); -- if (NeedQuotes) -- OS << "\""; -- if (TT.isWindowsGNUEnvironment() || TT.isWindowsCygwinEnvironment()) { - std::string Flag; - raw_string_ostream FlagOS(Flag); - Mangler.getNameWithPrefix(FlagOS, GV, false); -@@ -230,17 +258,9 @@ void llvm::emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV, - OS << Flag.substr(1); - else - OS << Flag; -- } else { -- Mangler.getNameWithPrefix(OS, GV, false); -- } -- if (NeedQuotes) -- OS << "\""; - -- if (!GV->getValueType()->isFunctionTy()) { -- if (TT.isWindowsMSVCEnvironment()) -- OS << ",DATA"; -- else -- OS << ",data"; -+ if (NeedQuotes) -+ OS << "\""; - } - } - -diff --git a/test/CodeGen/X86/mingw-hidden.ll b/test/CodeGen/X86/mingw-hidden.ll -new file mode 100644 -index 000000000000..8958458c55b6 ---- /dev/null -+++ b/test/CodeGen/X86/mingw-hidden.ll -@@ -0,0 +1,81 @@ -+; RUN: llc -mtriple i386-pc-win32 < %s \ -+; RUN: | FileCheck --check-prefixes=CHECK,CHECK-MSVC %s -+; RUN: llc -mtriple i386-pc-mingw32 < %s \ -+; RUN: | FileCheck --check-prefixes=CHECK,CHECK-MINGW %s -+; RUN: llc -mtriple i386-pc-mingw32 < %s \ -+; RUN: | FileCheck --check-prefix=NOTEXPORTED %s -+ -+; CHECK: .text -+ -+; CHECK: .globl _notHidden -+define void @notHidden() { -+ ret void -+} -+ -+; CHECK: .globl _f1 -+define hidden void @f1() { -+ ret void -+} -+ -+; CHECK: .globl _f2 -+define hidden void @f2() unnamed_addr { -+ ret void -+} -+ -+declare hidden void @notDefined() -+ -+; CHECK: .globl _stdfun@0 -+define hidden x86_stdcallcc void @stdfun() nounwind { -+ ret void -+} -+ -+; CHECK: .globl _lnk1 -+$lnk1 = comdat any -+ -+define linkonce_odr hidden void @lnk1() comdat { -+ ret void -+} -+ -+; CHECK: .globl _lnk2 -+$lnk2 = comdat any -+ -+define linkonce_odr hidden void @lnk2() alwaysinline comdat { -+ ret void -+} -+ -+; CHECK: .data -+; CHECK: .globl _Var1 -+@Var1 = hidden global i32 1, align 4 -+ -+; CHECK: .rdata,"dr" -+; CHECK: .globl _Var2 -+@Var2 = hidden unnamed_addr constant i32 1 -+ -+; CHECK: .comm _Var3 -+@Var3 = common hidden global i32 0, align 4 -+ -+; CHECK: .globl "_complex-name" -+@"complex-name" = hidden global i32 1, align 4 -+ -+; CHECK: .globl _complex.name -+@"complex.name" = hidden global i32 1, align 4 -+ -+ -+; Verify items that should not be marked hidden do not appear in the directives. -+; We use a separate check prefix to avoid confusion between -NOT and -SAME. -+; NOTEXPORTED: .section .drectve -+; NOTEXPORTED-NOT: :notHidden -+; NOTEXPORTED-NOT: :notDefined -+ -+; CHECK-MSVC-NOT: .section .drectve -+; CHECK-MINGW: .section .drectve -+; CHECK-MINGW: .ascii " -exclude-symbols:f1" -+; CHECK-MINGW: .ascii " -exclude-symbols:f2" -+; CHECK-MINGW: .ascii " -exclude-symbols:stdfun@0" -+; CHECK-MINGW: .ascii " -exclude-symbols:lnk1" -+; CHECK-MINGW: .ascii " -exclude-symbols:lnk2" -+; CHECK-MINGW: .ascii " -exclude-symbols:Var1" -+; CHECK-MINGW: .ascii " -exclude-symbols:Var2" -+; CHECK-MINGW: .ascii " -exclude-symbols:Var3" -+; CHECK-MINGW: .ascii " -exclude-symbols:\"complex-name\"" -+; CHECK-MINGW: .ascii " -exclude-symbols:\"complex.name\"" --- -2.37.1.windows.1 - diff --git a/mingw-w64-clang/0009-Use-hidden-visibility-when-building-for-MinGW-with-Clang.patch b/mingw-w64-clang/0009-Use-hidden-visibility-when-building-for-MinGW-with-Clang.patch deleted file mode 100644 index f5cf7390b0..0000000000 --- a/mingw-w64-clang/0009-Use-hidden-visibility-when-building-for-MinGW-with-Clang.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 2c2fb0c7375061147711cd21396d79faad7dfdfb Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Martin=20Storsj=C3=B6?= -Date: Mon, 18 Jul 2022 14:13:05 +0300 -Subject: [PATCH] [llvm] Use hidden visibility when building for MinGW with - Clang - -Since c5b3de6745c37dd991430b9b88ff97c35b6fc455 (git main, -August 11th), Clang does generate working hidden visibility -on MinGW targets. Using that reduces the number of exports from -a dylib build of LLVM significantly, which is vital for fitting -within the limit of 64k exported symbols from a DLL. - -It's essential that if we set CMAKE_CXX_VISIBILITY_PRESET=hidden -(which passes -fvisibility=hidden on the command line), we also -must define LLVM_EXTERNAL_VISIBILITY consistently to override -it. (If there are mismatches, e.g. setting hidden visibility generally -but never overriding it back to default for the symbols that do need -to be exported, we'd get broken builds in such configurations.) - -We don't want to be using __attribute__((visibility("hidden"))) on -MinGW with GCC, because GCC produces a warning about it. (GCC hasn't -warned about the command line options that set hidden visibility -though.) Clang has historically not warned about either of them, so -it is harmless to use the hidden visibility when building with older -Clang (so we don't need to detect the exact version of Clang/LLVM where -it has an effect). - -This reduces the number of exported symbols for a dylib build of LLVM; -previously libLLVM exported around 64650 symbols (when the maximum is -65536) when the ARM, AArch64 and X86 targets were enabled. If enabling -more targets (or if building with e.g. assertions enabled), it would -exceed the limit. Now with visibility flags in use, the same build -with ARM, AArch64 and X86 ends up at around 35k exported symbols. - -Differential Revision: https://reviews.llvm.org/D131661 ---- - cmake/modules/HandleLLVMOptions.cmake | 7 +++++-- - include/llvm/Support/Compiler.h | 5 +++-- - lib/Target/CMakeLists.txt | 2 +- - 3 files changed, 9 insertions(+), 5 deletions(-) - -diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake -index dba96d1f0815d..ba525e62f3966 100644 ---- a/cmake/modules/HandleLLVMOptions.cmake -+++ b/cmake/modules/HandleLLVMOptions.cmake -@@ -351,8 +351,11 @@ if( LLVM_ENABLE_PIC ) - endif() - endif() - --if(NOT WIN32 AND NOT CYGWIN AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX")) -- # MinGW warns if -fvisibility-inlines-hidden is used. -+if((NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX")) AND -+ (NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang"))) -+ # GCC for MinGW does nothing about -fvisibility-inlines-hidden, but warns -+ # about use of the attributes. As long as we don't use the attributes (to -+ # override the default) we shouldn't set the command line options either. - # GCC on AIX warns if -fvisibility-inlines-hidden is used and Clang on AIX doesn't currently support visibility. - check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG) - append_if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG "-fvisibility-inlines-hidden" CMAKE_CXX_FLAGS) -diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h -index c4cfea1fb3c8b..bf299bc1d0d7f 100644 ---- a/include/llvm/Support/Compiler.h -+++ b/include/llvm/Support/Compiler.h -@@ -113,8 +113,9 @@ - /// LLVM_EXTERNAL_VISIBILITY - classes, functions, and variables marked with - /// this attribute will be made public and visible outside of any shared library - /// they are linked in to. --#if __has_attribute(visibility) && !defined(__MINGW32__) && \ -- !defined(__CYGWIN__) && !defined(_WIN32) -+#if __has_attribute(visibility) && \ -+ (!(defined(_WIN32) || defined(__CYGWIN__)) || \ -+ (defined(__MINGW32__) && defined(__clang__))) - #define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden"))) - #if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS) - #define LLVM_EXTERNAL_VISIBILITY __attribute__((visibility("default"))) -diff --git a/lib/Target/CMakeLists.txt b/lib/Target/CMakeLists.txt -index c0c2bc36a6e47..0fec6d1fb6901 100644 ---- a/lib/Target/CMakeLists.txt -+++ b/lib/Target/CMakeLists.txt -@@ -22,7 +22,7 @@ add_llvm_component_library(LLVMTarget - # When building shared objects for each target there are some internal APIs - # that are used across shared objects which we can't hide. - if (NOT BUILD_SHARED_LIBS AND NOT APPLE AND -- NOT MINGW AND -+ (NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND - NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX") AND - NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET) - # Set default visibility to hidden, so we don't export all the Target classes diff --git a/mingw-w64-clang/0011-List-memrchr-as-unavailable-on-Windows.patch b/mingw-w64-clang/0011-List-memrchr-as-unavailable-on-Windows.patch deleted file mode 100644 index 632af083ac..0000000000 --- a/mingw-w64-clang/0011-List-memrchr-as-unavailable-on-Windows.patch +++ /dev/null @@ -1,25 +0,0 @@ -From eef37f2d89e72954645f4f3583227df74c841a84 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= -Date: Sun, 18 Sep 2022 13:17:16 +0200 -Subject: [PATCH] List memrchr as unavailable on Windows - -Otherwise LLVM will optimize strrchr into memrchr causing linker error ---- - lib/Analysis/TargetLibraryInfo.cpp | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/lib/Analysis/TargetLibraryInfo.cpp b/lib/Analysis/TargetLibraryInfo.cpp -index 75b57e75fdd0..40f0cf39d7d6 100644 ---- a/lib/Analysis/TargetLibraryInfo.cpp -+++ b/lib/Analysis/TargetLibraryInfo.cpp -@@ -439,6 +439,7 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, - TLI.setUnavailable(LibFunc_htons); - TLI.setUnavailable(LibFunc_lchown); - TLI.setUnavailable(LibFunc_lstat); -+ TLI.setUnavailable(LibFunc_memrchr); - TLI.setUnavailable(LibFunc_ntohl); - TLI.setUnavailable(LibFunc_ntohs); - TLI.setUnavailable(LibFunc_pread); --- -2.37.3.windows.1 - diff --git a/mingw-w64-clang/0301-Add-exceptions-for-Flang-runtime-libraries-on-MinGW.patch b/mingw-w64-clang/0301-Add-exceptions-for-Flang-runtime-libraries-on-MinGW.patch new file mode 100644 index 0000000000..ba68398855 --- /dev/null +++ b/mingw-w64-clang/0301-Add-exceptions-for-Flang-runtime-libraries-on-MinGW.patch @@ -0,0 +1,13 @@ +diff --git a/COFF/MinGW.cpp b/COFF/MinGW.cpp +--- a/COFF/MinGW.cpp ++++ b/COFF/MinGW.cpp +@@ -49,6 +49,9 @@ + "libclang_rt.profile-x86_64", + "libc++", + "libc++abi", ++ "libFortran_main", ++ "libFortranRuntime", ++ "libFortranDecimal", + "libunwind", + "libmsvcrt", + "libucrtbase", diff --git a/mingw-w64-clang/0303-ignore-new-bfd-options.patch b/mingw-w64-clang/0303-ignore-new-bfd-options.patch index 790a8bf601..39ec520b3b 100644 --- a/mingw-w64-clang/0303-ignore-new-bfd-options.patch +++ b/mingw-w64-clang/0303-ignore-new-bfd-options.patch @@ -1,10 +1,8 @@ -diff --git a/MinGW/Options.td b/MinGW/Options.td -index 0604b458193..efccf2d48ce 100644 --- a/MinGW/Options.td +++ b/MinGW/Options.td -@@ -114,6 +114,8 @@ def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias; - // Ignored options +@@ -165,6 +165,8 @@ def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias; def: Joined<["-"], "O">; + def: F<"as-needed">; def: F<"build-id">; +def: F<"default-image-base-high">; +def: F<"default-image-base-low">; diff --git a/mingw-w64-clang/PKGBUILD b/mingw-w64-clang/PKGBUILD index 209822a218..375e3dfd92 100644 --- a/mingw-w64-clang/PKGBUILD +++ b/mingw-w64-clang/PKGBUILD @@ -22,11 +22,11 @@ pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}" $( (( _clangprefix )) && echo "${MINGW_PACKAGE_PREFIX}-gcc-compat" ) "${MINGW_PACKAGE_PREFIX}-lld" "${MINGW_PACKAGE_PREFIX}-llvm") -_version=15.0.7 +_version=16.0.0 _rc="" _tag=llvmorg-${_version}${_rc} pkgver=${_version}${_rc/-/} -pkgrel=3 +pkgrel=1 pkgdesc="C language family frontend for LLVM (mingw-w64)" arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64') @@ -41,15 +41,13 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-cmake" "${MINGW_PACKAGE_PREFIX}-python-sphinx" "${MINGW_PACKAGE_PREFIX}-python" $([[ "$_compiler" == "clang" ]] && echo \ - "${MINGW_PACKAGE_PREFIX}-clang") + "${MINGW_PACKAGE_PREFIX}-clang" || echo \ + "${MINGW_PACKAGE_PREFIX}-gcc") $((( _clangprefix )) && echo \ "${MINGW_PACKAGE_PREFIX}-compiler-rt" \ "${MINGW_PACKAGE_PREFIX}-libc++") - $([[ "$_compiler" == "gcc" ]] && echo \ - "${MINGW_PACKAGE_PREFIX}-gcc") "git" ) -options=('!debug' 'strip') _url=https://github.com/llvm/llvm-project/releases/download/${_tag} # libunwind: https://github.com/llvm/llvm-project/issues/48572 source=("${_url}/llvm-${pkgver}.src.tar.xz"{,.sig} @@ -59,54 +57,43 @@ source=("${_url}/llvm-${pkgver}.src.tar.xz"{,.sig} "${_url}/lld-${pkgver}.src.tar.xz"{,.sig} "${_url}/libunwind-${pkgver}.src.tar.xz"{,.sig} "${_url}/cmake-${pkgver}.src.tar.xz"{,.sig} + "${_url}/third-party-${pkgver}.src.tar.xz"{,.sig} "0001-Fix-GetHostTriple-for-mingw-w64-in-msys.patch" "0002-Revert-CMake-try-creating-symlink-first-on-windows.patch" "0003-add-pthread-as-system-lib-for-mingw.patch" "0004-enable-emutls-for-mingw.patch" - "0005-export-out-of-tree-mlir-targets.patch" - "0008-COFF-Emit-embedded-exclude-symbols-directives-for-hi.patch" - "0009-Use-hidden-visibility-when-building-for-MinGW-with-Clang.patch" - "0011-List-memrchr-as-unavailable-on-Windows.patch" "0101-link-pthread-with-mingw.patch" - "0303-ignore-new-bfd-options.patch" - "https://github.com/llvm/llvm-project/commit/fbfe1db4a95a.patch" - "https://github.com/llvm/llvm-project/commit/888d9e671fb5b44b74184e13beba2aa42133f4d6.patch" - "https://github.com/llvm/llvm-project/commit/dcbf61b3520ed7157688a269ad4dfa8545a00f79.patch" - "https://github.com/llvm/llvm-project/commit/a1e80c69223a091e6f0fc84df33a464604c8bbc1.patch") + "0301-Add-exceptions-for-Flang-runtime-libraries-on-MinGW.patch" + "0303-ignore-new-bfd-options.patch") # Some patch notes :) #0001-0099 -> llvm #0101-0199 -> clang #0201-0299 -> rt #0301-0399 -> lld #0401-0499 -> clang-tools-extra -sha256sums=('4ad8b2cc8003c86d0078d15d987d84e3a739f24aae9033865c027abae93ee7a4' +sha256sums=('bce6fc19c48501546097e7b839c9ee376ea23b5cfd09199de8e42d5a5b5d4aae' 'SKIP' - 'a6b673ef15377fb46062d164e8ddc4d05c348ff8968f015f7f4af03f51000067' + '86d1348c8bb1ef13edecec19a0e68dc0db9b18b78f5de48d52ae7983edb9598f' 'SKIP' - '809a2ef46d46be3b83ca389356404ac041fa6d8f5496cb02ec35d252afb64fd1' + '430fadf6b4b287686e7043792e4defc4b54a4911d02bda540aa5acf63a0de5fa' 'SKIP' - '353832c66cce60931ea0413b3c071faad59eefa70d02c97daa8978b15e4b25b7' + 'a43610aba06538324f4143626c392d51883042685a33d22b629afd8658ea344e' 'SKIP' - 'dba5c70c3fe88b3a38b9180df82fbc9d1dfd55d68f41fddd6a90f9e17f8e5df9' + '005577d7e59f780e47e69b47188083e7ad9ce9ce6a52d05b831d06d24523851d' 'SKIP' - '406d199ae3a16add84017f40458a5e7c31f9412937fcb518715af0a0eeafbc0c' + '32b9bc69b2ccf8e30b689508c5cc9dbd34616991d5a91679a32a8fc4cde2f921' 'SKIP' - '8986f29b634fdaa9862eedda78513969fe9788301c9f2d938f4c10a3e7a3e7ea' + '04e62ab7d0168688d9102680adf8eabe7b04275f333fe20eef8ab5a3a8ea9fcc' + 'SKIP' + 'ddc21cdd290df012f8aa719767d80df3c37f49cfdb087d3e814087dcfaebfc7a' 'SKIP' 'eb03df53671df6627768141b3aaa76abe176a14e5e47911c97bec544387c4aff' '5754c357cfc17769e80d95b673d41b1e54616e2487e037d761a1ac8bb28a2849' '7f0c64cd87b61e894be632f180ae5291e1aa9f1d9d382608f659067eeeda7146' - '3837bd707d3d99a742e874d5c59a1e7d5502811d6926319974c5d9db86020039' - 'cb96582194ef80a37cc184e95287920b2df5369e2e5798a64adf6f8bf1c52985' - '5bb5e31eea8ea2c4eea56f2aae161dfde35caa9800459ae3c785a94654628e57' - 'f3bce25ac7d339cbe7a94bd1cfd2d634450c261c7a32103aba4ed5f773fd2cfc' - 'cc6aeca56693070de910670f546d2ec50a056d5356540dbd7b5aa74ced45980b' + 'ef2ae12a4d6ac7a52d38bb305818b26c830ae42d14468e4b1913157d998b2137' '715cb8862753854b2d9256e0b70003e2d1f57083d83eaeaf5a095fc72b8a4e26' - '778e0db0a5b0657ab05e2a81d83241347a4a41af2b0f9903422f651fa58e8d40' - 'd5654bffcb86daf4ed32c42a057b5d27ca56564fe9166a3288d6f15702668360' - 'b1eeabbe8da66e7c26b16b1933e8157ca33f2cf253daa023c648af2142dd0714' - '27b29abbeca545998312dd0788c99d80ad6e52a665ecc3cb9141ebe8d900df64' - 'f252435d4048e6e33a45d51951d0d045a4390f4d0060e9c486b7feb1f255fdb5') + '068e7d929e523c87ca5e72473997af383fa9ecbb8591d5a65eb6b3d1dde09b60' + 'de631ab199a6fe83b3f695350bffaad067a2f95fc2ba9c8fe57dc85665d3653c') validpgpkeys=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D' # Hans Wennborg, Google. '474E22316ABF4785A88C6E8EA2C794A986419D8A' # Tom Stellard 'D574BD5D1D0E98895E3BF90044F2485E45D59042') # Tobias Hieta @@ -134,7 +121,7 @@ prepare() { tar -xJf ${srcdir}/clang-${pkgver}.src.tar.xz -C ${srcdir} || true # Rename Directories - for pkg in llvm clang clang-tools-extra compiler-rt lld libunwind cmake; do + for pkg in llvm clang clang-tools-extra compiler-rt lld libunwind cmake third-party; do mv ${pkg}-$pkgver.src ${pkg} done @@ -150,18 +137,6 @@ prepare() { "0004-enable-emutls-for-mingw.patch" fi - apply_patch_with_msg \ - "0005-export-out-of-tree-mlir-targets.patch" \ - "0008-COFF-Emit-embedded-exclude-symbols-directives-for-hi.patch" \ - "0009-Use-hidden-visibility-when-building-for-MinGW-with-Clang.patch" \ - "0011-List-memrchr-as-unavailable-on-Windows.patch" - - # https://github.com/llvm/llvm-project/issues/55023#issuecomment-1320967497 - patch -Nbp2 -i "${srcdir}/dcbf61b3520ed7157688a269ad4dfa8545a00f79.patch" - - # https://github.com/msys2/MINGW-packages/issues/15695 - patch -Nlbp2 -i "${srcdir}/a1e80c69223a091e6f0fc84df33a464604c8bbc1.patch" - # Patch clang cd "${srcdir}/clang" @@ -170,16 +145,14 @@ prepare() { "0101-link-pthread-with-mingw.patch" fi - # https://github.com/msys2/MINGW-packages/pull/12550#issuecomment-1228506687 - # https://github.com/msys2/MINGW-packages/pull/12852#issuecomment-1245042931 - patch -Nbp2 -i "${srcdir}/fbfe1db4a95a.patch" - # Patch lld cd "${srcdir}/lld" + # https://reviews.llvm.org/D145389 + apply_patch_with_msg \ + "0301-Add-exceptions-for-Flang-runtime-libraries-on-MinGW.patch" + apply_patch_with_msg \ "0303-ignore-new-bfd-options.patch" - # https://github.com/msys2/MINGW-packages/issues/9091#issuecomment-1293993425 - patch -Nbp2 -i "${srcdir}/888d9e671fb5b44b74184e13beba2aa42133f4d6.patch" # Patch clang-tools-extra cd "${srcdir}/clang-tools-extra" @@ -257,7 +230,6 @@ build() { platform_config+=(-DLLVM_TARGETS_TO_BUILD="AArch64;AMDGPU;ARM;AVR;BPF;Mips;MSP430;NVPTX;RISCV;WebAssembly;X86") fi - [[ -d build-${MSYSTEM} ]] && rm -rf build-${MSYSTEM} mkdir build-${MSYSTEM} && cd build-${MSYSTEM} MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \ @@ -276,6 +248,7 @@ build() { -DLLVM_ENABLE_RTTI=ON \ -DLLVM_INCLUDE_EXAMPLES=OFF \ -DLLVM_INCLUDE_BENCHMARKS=OFF \ + -DLLVM_INCLUDE_TESTS=OFF \ -DLLVM_INSTALL_UTILS=ON \ -DLLVM_LINK_LLVM_DYLIB=ON \ "${common_cmake_args[@]}" \ @@ -297,6 +270,8 @@ check() { # Remove || true once testcase doesn't cause failures. # make check || true # make check-clang || true + ${MINGW_PREFIX}/bin/cmake.exe -DLLVM_INCLUDE_TESTS=ON ../llvm + ${MINGW_PREFIX}/bin/cmake.exe --build . ${MINGW_PREFIX}/bin/cmake.exe --build . -- check-lld || true } @@ -351,7 +326,7 @@ package_compiler-rt() { DESTDIR="${pkgdir}" cmake --install "${srcdir}/build-${MSYSTEM}/projects/compiler-rt" mkdir -p "${pkgdir}${MINGW_PREFIX}/bin/" - find "${pkgdir}${MINGW_PREFIX}/lib/clang/${_version}/lib/windows/" \ + find "${pkgdir}${MINGW_PREFIX}/lib/clang/${_version%.[0-9].*}/lib/windows/" \ -name '*.dll' -exec mv '{}' "${pkgdir}${MINGW_PREFIX}/bin/" \; # remove bin dir we created if it is still empty rmdir "${pkgdir}${MINGW_PREFIX}/bin/" 2>/dev/null || true diff --git a/mingw-w64-clang/README-patches.md b/mingw-w64-clang/README-patches.md index 97a276d0ff..29f9d81bc7 100644 --- a/mingw-w64-clang/README-patches.md +++ b/mingw-w64-clang/README-patches.md @@ -14,8 +14,6 @@ Legend: - `"0002-Revert-CMake-try-creating-symlink-first-on-windows.patch"` :x: (win symlinks don't play well with pacman packages) - `"0003-add-pthread-as-system-lib-for-mingw.patch"` :grey_exclamation: - `"0004-enable-emutls-for-mingw.patch"` :grey_exclamation: -- `"0005-export-out-of-tree-mlir-targets.patch"` :x: -- `"0008-COFF-Emit-embedded-exclude-symbols-directives-for-hi.patch"` :arrow_down_small: -- `"0009-Use-hidden-visibility-when-building-for-MinGW-with-Clang.patch"` :arrow_down_small: - `"0101-link-pthread-with-mingw.patch"` :grey_exclamation: +- `"0301-Add-exceptions-for-Flang-runtime-libraries-on-MinGW.patch"` :upstreamed: - `"0303-ignore-new-bfd-options.patch"` :x: