From c6873410cbd1d72cfcf7ec10e475090aac03d265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= Date: Fri, 30 Jun 2023 21:34:36 +0200 Subject: [PATCH 1/3] clang: sync with upstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update clang to 17.0.2-2 from Msys2 in preparation for building our own smaller clang for ARM64. Signed-off-by: Matthias Aßhauer --- ...GetHostTriple-for-mingw-w64-in-msys.patch} | 16 +- ...ngw-w64-use-MSVC-style-ByteAlignment.patch | 36 - .../0002-Fix-Findzstd-on-MINGW.patch | 16 + ...ly-provide-DESTDIR-for-all-platforms.patch | 27 - ...add-pthread-as-system-lib-for-mingw.patch} | 6 +- .../0004-enable-emutls-for-mingw.patch | 11 + ...-for-unversioned-shared-lib-on-win32.patch | 38 - mingw-w64-clang/0005-aarch64-unwind-seh.patch | 75 ++ ...006-fix-bugpoint-multiple-definition.patch | 9 - ...build-static-clang-library-for-mingw.patch | 25 - ...tch => 0101-link-pthread-with-mingw.patch} | 4 +- ...new-flang-experimental-exec-to-flang.patch | 34 + .../0102-fix-libclang-name-for-mingw.patch | 25 - ...-x86-arch-name-to-i686-for-mingw-w64.patch | 28 - .../0105-use-emulated-tls-with-mingw.patch | 26 - ...isibility-public-std-CC1-arg-to-get-.patch | 29 - ...0201-mingw-w64-__udivdi3-mangle-hack.patch | 30 - .../0202-compiler-rt-fix-mingw-build.patch | 25 - .../0303-ignore-new-bfd-options.patch | 11 + ...gw-w64-hack-and-slash-fixes-for-libc.patch | 34 - .../0501-fixes-to-get-lldb-building.patch | 172 ----- ...02-hack-to-use-64-bit-time-for-mingw.patch | 12 - ...-libunwind-add-support-for-mingw-w64.patch | 147 ---- .../0801-Don-t-build-LLVMPolly-on-WIN32.patch | 39 - mingw-w64-clang/PKGBUILD | 691 ++++++++---------- mingw-w64-clang/README-patches.md | 18 + 26 files changed, 477 insertions(+), 1107 deletions(-) rename mingw-w64-clang/{0002-Fix-GetHostTriple-for-mingw-w64-in-msys.patch => 0001-Fix-GetHostTriple-for-mingw-w64-in-msys.patch} (63%) delete mode 100644 mingw-w64-clang/0001-mingw-w64-use-MSVC-style-ByteAlignment.patch create mode 100644 mingw-w64-clang/0002-Fix-Findzstd-on-MINGW.patch delete mode 100644 mingw-w64-clang/0003-Globally-provide-DESTDIR-for-all-platforms.patch rename mingw-w64-clang/{0005-add-pthread-as-system-lib-for-mingw.patch => 0003-add-pthread-as-system-lib-for-mingw.patch} (79%) create mode 100644 mingw-w64-clang/0004-enable-emutls-for-mingw.patch delete mode 100644 mingw-w64-clang/0004-llvm-config-look-for-unversioned-shared-lib-on-win32.patch create mode 100644 mingw-w64-clang/0005-aarch64-unwind-seh.patch delete mode 100644 mingw-w64-clang/0006-fix-bugpoint-multiple-definition.patch delete mode 100644 mingw-w64-clang/0101-Allow-build-static-clang-library-for-mingw.patch rename mingw-w64-clang/{0104-link-pthread-with-mingw.patch => 0101-link-pthread-with-mingw.patch} (84%) create mode 100644 mingw-w64-clang/0102-Rename-flang-new-flang-experimental-exec-to-flang.patch delete mode 100644 mingw-w64-clang/0102-fix-libclang-name-for-mingw.patch delete mode 100644 mingw-w64-clang/0103-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch delete mode 100644 mingw-w64-clang/0105-use-emulated-tls-with-mingw.patch delete mode 100644 mingw-w64-clang/0106-MinGW-use-flto-visibility-public-std-CC1-arg-to-get-.patch delete mode 100644 mingw-w64-clang/0201-mingw-w64-__udivdi3-mangle-hack.patch delete mode 100644 mingw-w64-clang/0202-compiler-rt-fix-mingw-build.patch create mode 100644 mingw-w64-clang/0303-ignore-new-bfd-options.patch delete mode 100644 mingw-w64-clang/0401-mingw-w64-hack-and-slash-fixes-for-libc.patch delete mode 100644 mingw-w64-clang/0501-fixes-to-get-lldb-building.patch delete mode 100644 mingw-w64-clang/0502-hack-to-use-64-bit-time-for-mingw.patch delete mode 100644 mingw-w64-clang/0601-libunwind-add-support-for-mingw-w64.patch delete mode 100644 mingw-w64-clang/0801-Don-t-build-LLVMPolly-on-WIN32.patch create mode 100644 mingw-w64-clang/README-patches.md diff --git a/mingw-w64-clang/0002-Fix-GetHostTriple-for-mingw-w64-in-msys.patch b/mingw-w64-clang/0001-Fix-GetHostTriple-for-mingw-w64-in-msys.patch similarity index 63% rename from mingw-w64-clang/0002-Fix-GetHostTriple-for-mingw-w64-in-msys.patch rename to mingw-w64-clang/0001-Fix-GetHostTriple-for-mingw-w64-in-msys.patch index 90da3552db667..be63c8f6a959d 100644 --- a/mingw-w64-clang/0002-Fix-GetHostTriple-for-mingw-w64-in-msys.patch +++ b/mingw-w64-clang/0001-Fix-GetHostTriple-for-mingw-w64-in-msys.patch @@ -11,20 +11,14 @@ diff --git a/cmake/modules/GetHostTriple.cmake b/cmake/modules/GetHostTriple.cma index 0cad1db4eff..47e9f986e15 100644 --- a/cmake/modules/GetHostTriple.cmake +++ b/cmake/modules/GetHostTriple.cmake -@@ -8,11 +8,11 @@ function( get_host_triple var ) +@@ -16,7 +16,7 @@ else() - set( value "i686-pc-win32" ) + set( value "i686-pc-windows-msvc" ) endif() - elseif( MINGW AND NOT MSYS ) + elseif( MINGW ) - if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) - set( value "x86_64-w64-mingw32" ) - else() -- set( value "i686-pc-mingw32" ) -+ set( value "i686-w64-mingw32" ) - endif() - else( MSVC ) - set(config_guess ${LLVM_MAIN_SRC_DIR}/cmake/config.guess) --- + # CMake doesn't provide COMPILER_ARCHITECTURE_ID for Clang/GCC, + # but it does for MSVC. + if( CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "ARM.*" ) 2.13.3 diff --git a/mingw-w64-clang/0001-mingw-w64-use-MSVC-style-ByteAlignment.patch b/mingw-w64-clang/0001-mingw-w64-use-MSVC-style-ByteAlignment.patch deleted file mode 100644 index 058faba144892..0000000000000 --- a/mingw-w64-clang/0001-mingw-w64-use-MSVC-style-ByteAlignment.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 6832b520f918211609cb0b6ee427e922720d4803 Mon Sep 17 00:00:00 2001 -From: Martell Malone -Date: Tue, 16 Aug 2016 12:55:01 -0700 -Subject: [PATCH 1/5] mingw-w64: use MSVC style ByteAlignment - -We can do alignment without -aligncomm derectives in PE COFF -Until we support GNU style in lld we should use this ---- - lib/MC/MCWinCOFFStreamer.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/lib/MC/MCWinCOFFStreamer.cpp b/lib/MC/MCWinCOFFStreamer.cpp -index bf341bb1f45..3b3fecfc1d7 100644 ---- a/lib/MC/MCWinCOFFStreamer.cpp -+++ b/lib/MC/MCWinCOFFStreamer.cpp -@@ -222,7 +222,7 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size, - auto *Symbol = cast(S); - - const Triple &T = getContext().getObjectFileInfo()->getTargetTriple(); -- if (T.isKnownWindowsMSVCEnvironment()) { -+ if (T.getEnvironment() != Triple::Cygnus) { - if (ByteAlignment > 32) - report_fatal_error("alignment is limited to 32-bytes"); - -@@ -234,7 +234,7 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size, - Symbol->setExternal(true); - Symbol->setCommon(Size, ByteAlignment); - -- if (!T.isKnownWindowsMSVCEnvironment() && ByteAlignment > 1) { -+ if (T.getEnvironment() == Triple::Cygnus && ByteAlignment > 1) { - SmallString<128> Directive; - raw_svector_ostream OS(Directive); - const MCObjectFileInfo *MFI = getContext().getObjectFileInfo(); --- -2.13.3 - diff --git a/mingw-w64-clang/0002-Fix-Findzstd-on-MINGW.patch b/mingw-w64-clang/0002-Fix-Findzstd-on-MINGW.patch new file mode 100644 index 0000000000000..108fb0e6a2ef6 --- /dev/null +++ b/mingw-w64-clang/0002-Fix-Findzstd-on-MINGW.patch @@ -0,0 +1,16 @@ +--- a/cmake/modules/Findzstd.cmake ++++ b/cmake/modules/Findzstd.cmake +@@ -29,11 +29,11 @@ + ) + + if(zstd_FOUND) +- if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$") ++ if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$" AND NOT MINGW) + set(zstd_STATIC_LIBRARY "${zstd_LIBRARY}") + elseif (NOT TARGET zstd::libzstd_shared) + add_library(zstd::libzstd_shared SHARED IMPORTED) +- if(MSVC) ++ 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}") diff --git a/mingw-w64-clang/0003-Globally-provide-DESTDIR-for-all-platforms.patch b/mingw-w64-clang/0003-Globally-provide-DESTDIR-for-all-platforms.patch deleted file mode 100644 index 71be66a3fb564..0000000000000 --- a/mingw-w64-clang/0003-Globally-provide-DESTDIR-for-all-platforms.patch +++ /dev/null @@ -1,27 +0,0 @@ -From f4cea343d6e61f388de78241e89b1032ff11b0c7 Mon Sep 17 00:00:00 2001 -From: Alexey Pavlov -Date: Fri, 25 Dec 2015 20:14:51 +0100 -Subject: [PATCH 3/5] Globally provide DESTDIR for all platforms - ---- - cmake/modules/LLVMInstallSymlink.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/cmake/modules/LLVMInstallSymlink.cmake b/cmake/modules/LLVMInstallSymlink.cmake -index 482697b06ba..61c4b9dea80 100644 ---- a/cmake/modules/LLVMInstallSymlink.cmake -+++ b/cmake/modules/LLVMInstallSymlink.cmake -@@ -3,9 +3,9 @@ - # See PR8397. - - function(install_symlink name target outdir) -+set(DESTDIR $ENV{DESTDIR}) - if(UNIX) - set(LINK_OR_COPY create_symlink) -- set(DESTDIR $ENV{DESTDIR}) - else() - set(LINK_OR_COPY copy) - endif() --- -2.13.3 - diff --git a/mingw-w64-clang/0005-add-pthread-as-system-lib-for-mingw.patch b/mingw-w64-clang/0003-add-pthread-as-system-lib-for-mingw.patch similarity index 79% rename from mingw-w64-clang/0005-add-pthread-as-system-lib-for-mingw.patch rename to mingw-w64-clang/0003-add-pthread-as-system-lib-for-mingw.patch index 33bb94a050373..1d8792100b967 100644 --- a/mingw-w64-clang/0005-add-pthread-as-system-lib-for-mingw.patch +++ b/mingw-w64-clang/0003-add-pthread-as-system-lib-for-mingw.patch @@ -11,10 +11,10 @@ diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt index 0a8e3897cce..de9cda5dda3 100644 --- a/lib/Support/CMakeLists.txt +++ b/lib/Support/CMakeLists.txt -@@ -2,6 +2,9 @@ set(system_libs) - if( MSVC OR MINGW ) +@@ -6,6 +6,9 @@ set(system_libs) # libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc. - set(system_libs ${system_libs} psapi shell32 ole32 uuid) + # advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc. + set(system_libs ${system_libs} psapi shell32 ole32 uuid advapi32) + if( MINGW ) + set(system_libs ${system_libs} pthread) + endif() diff --git a/mingw-w64-clang/0004-enable-emutls-for-mingw.patch b/mingw-w64-clang/0004-enable-emutls-for-mingw.patch new file mode 100644 index 0000000000000..8d89613fa93e7 --- /dev/null +++ b/mingw-w64-clang/0004-enable-emutls-for-mingw.patch @@ -0,0 +1,11 @@ +--- a/include/llvm/TargetParser/Triple.h ++++ b/include/llvm/TargetParser/Triple.h +@@ -993,7 +993,7 @@ + /// Note: Android API level 29 (10) introduced ELF TLS. + bool hasDefaultEmulatedTLS() const { + return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() || +- isWindowsCygwinEnvironment() || isOHOSFamily(); ++ isOSCygMing() || isOHOSFamily(); + } + + /// Tests whether the target uses -data-sections as default. diff --git a/mingw-w64-clang/0004-llvm-config-look-for-unversioned-shared-lib-on-win32.patch b/mingw-w64-clang/0004-llvm-config-look-for-unversioned-shared-lib-on-win32.patch deleted file mode 100644 index 3edd842032dff..0000000000000 --- a/mingw-w64-clang/0004-llvm-config-look-for-unversioned-shared-lib-on-win32.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 56c0371a3cbc98ef5dc039324ad43c153ff601c4 Mon Sep 17 00:00:00 2001 -From: Mateusz Mikula -Date: Thu, 2 Feb 2017 11:48:25 +0100 -Subject: [PATCH 4/5] llvm-config: look for unversioned shared lib on win32 - ---- - tools/llvm-config/llvm-config.cpp | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp -index 08b096afb05..e388d9e5d3f 100644 ---- a/tools/llvm-config/llvm-config.cpp -+++ b/tools/llvm-config/llvm-config.cpp -@@ -353,7 +353,7 @@ int main(int argc, char **argv) { - const Triple HostTriple(Triple::normalize(LLVM_HOST_TRIPLE)); - if (HostTriple.isOSWindows()) { - SharedExt = "dll"; -- SharedVersionedExt = LLVM_DYLIB_VERSION ".dll"; -+ SharedVersionedExt = ".dll"; - if (HostTriple.isOSCygMing()) { - StaticExt = "a"; - StaticPrefix = "lib"; -@@ -391,8 +391,10 @@ int main(int argc, char **argv) { - const bool BuiltSharedLibs = !!LLVM_ENABLE_SHARED; - - bool DyLibExists = false; -- const std::string DyLibName = -- (SharedPrefix + "LLVM-" + SharedVersionedExt).str(); -+ const std::string DyLibName = -+ (SharedPrefix + (HostTriple.isOSWindows() ? "LLVM" : "LLVM-") + -+ SharedVersionedExt) -+ .str(); - - // If LLVM_LINK_DYLIB is ON, the single shared library will be returned - // for "--libs", etc, if they exist. This behaviour can be overridden with --- -2.13.3 - diff --git a/mingw-w64-clang/0005-aarch64-unwind-seh.patch b/mingw-w64-clang/0005-aarch64-unwind-seh.patch new file mode 100644 index 0000000000000..ff4385cd3a52b --- /dev/null +++ b/mingw-w64-clang/0005-aarch64-unwind-seh.patch @@ -0,0 +1,75 @@ +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/0006-fix-bugpoint-multiple-definition.patch b/mingw-w64-clang/0006-fix-bugpoint-multiple-definition.patch deleted file mode 100644 index 677179585b6d4..0000000000000 --- a/mingw-w64-clang/0006-fix-bugpoint-multiple-definition.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- llvm-5.0.0.src/tools/bugpoint/CMakeLists.txt.orig 2017-09-08 22:16:39.035644100 +0200 -+++ llvm-5.0.0.src/tools/bugpoint/CMakeLists.txt 2017-09-14 13:26:53.811311200 +0200 -@@ -38,6 +38,4 @@ - - if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS) - target_link_libraries(bugpoint Polly) -- # Ensure LLVMTarget can resolve dependences in Polly. -- target_link_libraries(bugpoint LLVMTarget) - endif(WITH_POLLY AND LINK_POLLY_INTO_TOOLS) diff --git a/mingw-w64-clang/0101-Allow-build-static-clang-library-for-mingw.patch b/mingw-w64-clang/0101-Allow-build-static-clang-library-for-mingw.patch deleted file mode 100644 index 7ce50e93ff717..0000000000000 --- a/mingw-w64-clang/0101-Allow-build-static-clang-library-for-mingw.patch +++ /dev/null @@ -1,25 +0,0 @@ -From ded1b370c6ccbb427406edc6ab39656144d61818 Mon Sep 17 00:00:00 2001 -From: Alexey Pavlov -Date: Fri, 25 Dec 2015 20:14:51 +0100 -Subject: [PATCH 1/6] Allow build static clang library for mingw - ---- - tools/libclang/CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt -index 2dd6703076..477e53dd15 100644 ---- a/tools/libclang/CMakeLists.txt -+++ b/tools/libclang/CMakeLists.txt -@@ -74,7 +74,7 @@ if( LLVM_ENABLE_PIC ) - set(ENABLE_SHARED SHARED) - endif() - --if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32) -+if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND (NOT MSVC)) - set(ENABLE_STATIC STATIC) - endif() - --- -2.14.1 - diff --git a/mingw-w64-clang/0104-link-pthread-with-mingw.patch b/mingw-w64-clang/0101-link-pthread-with-mingw.patch similarity index 84% rename from mingw-w64-clang/0104-link-pthread-with-mingw.patch rename to mingw-w64-clang/0101-link-pthread-with-mingw.patch index 086e3028a6f11..3fdfc0fc0d4dd 100644 --- a/mingw-w64-clang/0104-link-pthread-with-mingw.patch +++ b/mingw-w64-clang/0101-link-pthread-with-mingw.patch @@ -11,7 +11,7 @@ diff --git a/lib/Driver/ToolChains/MinGW.cpp b/lib/Driver/ToolChains/MinGW.cpp index 632b76d92b..23da2d6376 100644 --- a/lib/Driver/ToolChains/MinGW.cpp +++ b/lib/Driver/ToolChains/MinGW.cpp -@@ -215,7 +215,7 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, +@@ -265,7 +265,7 @@ if (Args.hasArg(options::OPT_pg)) CmdArgs.push_back("-lgmon"); @@ -19,7 +19,7 @@ index 632b76d92b..23da2d6376 100644 + if (!Args.hasArg(options::OPT_no_pthread)) CmdArgs.push_back("-lpthread"); - // add system libraries + if (Sanitize.needsAsanRt()) { -- 2.14.1 diff --git a/mingw-w64-clang/0102-Rename-flang-new-flang-experimental-exec-to-flang.patch b/mingw-w64-clang/0102-Rename-flang-new-flang-experimental-exec-to-flang.patch new file mode 100644 index 0000000000000..eef281b510555 --- /dev/null +++ b/mingw-w64-clang/0102-Rename-flang-new-flang-experimental-exec-to-flang.patch @@ -0,0 +1,34 @@ +Index: clang/lib/Driver/Driver.cpp +=================================================================== +--- clang/lib/Driver/Driver.cpp ++++ clang/lib/Driver/Driver.cpp +@@ -1936,7 +1936,7 @@ + + void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const { + if (IsFlangMode()) { +- OS << getClangToolFullVersion("flang-new") << '\n'; ++ OS << getClangToolFullVersion("flang") << '\n'; + } else { + // FIXME: The following handlers should use a callback mechanism, we don't + // know what the client would like to do. +Index: clang/lib/Driver/ToolChains/Flang.cpp +=================================================================== +--- clang/lib/Driver/ToolChains/Flang.cpp ++++ clang/lib/Driver/ToolChains/Flang.cpp +@@ -409,14 +409,12 @@ + + CmdArgs.push_back(Input.getFilename()); + +- // TODO: Replace flang-new with flang once the new driver replaces the +- // throwaway driver +- const char *Exec = Args.MakeArgString(D.GetProgramPath("flang-new", TC)); ++ const char *Exec = Args.MakeArgString(D.GetProgramPath("flang", TC)); + C.addCommand(std::make_unique(JA, *this, + ResponseFileSupport::AtFileUTF8(), + Exec, CmdArgs, Inputs, Output)); + } + +-Flang::Flang(const ToolChain &TC) : Tool("flang-new", "flang frontend", TC) {} ++Flang::Flang(const ToolChain &TC) : Tool("flang", "flang frontend", TC) {} + + Flang::~Flang() {} diff --git a/mingw-w64-clang/0102-fix-libclang-name-for-mingw.patch b/mingw-w64-clang/0102-fix-libclang-name-for-mingw.patch deleted file mode 100644 index ba0c324d27ed6..0000000000000 --- a/mingw-w64-clang/0102-fix-libclang-name-for-mingw.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 4fea4f3cc0f23cc4aacc727cff812303a63a83b5 Mon Sep 17 00:00:00 2001 -From: Mateusz Mikula -Date: Thu, 2 Feb 2017 12:21:45 +0100 -Subject: [PATCH 2/6] fix libclang name for mingw - ---- - tools/libclang/CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt -index 477e53dd15..dc2e3538fa 100644 ---- a/tools/libclang/CMakeLists.txt -+++ b/tools/libclang/CMakeLists.txt -@@ -78,7 +78,7 @@ if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND (NOT MSVC)) - set(ENABLE_STATIC STATIC) - endif() - --if(WIN32) -+if(MSVC) - set(output_name "libclang") - else() - set(output_name "clang") --- -2.14.1 - diff --git a/mingw-w64-clang/0103-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch b/mingw-w64-clang/0103-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch deleted file mode 100644 index 6db65f4e43e45..0000000000000 --- a/mingw-w64-clang/0103-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 5042e15216190f11cfb12f0c81c187c7353fb1d5 Mon Sep 17 00:00:00 2001 -From: Martell Malone -Date: Sun, 28 Jun 2015 19:12:19 +0100 -Subject: [PATCH 3/6] Set the x86 arch name to i686 for mingw-w64 - ---- - lib/Driver/Driver.cpp | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp -index ba4d0e836b..9f8c850b22 100644 ---- a/lib/Driver/Driver.cpp -+++ b/lib/Driver/Driver.cpp -@@ -429,6 +429,11 @@ static llvm::Triple computeTargetTriple(const Driver &D, - - if (AT != llvm::Triple::UnknownArch && AT != Target.getArch()) - Target.setArch(AT); -+ -+ // Override the default ArchName of 'i386' for mingw-w64 targets when passed -m32. -+ if (AT == llvm::Triple::x86 && Target.isWindowsGNUEnvironment() && -+ Target.getVendorName().equals(StringRef("w64"))) -+ Target.setArchName(StringRef("i686")); - } - - // Handle -miamcu flag. --- -2.14.1 - diff --git a/mingw-w64-clang/0105-use-emulated-tls-with-mingw.patch b/mingw-w64-clang/0105-use-emulated-tls-with-mingw.patch deleted file mode 100644 index 9772aa0469a91..0000000000000 --- a/mingw-w64-clang/0105-use-emulated-tls-with-mingw.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 89e43bd7141cc12f6b4eca71b549d6b2eb6030c0 Mon Sep 17 00:00:00 2001 -From: Mateusz Mikula -Date: Wed, 1 Mar 2017 19:56:37 +0100 -Subject: [PATCH 5/6] use emulated tls with mingw - ---- - lib/Driver/ToolChains/Clang.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp -index 6a6b90f868..f7967fe79b 100644 ---- a/lib/Driver/ToolChains/Clang.cpp -+++ b/lib/Driver/ToolChains/Clang.cpp -@@ -3207,7 +3207,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, - // Emulated TLS is enabled by default on Android and OpenBSD, and can be enabled - // manually with -femulated-tls. - bool EmulatedTLSDefault = Triple.isAndroid() || Triple.isOSOpenBSD() || -- Triple.isWindowsCygwinEnvironment(); -+ Triple.isWindowsCygwinEnvironment() || -+ Triple.isWindowsGNUEnvironment(); - if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls, - EmulatedTLSDefault)) - CmdArgs.push_back("-femulated-tls"); --- -2.14.1 - diff --git a/mingw-w64-clang/0106-MinGW-use-flto-visibility-public-std-CC1-arg-to-get-.patch b/mingw-w64-clang/0106-MinGW-use-flto-visibility-public-std-CC1-arg-to-get-.patch deleted file mode 100644 index fa141eca75274..0000000000000 --- a/mingw-w64-clang/0106-MinGW-use-flto-visibility-public-std-CC1-arg-to-get-.patch +++ /dev/null @@ -1,29 +0,0 @@ -From a719447157a7cb8746f0779dc1fa5e3de56b86ee Mon Sep 17 00:00:00 2001 -From: Mateusz Mikula -Date: Mon, 18 Sep 2017 12:25:11 +0200 -Subject: [PATCH 6/6] MinGW: use -flto-visibility-public-std CC1 arg to get rid - of undefined reference to _imp___cxa* errors - ---- - lib/Driver/ToolChains/Clang.cpp | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp -index f7967fe79b..46e7998a72 100644 ---- a/lib/Driver/ToolChains/Clang.cpp -+++ b/lib/Driver/ToolChains/Clang.cpp -@@ -3200,6 +3200,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, - IsHosted = false; - } - -+ if (Triple.isWindowsGNUEnvironment() && -+ Args.hasArg(options::OPT_static) && -+ getToolChain().GetCXXStdlibType(Args) == ToolChain::CST_Libstdcxx) -+ CmdArgs.push_back("-flto-visibility-public-std"); -+ - // Forward -f (flag) options which we can pass directly. - Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls); - Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions); --- -2.14.1 - diff --git a/mingw-w64-clang/0201-mingw-w64-__udivdi3-mangle-hack.patch b/mingw-w64-clang/0201-mingw-w64-__udivdi3-mangle-hack.patch deleted file mode 100644 index 450308d24267c..0000000000000 --- a/mingw-w64-clang/0201-mingw-w64-__udivdi3-mangle-hack.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 9a4406ce9d21da7042974c049f3715e1a1e606fb Mon Sep 17 00:00:00 2001 -From: Martell Malone -Date: Tue, 16 Aug 2016 16:00:52 -0700 -Subject: [PATCH 1/2] mingw-w64: __udivdi3 mangle hack - ---- - lib/builtins/udivdi3.c | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/lib/builtins/udivdi3.c b/lib/builtins/udivdi3.c -index dc68e154b..4c616fde2 100644 ---- a/lib/builtins/udivdi3.c -+++ b/lib/builtins/udivdi3.c -@@ -17,7 +17,12 @@ - /* Returns: a / b */ - - COMPILER_RT_ABI du_int --__udivdi3(du_int a, du_int b) -+#if defined (__MINGW32__) && !defined(_WIN64) -+___udivdi3 -+#else -+__udivdi3 -+#endif -+(du_int a, du_int b) - { - return __udivmoddi4(a, b, 0); - } --- -2.14.1.windows.1 - diff --git a/mingw-w64-clang/0202-compiler-rt-fix-mingw-build.patch b/mingw-w64-clang/0202-compiler-rt-fix-mingw-build.patch deleted file mode 100644 index 547600a0d29de..0000000000000 --- a/mingw-w64-clang/0202-compiler-rt-fix-mingw-build.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 056e6d2e8010dbf7777fa6d5d88496c1f9a49100 Mon Sep 17 00:00:00 2001 -From: Mateusz Mikula -Date: Wed, 15 Feb 2017 19:21:48 +0100 -Subject: [PATCH 2/2] compiler-rt: fix mingw build - ---- - lib/profile/InstrProfilingPort.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/profile/InstrProfilingPort.h b/lib/profile/InstrProfilingPort.h -index 578935195..3bda151ad 100644 ---- a/lib/profile/InstrProfilingPort.h -+++ b/lib/profile/InstrProfilingPort.h -@@ -44,7 +44,7 @@ - #define COMPILER_RT_GETHOSTNAME(Name, Len) ((void)(Name), (void)(Len), (-1)) - #else - #define COMPILER_RT_GETHOSTNAME(Name, Len) lprofGetHostName(Name, Len) --#ifndef _MSC_VER -+#ifndef _WIN32 - #define COMPILER_RT_HAS_UNAME 1 - #endif - #endif --- -2.14.1.windows.1 - diff --git a/mingw-w64-clang/0303-ignore-new-bfd-options.patch b/mingw-w64-clang/0303-ignore-new-bfd-options.patch new file mode 100644 index 0000000000000..39ec520b3becd --- /dev/null +++ b/mingw-w64-clang/0303-ignore-new-bfd-options.patch @@ -0,0 +1,11 @@ +--- a/MinGW/Options.td ++++ b/MinGW/Options.td +@@ -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">; + def: F<"disable-auto-image-base">; + def: F<"enable-auto-image-base">; + def: F<"end-group">; diff --git a/mingw-w64-clang/0401-mingw-w64-hack-and-slash-fixes-for-libc.patch b/mingw-w64-clang/0401-mingw-w64-hack-and-slash-fixes-for-libc.patch deleted file mode 100644 index 5afce7be741a0..0000000000000 --- a/mingw-w64-clang/0401-mingw-w64-hack-and-slash-fixes-for-libc.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 5ad3d8c960e46a85e6fa3ec457dafdd53394ef77 Mon Sep 17 00:00:00 2001 -From: Mateusz Mikula -Date: Mon, 20 Mar 2017 18:33:53 +0100 -Subject: [PATCH] workarounds to build libc++ with MinGW - -Based on Martell's patches ---- - src/support/win32/support.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/support/win32/support.cpp b/src/support/win32/support.cpp -index dbd1c4c41..fa8cabd65 100644 ---- a/src/support/win32/support.cpp -+++ b/src/support/win32/support.cpp -@@ -15,7 +15,7 @@ - #include // strcpy, wcsncpy - #include // mbstate_t - -- -+#ifndef __MINGW64_VERSION_MAJOR - // Like sprintf, but when return value >= 0 it returns - // a pointer to a malloc'd string in *sptr. - // If return >= 0, use free to delete *sptr. -@@ -40,6 +40,7 @@ int vasprintf( char **sptr, const char *__restrict format, va_list ap ) - *sptr = p; - return count; - } -+#endif - - // Returns >= 0: the number of wide characters found in the - // multi byte sequence src (of src_size_bytes), that fit in the buffer dst --- -2.14.1.windows.1 - diff --git a/mingw-w64-clang/0501-fixes-to-get-lldb-building.patch b/mingw-w64-clang/0501-fixes-to-get-lldb-building.patch deleted file mode 100644 index 42dce581e2006..0000000000000 --- a/mingw-w64-clang/0501-fixes-to-get-lldb-building.patch +++ /dev/null @@ -1,172 +0,0 @@ -From b8a3387eee86d609b18ac880e7897252de62a0c5 Mon Sep 17 00:00:00 2001 -From: Mateusz Mikula -Date: Fri, 15 Sep 2017 15:03:12 +0200 -Subject: [PATCH] fixes to get lldb building - ---- - cmake/LLDBDependencies.cmake | 6 ++++++ - include/lldb/Host/windows/PosixApi.h | 14 ++++++++++---- - include/lldb/Host/windows/windows.h | 4 ++++ - source/Host/common/MainLoop.cpp | 1 + - source/Host/windows/Windows.cpp | 3 +++ - .../gdb-remote/GDBRemoteCommunicationServerPlatform.cpp | 1 + - source/Plugins/Process/gdb-remote/ProcessGDBRemote.h | 1 + - tools/lldb-mi/MIDataTypes.h | 2 ++ - tools/lldb-mi/Platform.h | 4 ++++ - 9 files changed, 32 insertions(+), 4 deletions(-) - -diff --git a/cmake/LLDBDependencies.cmake b/cmake/LLDBDependencies.cmake -index 55ce379..ae65ebe 100644 ---- a/cmake/LLDBDependencies.cmake -+++ b/cmake/LLDBDependencies.cmake -@@ -6,6 +6,12 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) - ws2_32 - rpcrt4 - ) -+ if (MINGW) -+ list(APPEND LLDB_SYSTEM_LIBS -+ dbghelp -+ psapi -+ ) -+ endif () - endif () - - if (NOT LLDB_DISABLE_LIBEDIT) -diff --git a/include/lldb/Host/windows/PosixApi.h b/include/lldb/Host/windows/PosixApi.h -index de70266..51fba95 100644 ---- a/include/lldb/Host/windows/PosixApi.h -+++ b/include/lldb/Host/windows/PosixApi.h -@@ -73,13 +73,9 @@ typedef uint32_t pid_t; - #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) - #endif - --#endif // _MSC_VER -- - // Various useful posix functions that are not present in Windows. We provide - // custom implementations. - int vasprintf(char **ret, const char *fmt, va_list ap); --char *strcasestr(const char *s, const char *find); --char *realpath(const char *name, char *resolved); - - int usleep(uint32_t useconds); - char *basename(char *path); -@@ -88,6 +84,16 @@ char *dirname(char *path); - int strcasecmp(const char *s1, const char *s2); - int strncasecmp(const char *s1, const char *s2, size_t n); - -+#elif __MINGW64_VERSION_MAJOR -+ -+// pid_t definition -+#include -+ -+#endif -+ -+char *strcasestr(const char *s, const char *find); -+char *realpath(const char *name, char *resolved); -+ - // empty functions - inline int posix_openpt(int flag) { LLVM_BUILTIN_UNREACHABLE; } - -diff --git a/include/lldb/Host/windows/windows.h b/include/lldb/Host/windows/windows.h -index 3dc9f77..ca138c1 100644 ---- a/include/lldb/Host/windows/windows.h -+++ b/include/lldb/Host/windows/windows.h -@@ -28,4 +28,8 @@ - #define FAR - #define NEAR - -+#ifndef _MSC_VER -+#include -+#endif -+ - #endif // LLDB_lldb_windows_h_ -diff --git a/source/Host/common/MainLoop.cpp b/source/Host/common/MainLoop.cpp -index d0e0d00..cd1d4a8 100644 ---- a/source/Host/common/MainLoop.cpp -+++ b/source/Host/common/MainLoop.cpp -@@ -27,6 +27,7 @@ - #if HAVE_SYS_EVENT_H - #include - #elif defined(LLVM_ON_WIN32) -+#include "lldb/Host/windows/windows.h" - #include - #else - #include -diff --git a/source/Host/windows/Windows.cpp b/source/Host/windows/Windows.cpp -index 9d0e70e..aaf06b0 100644 ---- a/source/Host/windows/Windows.cpp -+++ b/source/Host/windows/Windows.cpp -@@ -43,6 +43,8 @@ bool wideToUtf8(const wchar_t *wide, char *buf, size_t bufSize) { - } - } - -+#ifdef _MSC_VER -+ - int vasprintf(char **ret, const char *fmt, va_list ap) { - char *buf; - int len; -@@ -69,6 +71,7 @@ int vasprintf(char **ret, const char *fmt, va_list ap) { - va_end(ap2); - return len; - } -+#endif - - char *strcasestr(const char *s, const char *find) { - char c, sc; -diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp -index 977c34c..9bec1d8 100644 ---- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp -+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp -@@ -12,6 +12,7 @@ - #include - - // C Includes -+#include - // C++ Includes - #include - #include -diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h -index 54a472d..196e012 100644 ---- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h -+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h -@@ -11,6 +11,7 @@ - #define liblldb_ProcessGDBRemote_h_ - - // C Includes -+#include - // C++ Includes - #include - #include -diff --git a/tools/lldb-mi/MIDataTypes.h b/tools/lldb-mi/MIDataTypes.h -index 34fe457..8372e8c 100644 ---- a/tools/lldb-mi/MIDataTypes.h -+++ b/tools/lldb-mi/MIDataTypes.h -@@ -19,6 +19,8 @@ - // Windows headers: - #ifdef _WIN32 - -+#include -+ - // Debugging: - #ifdef _DEBUG - #include // C-runtime debugging library (defines _ASSERT). -diff --git a/tools/lldb-mi/Platform.h b/tools/lldb-mi/Platform.h -index ce2de1b..d334d75 100644 ---- a/tools/lldb-mi/Platform.h -+++ b/tools/lldb-mi/Platform.h -@@ -78,8 +78,12 @@ typedef void (*sighandler_t)(int); - - #include - #include -+ -+#ifndef __MINGW64_VERSION_MAJOR - #include - #include -+#endif -+ - #include - - #include --- -2.14.1.windows.1 - diff --git a/mingw-w64-clang/0502-hack-to-use-64-bit-time-for-mingw.patch b/mingw-w64-clang/0502-hack-to-use-64-bit-time-for-mingw.patch deleted file mode 100644 index 3c161a65ceeb0..0000000000000 --- a/mingw-w64-clang/0502-hack-to-use-64-bit-time-for-mingw.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -urN lldb-3.9.0.src.orig/source/Host/windows/FileSystem.cpp lldb-3.9.0.src/source/Host/windows/FileSystem.cpp ---- lldb-3.9.0.src.orig/source/Host/windows/FileSystem.cpp 2016-03-22 18:58:09.000000000 +0100 -+++ lldb-3.9.0.src/source/Host/windows/FileSystem.cpp 2016-11-10 01:55:34.663530600 +0100 -@@ -276,7 +276,7 @@ - return -EINVAL; - } - int stat_result; --#ifdef _USE_32BIT_TIME_T -+#if defined(_USE_32BIT_TIME_T) && !defined(__MINGW64_VERSION_MAJOR) - struct _stat32 file_stats; - stat_result = ::_wstat32(wpath.c_str(), &file_stats); - #else \ No newline at end of file diff --git a/mingw-w64-clang/0601-libunwind-add-support-for-mingw-w64.patch b/mingw-w64-clang/0601-libunwind-add-support-for-mingw-w64.patch deleted file mode 100644 index 0a89339ccbeb0..0000000000000 --- a/mingw-w64-clang/0601-libunwind-add-support-for-mingw-w64.patch +++ /dev/null @@ -1,147 +0,0 @@ -From 8d0335a3e369eca60ff53c5a6a0936aafcaaf13b Mon Sep 17 00:00:00 2001 -From: Mateusz Mikula -Date: Fri, 17 Mar 2017 21:20:49 +0100 -Subject: [PATCH] libunwind add support for mingw-w64 - ---- - cmake/config-ix.cmake | 13 +++++++++++++ - include/unwind.h | 2 +- - src/AddressSpace.hpp | 10 ++++++---- - src/assembly.h | 2 ++ - src/config.h | 10 ++++++++-- - 5 files changed, 30 insertions(+), 7 deletions(-) - -diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake -index 40a5dd1..e2041af 100644 ---- a/cmake/config-ix.cmake -+++ b/cmake/config-ix.cmake -@@ -29,6 +29,19 @@ if (LIBUNWIND_HAS_NODEFAULTLIBS_FLAG) - elseif (LIBUNWIND_HAS_GCC_S_LIB) - list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s) - endif () -+ if (MINGW) -+ # Mingw64 requires quite a few "C" runtime libraries in order for basic -+ # programs to link successfully with -nodefaultlibs. -+ if (LIBUNWIND_USE_COMPILER_RT) -+ set(MINGW_RUNTIME ${LIBUNWIND_BUILTINS_LIBRARY}) -+ else () -+ set(MINGW_RUNTIME gcc_s gcc) -+ endif() -+ set(MINGW_LIBRARIES mingw32 ${MINGW_RUNTIME} moldname mingwex msvcrt advapi32 -+ shell32 user32 kernel32 mingw32 ${MINGW_RUNTIME} -+ moldname mingwex msvcrt) -+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES}) -+ endif() - if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all") - endif () -diff --git a/include/unwind.h b/include/unwind.h -index fc7d122..db10654 100644 ---- a/include/unwind.h -+++ b/include/unwind.h -@@ -122,7 +122,7 @@ struct _Unwind_Exception { - _Unwind_Exception *exc); - uintptr_t private_1; // non-zero means forced unwind - uintptr_t private_2; // holds sp that phase1 found for phase2 to use --#ifndef __LP64__ -+#if !defined(__LP64__) && !defined(_WIN64) - // The implementation of _Unwind_Exception uses an attribute mode on the - // above fields which has the side effect of causing this whole struct to - // round up to 32 bytes in size. To be more explicit, we add pad fields -diff --git a/src/AddressSpace.hpp b/src/AddressSpace.hpp -index 2ed52a5..b18851f 100644 ---- a/src/AddressSpace.hpp -+++ b/src/AddressSpace.hpp -@@ -18,7 +18,7 @@ - #include - #include - --#ifndef _LIBUNWIND_IS_BAREMETAL -+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32) - #include - #endif - -@@ -68,7 +68,7 @@ struct UnwindInfoSections { - /// making local unwinds fast. - class __attribute__((visibility("hidden"))) LocalAddressSpace { - public: --#ifdef __LP64__ -+#if defined(__LP64__) || defined(_WIN64) - typedef uint64_t pint_t; - typedef int64_t sint_t; - #else -@@ -290,7 +290,7 @@ LocalAddressSpace::getEncodedP(pint_t &addr, pint_t end, uint8_t encoding, - Dl_info dlinfo; - if (!dladdr(addr, &dlinfo)) - return false; --#if __LP64__ -+#if defined(__LP64__) || defined(_WIN64) - const struct mach_header_64 *mh = (const struct mach_header_64 *)dlinfo.dli_fbase; - #else - const struct mach_header *mh = (const struct mach_header *)dlinfo.dli_fbase; -@@ -327,7 +327,9 @@ extern char __exidx_end; - // independent ELF header traversal is not provided by on some - // systems (e.g., FreeBSD). On these systems the data structures are - // just called Elf_XXX. Define ElfW() locally. -+#ifndef _WIN32 - #include -+#endif - #if !defined(ElfW) - #define ElfW(type) Elf_##type - #endif -@@ -478,7 +480,7 @@ inline bool LocalAddressSpace::findOtherFDE(pint_t targetAddr, pint_t &fde) { - inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf, - size_t bufLen, - unw_word_t *offset) { --#ifndef _LIBUNWIND_IS_BAREMETAL -+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32) - Dl_info dyldInfo; - if (dladdr((void *)addr, &dyldInfo)) { - if (dyldInfo.dli_sname != NULL) { -diff --git a/src/assembly.h b/src/assembly.h -index d28cbc9..df55679 100644 ---- a/src/assembly.h -+++ b/src/assembly.h -@@ -26,6 +26,8 @@ - - #if defined(__APPLE__) - #define HIDDEN_DIRECTIVE .private_extern -+#elif defined(_WIN32) -+#define HIDDEN_DIRECTIVE .globl - #else - #define HIDDEN_DIRECTIVE .hidden - #endif -diff --git a/src/config.h b/src/config.h -index ac8d7d9..07e7c1a 100644 ---- a/src/config.h -+++ b/src/config.h -@@ -37,6 +37,13 @@ - #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND - #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1 - #endif -+#elif defined(_WIN32) -+ // #define _LIBUNWIND_BUILD_SJLJ_APIS -+ // #define _LIBUNWIND_SUPPORT_FRAME_APIS -+ #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1 -+ // #define _LIBUNWIND_SUPPORT_DWARF_UNWIND -+ // #define _LIBUNWIND_SUPPORT_DWARF_INDEX -+ #define bzero(s,n) memset(s,0,n) - #else - #if defined(__ARM_DWARF_EH__) || !defined(__arm__) - #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1 -@@ -44,11 +51,10 @@ - #endif - #endif - --#if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS) -+#if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS) || defined(_WIN32) - #define _LIBUNWIND_EXPORT - #define _LIBUNWIND_HIDDEN - #else -- // FIXME: these macros are not correct for COFF targets - #define _LIBUNWIND_EXPORT __attribute__((visibility("default"))) - #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden"))) - #endif --- -2.14.1 - diff --git a/mingw-w64-clang/0801-Don-t-build-LLVMPolly-on-WIN32.patch b/mingw-w64-clang/0801-Don-t-build-LLVMPolly-on-WIN32.patch deleted file mode 100644 index de4568e0413a0..0000000000000 --- a/mingw-w64-clang/0801-Don-t-build-LLVMPolly-on-WIN32.patch +++ /dev/null @@ -1,39 +0,0 @@ -From fbb0c64cb855fbc25c0420aea712ed1390a6ecba Mon Sep 17 00:00:00 2001 -From: Mateusz Mikula -Date: Fri, 15 Sep 2017 14:25:27 +0200 -Subject: [PATCH] Don't build LLVMPolly on WIN32 - ---- - cmake/CMakeLists.txt | 2 +- - lib/CMakeLists.txt | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt -index 969292c..2c7d81a 100644 ---- a/cmake/CMakeLists.txt -+++ b/cmake/CMakeLists.txt -@@ -10,7 +10,7 @@ else() - endif() - - set(POLLY_CONFIG_EXPORTED_TARGETS Polly ${ISL_TARGET}) --if (NOT MSVC) -+if (NOT WIN32) - # LLVMPolly is a dummy target on Win - list(APPEND POLLY_CONFIG_EXPORTED_TARGETS LLVMPolly) - endif() -diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt -index 1141de5..3e0a8bc 100644 ---- a/lib/CMakeLists.txt -+++ b/lib/CMakeLists.txt -@@ -119,7 +119,7 @@ endif () - - # Create a loadable module Polly.so that can be loaded using - # LLVM's/clang's "-load" option. --if (MSVC) -+if (WIN32) - # Add dummy target, because loadable modules are not supported on Windows - add_custom_target(LLVMPolly) - set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly") --- -2.14.1.windows.1 - diff --git a/mingw-w64-clang/PKGBUILD b/mingw-w64-clang/PKGBUILD index 0a11ccbe3c94a..db7aaf8e43ffe 100644 --- a/mingw-w64-clang/PKGBUILD +++ b/mingw-w64-clang/PKGBUILD @@ -3,502 +3,415 @@ # Contributor: Ray Donnelly # Contributor: Mateusz Mikuła # Contributor: wirx6 - -# We can switch to clang when it fully works with mingw-w64 -#_compiler=clang - +# Contributor: Yuui Tanabe +# Contributor: Oscar Fuentes +# Contributor: Adrian Pop + +if [[ $MINGW_PACKAGE_PREFIX == *-clang-* ]]; then + _clangprefix=1 + _compiler=clang +else + _compiler=clang +fi _realname=clang pkgbase=mingw-w64-${_realname} pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}" "${MINGW_PACKAGE_PREFIX}-clang-analyzer" "${MINGW_PACKAGE_PREFIX}-clang-tools-extra" "${MINGW_PACKAGE_PREFIX}-compiler-rt" - "${MINGW_PACKAGE_PREFIX}-libc++abi" - "${MINGW_PACKAGE_PREFIX}-libc++" + $( (( _clangprefix )) && echo "${MINGW_PACKAGE_PREFIX}-gcc-compat" ) "${MINGW_PACKAGE_PREFIX}-lld" - "${MINGW_PACKAGE_PREFIX}-libunwind" "${MINGW_PACKAGE_PREFIX}-llvm" - "${MINGW_PACKAGE_PREFIX}-lldb" - "${MINGW_PACKAGE_PREFIX}-polly") -pkgver=5.0.1 -pkgrel=3 + "${MINGW_PACKAGE_PREFIX}-llvm-libs") +_version=17.0.2 +_rc= +_tag=llvmorg-${_version}${_rc} +pkgver=${_version}${_rc/-/} +pkgrel=2 pkgdesc="C language family frontend for LLVM (mingw-w64)" arch=('any') +mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64') url="https://llvm.org/" -license=("custom:University of Illinois/NCSA Open Source License") -makedepends=("${MINGW_PACKAGE_PREFIX}-cmake>=3.4.3" +license=("spdx:Apache-2.0 WITH LLVM-exception") +groups=($( (( _clangprefix )) && echo "${MINGW_PACKAGE_PREFIX}-toolchain")) +makedepends=("${MINGW_PACKAGE_PREFIX}-cmake" "${MINGW_PACKAGE_PREFIX}-z3" - $([[ "$_compiler" == "clang" ]] && echo \ - "${MINGW_PACKAGE_PREFIX}-clang") "${MINGW_PACKAGE_PREFIX}-libffi" - "${MINGW_PACKAGE_PREFIX}-pkg-config" - "${MINGW_PACKAGE_PREFIX}-python3-sphinx" - "${MINGW_PACKAGE_PREFIX}-python2" - "tar" - "groff") -depends=("${MINGW_PACKAGE_PREFIX}-gcc") -#options=('debug' '!strip') -source=(https://releases.llvm.org/${pkgver}/llvm-${pkgver}.src.tar.xz{,.sig} - https://releases.llvm.org/${pkgver}/cfe-${pkgver}.src.tar.xz{,.sig} - https://releases.llvm.org/${pkgver}/compiler-rt-${pkgver}.src.tar.xz{,.sig} - https://releases.llvm.org/${pkgver}/test-suite-${pkgver}.src.tar.xz{,.sig} - https://releases.llvm.org/${pkgver}/libcxx-${pkgver}.src.tar.xz{,.sig} - https://releases.llvm.org/${pkgver}/libcxxabi-${pkgver}.src.tar.xz{,.sig} - https://releases.llvm.org/${pkgver}/clang-tools-extra-${pkgver}.src.tar.xz{,.sig} - https://releases.llvm.org/${pkgver}/lld-${pkgver}.src.tar.xz{,.sig} - https://releases.llvm.org/${pkgver}/lldb-${pkgver}.src.tar.xz{,.sig} - https://releases.llvm.org/${pkgver}/libunwind-${pkgver}.src.tar.xz{,.sig} - https://releases.llvm.org/${pkgver}/polly-${pkgver}.src.tar.xz{,.sig} - "0001-mingw-w64-use-MSVC-style-ByteAlignment.patch" - "0002-Fix-GetHostTriple-for-mingw-w64-in-msys.patch" - "0003-Globally-provide-DESTDIR-for-all-platforms.patch" - "0004-llvm-config-look-for-unversioned-shared-lib-on-win32.patch" - "0005-add-pthread-as-system-lib-for-mingw.patch" - "0006-fix-bugpoint-multiple-definition.patch" - "0101-Allow-build-static-clang-library-for-mingw.patch" - "0102-fix-libclang-name-for-mingw.patch" - "0103-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch" - "0104-link-pthread-with-mingw.patch" - "0105-use-emulated-tls-with-mingw.patch" - "0106-MinGW-use-flto-visibility-public-std-CC1-arg-to-get-.patch" - "0201-mingw-w64-__udivdi3-mangle-hack.patch" - "0202-compiler-rt-fix-mingw-build.patch" - "0401-mingw-w64-hack-and-slash-fixes-for-libc.patch" - "0501-fixes-to-get-lldb-building.patch" - "0502-hack-to-use-64-bit-time-for-mingw.patch" - "0601-libunwind-add-support-for-mingw-w64.patch" - "0801-Don-t-build-LLVMPolly-on-WIN32.patch") + "${MINGW_PACKAGE_PREFIX}-ninja" + "${MINGW_PACKAGE_PREFIX}-pkgconf" + "${MINGW_PACKAGE_PREFIX}-python-sphinx" + "${MINGW_PACKAGE_PREFIX}-python" + "${MINGW_PACKAGE_PREFIX}-libunwind" + $([[ "$_compiler" == "clang" ]] && echo \ + "${MINGW_PACKAGE_PREFIX}-clang" || echo \ + "${MINGW_PACKAGE_PREFIX}-gcc") + $((( _clangprefix )) && echo \ + "${MINGW_PACKAGE_PREFIX}-compiler-rt" \ + "${MINGW_PACKAGE_PREFIX}-libc++") + "git" + ) +_url=https://github.com/llvm/llvm-project/releases/download/${_tag} +source=("${_url}/llvm-${pkgver}.src.tar.xz"{,.sig} + "${_url}/clang-${pkgver}.src.tar.xz"{,.sig} + "${_url}/clang-tools-extra-${pkgver}.src.tar.xz"{,.sig} + "${_url}/compiler-rt-${pkgver}.src.tar.xz"{,.sig} + "${_url}/lld-${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-Fix-Findzstd-on-MINGW.patch" + "0003-add-pthread-as-system-lib-for-mingw.patch" + "0004-enable-emutls-for-mingw.patch" + "0005-aarch64-unwind-seh.patch" + "0101-link-pthread-with-mingw.patch" + "0102-Rename-flang-new-flang-experimental-exec-to-flang.patch" + "0303-ignore-new-bfd-options.patch") # Some patch notes :) #0001-0099 -> llvm #0101-0199 -> clang #0201-0299 -> rt #0301-0399 -> lld -#0401-0499 -> libc++ -#0501-0599 -> lldb -#0601-0699 -> libunwind -#0701-0799 -> libc++abi -#0801-0899 -> polly -sha256sums=('5fa7489fc0225b11821cab0362f5813a05f2bcf2533e8a4ea9c9c860168807b0' - 'SKIP' - '135f6c9b0cd2da1aff2250e065946258eb699777888df39ca5a5b4fe5e23d0ff' - 'SKIP' - '4edd1417f457a9b3f0eb88082530490edf3cf6a7335cdce8ecbc5d3e16a895da' - 'SKIP' - 'db650be9ce049faa8e16ec2b12cc3ec670347d3e8677dec479e8cad499fe59e5' - 'SKIP' - 'fa8f99dd2bde109daa3276d529851a3bce5718d46ce1c5d0806f46caa3e57c00' +#0401-0499 -> clang-tools-extra +sha256sums=('61dd9eaa1f874a10a51dc397b84998eaebdd3c55a5a5fa6c24b2081a435b47c6' 'SKIP' - '5a25152cb7f21e3c223ad36a1022faeb8a5ac27c9e75936a5ae2d3ac48f6e854' + 'ce1c16b766894b3281038e4b2c4280f1b8c42fd5cc95ba355bba0f5ff47e23fa' 'SKIP' - '9aada1f9d673226846c3399d13fab6bba4bfd38bcfe8def5ee7b0ec24f8cd225' + '7ed1dd0c2f8a37f5759d9a7954655f7fcad933cba9bdb6ea30f592b47cac4e44' 'SKIP' - 'd5b36c0005824f07ab093616bdff247f3da817cae2c51371e1d1473af717d895' + '8053f53d3205f9758b03784c5d0cf8235ffe2f3fb7a946aea9c6aa5ff9b8d1a1' 'SKIP' - 'b7c1c9e67975ca219089a3a6a9c77c2d102cead2dc38264f2524aa3326da376a' + 'ccd46707b349f0e2bd8fe9eeb0ac5aa2ab1366a4939957dadab25dec14c68036' 'SKIP' - '6bbfbf6679435b858bd74bdf080386d084a76dfbf233fb6e47b2c28e0872d0fe' + '07093ef3b47bc30c24c8ab4996dea8c89eb6f3c8f55cd43158000c61c1fd5075' 'SKIP' - '9dd52b17c07054aa8998fc6667d41ae921430ef63fa20ae130037136fdacf36e' + '058623c5859c99e6b6711e88c646e80778377ec8e596e1f0e24efb987e063aff' 'SKIP' - 'd5b11097084f8a03dd3002c2adb27b4fec99cf290404049f1a4e1185274bde67' - '5081a1a9d8074b275f3087d4d80a13ce5d1c20bc1962819953790e54275930c8' - '46e10ce71525836d67466af954542c7133b646d7cc81dc30388f42dc27c7a6d6' - 'ef273f4b3abb2e0ee5c452362fe82195c3f1787bd6788ed24234aaf8180a015e' - '5303e8a2d64a4c08a2088a3610d74cfda3adbf5fdf172c4ca1f0ddc8701e3cf2' - 'f6e04b5e2a65e1eaa4ab6d14427cf17b1e79625a428430dd16a441578b31df55' - 'f2b0403e6b6cafddf364a90a6bb1e57793fd98d6f80f8976a87574cd93eb1d1a' - 'b1ed2ccdb87bb4f024a5cd750e71de3706fd24ccfeb87835403dab84ef7a9019' - 'ab49b90d69a609f441fa58e835873f2b1a8a060c9ca6358fee7d99c1973da692' - '53646dd01af2862473e9719c5223366486268891ccbff86413943a432a8342e9' - '7b85221a5d8506abc622dc8f252866c93183ccd7e44d5e1bc082d6fcb244e7d3' - '3d6045cf35d5523c68baf87bd490007d4ac8fe3eabcbc23d8c66e80ff1c234e7' - 'bafaf7d06bec3ed7fba58e8a926e7b472b5e16442b6ee9dd8c7ee6c0cce9792a' - 'a9e1c001701508c6ffd808cf530e0f6a756253a5cdb72d166e7987fa5ab64960' - 'da44cca549bc7fb9e04f0f038a1ed68ba99cdfec834fc241ab13880bd0aa3b0f' - 'df0fcd73d46207d23b4f6952de75ab626084560e9d9c698c3eb8d5ec071b308c' - 'a2bbb4d75d2d02b08a44a9f767b7f4ff11a546ae1ed79d06c3fc254218ac54e0' - '79d811b916b2ff718fd3b68b4211dd7548a7b51badc510d9e83eeac4229338a3' - 'bc394e597f8939b6f6630bd88c990f951738aaadacded2f3be71c658e9608fe7') + 'eb03df53671df6627768141b3aaa76abe176a14e5e47911c97bec544387c4aff' + 'd7d58ad5d0e77f2803070a8fb7f4138a6f49a2cbf30c55ff059c31f40ca6b65c' + '7f0c64cd87b61e894be632f180ae5291e1aa9f1d9d382608f659067eeeda7146' + '5f86e542dd1ec92b2fe06ee59061c3e23512df7bafabe82206f2b7d80b81836b' + '23b92a36f1623c3bd03fac831457597fc28276b9fd442cff6c962500e8cbbbc4' + '715cb8862753854b2d9256e0b70003e2d1f57083d83eaeaf5a095fc72b8a4e26' + '2770cadf8ccf6b31aece6aee8f76dceb71e6e9d01fdf3be74c3743480ce34899' + 'de631ab199a6fe83b3f695350bffaad067a2f95fc2ba9c8fe57dc85665d3653c') validpgpkeys=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D' # Hans Wennborg, Google. - '11E521D646982372EB577A1F8F0871F202119294') # Tom Stellard -noextract=(cfe-${pkgver}.src.tar.xz - libcxx-${pkgver}.src.tar.xz - lldb-${pkgver}.src.tar.xz - test-suite-${pkgver}.src.tar.xz) + '474E22316ABF4785A88C6E8EA2C794A986419D8A' # Tom Stellard + 'D574BD5D1D0E98895E3BF90044F2485E45D59042') # Tobias Hieta +noextract=(clang-${pkgver}.src.tar.xz) + +apply_patch_with_msg() { + for _patch in "$@" + do + msg2 "Applying ${_patch}" + patch -Nbp1 -i "${srcdir}/${_patch}" + done +} + +revert_patch_with_msg() { + for _patch in "$@" + do + msg2 "Reverting ${_patch}" + patch -Rbp1 -i "${srcdir}/${_patch}" + done +} prepare() { + cd "${srcdir}" plain "Extracting clang-${pkgver}.src.tar.xz due to symlink(s) without pre-existing target(s)" - [[ -d ${srcdir}/cfe-${pkgver} ]] && rm -rf ${srcdir}/cfe-${pkgver} - [[ -d ${srcdir}/cfe-${pkgver} ]] || tar -xJvf ${srcdir}/cfe-${pkgver}.src.tar.xz -C ${srcdir} || true - - plain "Extracting libcxx-${pkgver}.src.tar.xz due to symlink(s) without pre-existing target(s)" - [[ -d ${srcdir}/libcxx-${pkgver} ]] && rm -rf ${srcdir}/libcxx-${pkgver} - [[ -d ${srcdir}/libcxx-${pkgver} ]] || tar -xJvf ${srcdir}/libcxx-${pkgver}.src.tar.xz -C ${srcdir} || true - - plain "Extracting lldb-${pkgver}.src.tar.xz due to symlink(s) without pre-existing target(s)" - [[ -d ${srcdir}/lldb-${pkgver} ]] && rm -rf ${srcdir}/lldb-${pkgver} - [[ -d ${srcdir}/lldb-${pkgver} ]] || tar -xJvf ${srcdir}/lldb-${pkgver}.src.tar.xz -C ${srcdir} || true - - cd "${srcdir}/llvm-${pkgver}.src" - patch -p1 -i "${srcdir}/0001-mingw-w64-use-MSVC-style-ByteAlignment.patch" - patch -p1 -i "${srcdir}/0002-Fix-GetHostTriple-for-mingw-w64-in-msys.patch" - patch -p1 -i "${srcdir}/0003-Globally-provide-DESTDIR-for-all-platforms.patch" - patch -p1 -i "${srcdir}/0004-llvm-config-look-for-unversioned-shared-lib-on-win32.patch" - patch -p1 -i "${srcdir}/0005-add-pthread-as-system-lib-for-mingw.patch" - #patch -p1 -i "${srcdir}/0006-fix-bugpoint-multiple-definition.patch" - - cd "${srcdir}/cfe-${pkgver}.src" - patch -p1 -i "${srcdir}/0101-Allow-build-static-clang-library-for-mingw.patch" - patch -p1 -i "${srcdir}/0102-fix-libclang-name-for-mingw.patch" - patch -p1 -i "${srcdir}/0103-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch" - patch -p1 -i "${srcdir}/0104-link-pthread-with-mingw.patch" - patch -p1 -i "${srcdir}/0105-use-emulated-tls-with-mingw.patch" - patch -p1 -i "${srcdir}/0106-MinGW-use-flto-visibility-public-std-CC1-arg-to-get-.patch" - - cd "${srcdir}/compiler-rt-${pkgver}.src" - patch -p1 -i "${srcdir}/0201-mingw-w64-__udivdi3-mangle-hack.patch" - patch -p1 -i "${srcdir}/0202-compiler-rt-fix-mingw-build.patch" - - #cd "${srcdir}/lld-${pkgver}.src" - - cd "${srcdir}/libcxx-${pkgver}.src" - patch -p1 -i "${srcdir}/0401-mingw-w64-hack-and-slash-fixes-for-libc.patch" - - cd "${srcdir}/lldb-${pkgver}.src" - patch -p1 -i "${srcdir}/0501-fixes-to-get-lldb-building.patch" - # There was big refactor/cleanup and it doesn't apply any more - # https://github.com/llvm-mirror/lldb/commit/456b31d616f3c71be31315ae26f6c8e174f4fd51#diff-2c5e3e9a387d499896aa082d15141bfb - # However 32 bit lldb is still crashing without it; temporary leaving patch for the reference until it's solved - #patch -p1 -i "${srcdir}/0502-hack-to-use-64-bit-time-for-mingw.patch" - - cd "${srcdir}/libunwind-${pkgver}.src" - patch -p1 -i "${srcdir}/0601-libunwind-add-support-for-mingw-w64.patch" - - #cd "${srcdir}/libcxxabi-${pkgver}.src" - - cd "${srcdir}/polly-${pkgver}.src" - # With LLVM_LINK_LLVM_DYLIB=ON it's build before LLVM and fails with undefined references to LLVM functions - patch -p1 -i "${srcdir}/0801-Don-t-build-LLVMPolly-on-WIN32.patch" - - # At the present, clang must reside inside the LLVM source code tree to build - # See https://bugs.llvm.org/show_bug.cgi?id=4840 - - cd "${srcdir}"/llvm-${pkgver}.src - rm -rf tools/clang tools/clang/tools/extra tools/lld tools/lldb tools/polly projects/compiler-rt projects/libcxx \ - projects/libcxxabi projects/libunwind projects/test-suite | true - mv "${srcdir}/cfe-${pkgver}.src" tools/clang - mv "${srcdir}/clang-tools-extra-${pkgver}.src" tools/clang/tools/extra - mv "${srcdir}/lld-${pkgver}.src" tools/lld - mv "${srcdir}/lldb-${pkgver}.src" tools/lldb - mv "${srcdir}/polly-${pkgver}.src" tools/polly - mv "${srcdir}/compiler-rt-${pkgver}.src" projects/compiler-rt - mv "${srcdir}/libcxxabi-${pkgver}.src" projects/libcxxabi - mv "${srcdir}/libcxx-${pkgver}.src" projects/libcxx - mv "${srcdir}/libunwind-${pkgver}.src" projects/libunwind - #mv "${srcdir}/testsuite-${pkgver}.src" projects/test-suite + tar -xJf ${srcdir}/clang-${pkgver}.src.tar.xz -C ${srcdir} || true + + # Rename Directories + for pkg in llvm clang clang-tools-extra compiler-rt lld cmake third-party; do + mv ${pkg}-$pkgver.src ${pkg} + done + + # Patch llvm + cd "${srcdir}/llvm" + apply_patch_with_msg \ + "0001-Fix-GetHostTriple-for-mingw-w64-in-msys.patch" \ + "0002-Fix-Findzstd-on-MINGW.patch" \ + "0005-aarch64-unwind-seh.patch" + + if (( ! _clangprefix )); then + apply_patch_with_msg \ + "0003-add-pthread-as-system-lib-for-mingw.patch" \ + "0004-enable-emutls-for-mingw.patch" + fi + + # Patch clang + cd "${srcdir}/clang" + + if (( ! _clangprefix )); then + apply_patch_with_msg \ + "0101-link-pthread-with-mingw.patch" + fi + # https://reviews.llvm.org/D143592 + apply_patch_with_msg \ + "0102-Rename-flang-new-flang-experimental-exec-to-flang.patch" + + # Patch lld + cd "${srcdir}/lld" + + apply_patch_with_msg \ + "0303-ignore-new-bfd-options.patch" + + # Patch clang-tools-extra + cd "${srcdir}/clang-tools-extra" } build() { cd "${srcdir}" - [[ -d build-${CARCH} ]] && rm -rf build-${CARCH} - mkdir build-${CARCH} && cd build-${CARCH} + case "${CARCH}" in + i?86|armv7) + # lld needs all the address space it can get. + LDFLAGS+=" -Wl,--large-address-aware" + ;; + esac - local -a extra_config + local -a platform_config + local -a common_cmake_args if check_option "debug" "y"; then - extra_config+=(-DCMAKE_BUILD_TYPE=Debug) + common_cmake_args+=(-DCMAKE_BUILD_TYPE=Debug) VERBOSE="VERBOSE=1" else - extra_config+=(-DCMAKE_BUILD_TYPE=Release) + common_cmake_args+=(-DCMAKE_BUILD_TYPE=Release) fi + common_cmake_args+=(-Wno-dev + -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} + -DCMAKE_SYSTEM_IGNORE_PATH=/usr/lib + -DLLVM_HOST_TRIPLE="${CARCH}-w64-windows-gnu" + -DPython3_EXECUTABLE=${MINGW_PREFIX}/bin/python.exe + -DPython3_FIND_REGISTRY=NEVER + -DPython3_ROOT_DIR=${MINGW_PREFIX}) # Include location of libffi headers in CPPFLAGS FFI_INCLUDE_DIR="$(pkg-config --cflags libffi)" FFI_INCLUDE_DIR=$(echo $FFI_INCLUDE_DIR | sed 's|-I||g') - # "Ninja" cant install each component seperately - # https://github.com/martine/ninja/issues/932 - if [ "${_compiler}" == "clang" ]; then - #export CC='clang -stdlib=libc++' - #export CXX='clang++ -stdlib=libc++' export CC='clang' export CXX='clang++' fi + if (( _clangprefix )); then + # A bit hacky but it works + local _clang_links="clang++;clang-cpp;as;c++;cc;cpp;${MINGW_CHOST}-cc;${MINGW_CHOST}-c++;${MINGW_CHOST}-clang;${MINGW_CHOST}-clang++" + + platform_config+=(-DCLANG_DEFAULT_RTLIB=compiler-rt + -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON + -DCLANG_DEFAULT_UNWINDLIB=libunwind + -DCLANG_DEFAULT_CXX_STDLIB=libc++ + -DLLVM_ENABLE_LIBCXX=ON + -DCLANG_DEFAULT_LINKER=lld + -DLLVM_ENABLE_LLD=ON + -DCLANG_LINKS_TO_CREATE="${_clang_links}" + -DLLVM_INSTALL_BINUTILS_SYMLINKS=ON) + fi + + local _projects="clang;clang-tools-extra;compiler-rt;lld" + + case "${CARCH}" in + x86_64|i?86) + platform_config+=(-DCOMPILER_RT_BUILD_SANITIZERS=$( (( _clangprefix )) && echo "ON" || echo "OFF")) + ;; + armv7|aarch64) + platform_config+=(-DCOMPILER_RT_BUILD_MEMPROF=OFF + -DCOMPILER_RT_BUILD_SANITIZERS=OFF + -DCOMPILER_RT_BUILD_XRAY=OFF) + ;; + esac + + # List of targets to build in CMake style + # For more info see: https://github.com/msys2/MINGW-packages/discussions/9765 + if [ "${_compiler}" == "clang" ]; then + platform_config+=(-DLLVM_TARGETS_TO_BUILD="all") + else + platform_config+=(-DLLVM_TARGETS_TO_BUILD="AArch64;AMDGPU;ARM;AVR;BPF;Mips;MSP430;NVPTX;RISCV;WebAssembly;X86") + fi + + mkdir build-${MSYSTEM} && cd build-${MSYSTEM} + MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \ ${MINGW_PREFIX}/bin/cmake.exe \ - -G"MSYS Makefiles" \ - -DCMAKE_SYSTEM_IGNORE_PATH=/usr/lib \ - -DCMAKE_MAKE_PROGRAM="/usr/bin/make.exe" \ + -GNinja \ -DFFI_INCLUDE_DIR="${FFI_INCLUDE_DIR}" \ - -DCMAKE_C_FLAGS="${CFLAGS}" \ - -DCMAKE_CXX_FLAGS="${CXXFLAGS} -D_GNU_SOURCE" \ - -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \ - -DLLVM_TARGETS_TO_BUILD="ARM;NVPTX;X86" \ + -DLIBCLANG_BUILD_STATIC=ON \ + -DLLD_DEFAULT_LD_LLD_IS_MINGW=ON \ + -DLLVM_BUILD_LLVM_DYLIB=ON \ + -DLLVM_BUILD_STATIC=OFF \ -DLLVM_ENABLE_ASSERTIONS=OFF \ - -DLLVM_ENABLE_THREADS=ON \ - -DPYTHON_EXECUTABLE=${MINGW_PREFIX}/bin/python2.exe \ -DLLVM_ENABLE_FFI=ON \ + -DLLVM_ENABLE_PROJECTS="${_projects}" \ -DLLVM_ENABLE_SPHINX=ON \ - -DLLVM_BUILD_LLVM_DYLIB=ON \ + -DLLVM_ENABLE_THREADS=ON \ + -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 \ - -DLIBCLANG_BUILD_STATIC=ON \ - -DLIBCXX_ENABLE_SHARED=OFF \ - -DLIBCXXABI_ENABLE_SHARED=OFF \ - -DLIBUNWIND_ENABLE_SHARED=OFF \ - -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \ - -DLLVM_POLLY_LINK_INTO_TOOLS=OFF \ - -DCLANG_ANALYZER_BUILD_Z3=ON \ - "${extra_config[@]}" \ - ../llvm-${pkgver}.src + "${common_cmake_args[@]}" \ + "${platform_config[@]}" \ + ../llvm - make ${VERBOSE} + ${MINGW_PREFIX}/bin/cmake.exe --build . # Disable automatic installation of components that go into subpackages # -i.orig to check what has been removed in-case it starts dropping more than it should # - sed -i.orig '/\(clang\|lld\|lldb\|polly\)\/cmake_install.cmake/d' tools/cmake_install.cmake - sed -i.orig '/\(extra\|scan-build\|scan-view\)\/cmake_install.cmake/d' tools/clang/tools/cmake_install.cmake -# sed -i.orig '/\(compiler-rt\|libcxxabi\|libcxx\)\/cmake_install.cmake/d' projects/cmake_install.cmake - sed -i.orig '/\(compiler-rt\|libcxxabi\|libcxx\|libunwind\)\/cmake_install.cmake/d' projects/cmake_install.cmake + sed -i.orig '/\(clang\|lld\)\/cmake_install.cmake/d' tools/cmake_install.cmake + sed -i.orig '/\(extra\|scan-build\|scan-build-py\|scan-view\)\/cmake_install.cmake/d' tools/clang/tools/cmake_install.cmake + sed -i.orig '/compiler-rt\/cmake_install.cmake/d' projects/cmake_install.cmake } -#check() { -# cd "${srcdir}"/build-${CARCH} -# # Remove || true once testcase doesn't cause failures. +check() { + cd "${srcdir}"/build-${MSYSTEM} + # Remove || true once testcase doesn't cause failures. # make check || true # make check-clang || true -# make check-polly || true -#} - -package_llvm() { - pkgdesc="Low Level Virtual Machine (mingw-w64)" - depends=("${MINGW_PACKAGE_PREFIX}-libffi" - "${MINGW_PACKAGE_PREFIX}-gcc-libs") # "compiler-rt" - - cd "${srcdir}"/llvm-${pkgver}.src - - make -C ../build-${CARCH} DESTDIR="${pkgdir}" install - - # TODO: why CMake haven't included it? - cp ../build-${CARCH}/lib/libLLVM.dll.a "${pkgdir}/${MINGW_PREFIX}/lib/" - - install -Dm644 LICENSE.TXT "${pkgdir}${MINGW_PREFIX}/share/licenses/llvm/LICENSE" - - # Install CMake stuff - install -d "${pkgdir}"${MINGW_PREFIX}/share/llvm/cmake/{modules,platforms} - install -Dm644 "${srcdir}"/llvm-${pkgver}.src/cmake/modules/*.cmake "${pkgdir}"${MINGW_PREFIX}/share/llvm/cmake/modules/ - install -Dm644 "${srcdir}"/llvm-${pkgver}.src/cmake/platforms/*.cmake "${pkgdir}"${MINGW_PREFIX}/share/llvm/cmake/platforms/ - - # FileCheck is needed to build rust. - install -Dm755 "${srcdir}"/build-${CARCH}/bin/FileCheck.exe "${pkgdir}${MINGW_PREFIX}/bin/FileCheck.exe" - # fox cmake files. - local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX}) - sed -e "s|${PREFIX_WIN}|${MINGW_PREFIX}|g" -i ${pkgdir}/${MINGW_PREFIX}/lib/cmake/llvm/LLVMExports.cmake -} - -package_compiler-rt() { - pkgdesc="Runtime libraries for Clang and LLVM (mingw-w64)" - url="https://compiler-rt.llvm.org/" - depends=("${MINGW_PACKAGE_PREFIX}-llvm=${pkgver}-${pkgrel}") - - cd "${srcdir}"/llvm-${pkgver}.src - make -C ../build-${CARCH}/projects/compiler-rt DESTDIR="${pkgdir}" install -} - -package_libcxxabi() { - pkgdesc="C++ Standard Library Support (mingw-w64)" - url="https://libcxxabi.llvm.org/" - # Don't depend on libunwind until it actually works as installing it breaks some packages - #depends="${MINGW_PACKAGE_PREFIX}-libunwind" - - cd "${srcdir}/llvm-${pkgver}.src" - make -C ../build-${CARCH}/projects/libcxxabi -j1 DESTDIR="${pkgdir}" install -} - -package_libcxx() { - pkgdesc="C++ Standard Library (mingw-w64)" - url="https://libcxx.llvm.org/" - - cd "${srcdir}/llvm-${pkgver}.src" - make -C ../build-${CARCH}/projects/libcxx -j1 DESTDIR="${pkgdir}" install -} - -package_libunwind() { - pkgdesc='A new implementation of a stack unwinder for C++ exceptions (mingw-w64)' - url='https://llvm.org/' - - cd "${srcdir}/llvm-${pkgver}.src" - make -C ../build-${CARCH}/projects/libunwind -j1 DESTDIR="${pkgdir}" install -} - -package_lldb() { - pkgdesc="Next generation, high-performance debugger (mingw-w64)" - url="https://lldb.llvm.org/" - depends=("${MINGW_PACKAGE_PREFIX}-readline" - "${MINGW_PACKAGE_PREFIX}-libxml2" - "${MINGW_PACKAGE_PREFIX}-python2" - "${MINGW_PACKAGE_PREFIX}-swig") - - cd "${srcdir}/llvm-${pkgver}.src" - - make -C ../build-${CARCH}/tools/lldb DESTDIR="${pkgdir}" install - - # Compile Python scripts - python2 -m compileall "${pkgdir}${MINGW_PREFIX}/lib/python2.7/site-packages/lldb" - python2 -O -m compileall "${pkgdir}${MINGW_PREFIX}/lib/python2.7/site-packages/lldb" - - install -Dm644 tools/lldb/LICENSE.TXT "${pkgdir}${MINGW_PREFIX}/share/licenses/lldb/LICENSE" -} - -package_lld() { - pkgdesc="Linker tools for LLVM (mingw-w64)" - url="https://lld.llvm.org/" - - cd "${srcdir}/llvm-${pkgver}.src" - make -C ../build-${CARCH}/tools/lld -j1 DESTDIR="${pkgdir}" install + ${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 } package_clang() { pkgdesc="C language family frontend for LLVM (mingw-w64)" url="https://clang.llvm.org/" - depends=("${MINGW_PACKAGE_PREFIX}-llvm=${pkgver}-${pkgrel}" - "${MINGW_PACKAGE_PREFIX}-gcc" - "${MINGW_PACKAGE_PREFIX}-z3") + depends=("${MINGW_PACKAGE_PREFIX}-llvm=${pkgver}" + $( ((_clangprefix)) && echo \ + "${MINGW_PACKAGE_PREFIX}-compiler-rt=${pkgver}" \ + "${MINGW_PACKAGE_PREFIX}-crt" \ + "${MINGW_PACKAGE_PREFIX}-headers" \ + "${MINGW_PACKAGE_PREFIX}-lld=${pkgver}" \ + "${MINGW_PACKAGE_PREFIX}-winpthreads" \ + || echo "${MINGW_PACKAGE_PREFIX}-gcc")) + provides=($( (( _clangprefix )) && echo \ + "${MINGW_PACKAGE_PREFIX}-cc" \ + || true )) - cd "${srcdir}/llvm-${pkgver}.src" - make -C ../build-${CARCH}/tools/clang DESTDIR="${pkgdir}" install + cmake --install "${srcdir}/build-${MSYSTEM}/tools/clang" --prefix "${pkgdir}${MINGW_PREFIX}" } package_clang-analyzer() { pkgdesc="A source code analysis framework (mingw-w64)" url="https://clang-analyzer.llvm.org/" - depends=("${MINGW_PACKAGE_PREFIX}-clang=${pkgver}-${pkgrel}" - "${MINGW_PACKAGE_PREFIX}-python2") - - cd "${srcdir}/llvm-${pkgver}.src" - make -C ../build-${CARCH}/tools/clang/tools/scan-build -j1 DESTDIR="${pkgdir}" install - make -C ../build-${CARCH}/tools/clang/tools/scan-view -j1 DESTDIR="${pkgdir}" install + depends=("${MINGW_PACKAGE_PREFIX}-clang=${pkgver}" + "${MINGW_PACKAGE_PREFIX}-python") - # Use Python 2 - sed -i \ - -e 's|env python$|&2|' \ - -e 's|/usr/bin/python$|&2|' \ - "${pkgdir}"${MINGW_PREFIX}/bin/scan-view + local _analyzer + for _analyzer in scan-build scan-build-py scan-view; do + DESTDIR="${pkgdir}" cmake --install "${srcdir}/build-${MSYSTEM}/tools/clang/tools/${_analyzer}" + done # Compile Python scripts - python2 -m compileall "${pkgdir}"${MINGW_PREFIX}/bin/clang-analyzer - python2 -O -m compileall "${pkgdir}"${MINGW_PREFIX}/lib/clang-analyzer - install -Dm644 LICENSE.TXT "${pkgdir}"${MINGW_PREFIX}/share/licenses/clang-analyzer/LICENSE + ${MINGW_PREFIX}/bin/python -m compileall "${pkgdir}"${MINGW_PREFIX}/lib/libscanbuild + ${MINGW_PREFIX}/bin/python -O -m compileall "${pkgdir}"${MINGW_PREFIX}/lib/libscanbuild + + install -Dm644 "${srcdir}/clang/LICENSE.TXT" "${pkgdir}"${MINGW_PREFIX}/share/licenses/clang-analyzer/LICENSE } package_clang-tools-extra() { pkgdesc="Extra tools built using Clang's tooling APIs (mingw-w64)" url="https://clang.llvm.org/" + depends=("${MINGW_PACKAGE_PREFIX}-clang=${pkgver}") - cd "${srcdir}/llvm-${pkgver}.src" - make -C ../build-${CARCH}/tools/clang/tools/extra -j1 DESTDIR="${pkgdir}" install -} - -package_polly() { - pkgdesc="Polly - Polyhedral optimizations for LLVM (mingw-w64)" - url="https://polly.llvm.org/" - depends=("${MINGW_PACKAGE_PREFIX}-llvm=${pkgver}-${pkgrel}") - - cd "${srcdir}"/llvm-${pkgver}.src - make -C ../build-${CARCH}/tools/polly DESTDIR="${pkgdir}" install - # fox cmake files. - local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX}) - sed -e "s|${PREFIX_WIN}/bin/|${MINGW_PREFIX}/|g" -i "${pkgdir}/${MINGW_PREFIX}/lib/cmake/polly/PollyConfig.cmake" -} - -# Wrappers -package_mingw-w64-i686-clang(){ - package_clang -} - -package_mingw-w64-i686-clang-analyzer(){ - package_clang-analyzer -} - -package_mingw-w64-i686-clang-tools-extra(){ - package_clang-tools-extra -} - -package_mingw-w64-i686-compiler-rt(){ - package_compiler-rt + DESTDIR="${pkgdir}" cmake --install "${srcdir}/build-${MSYSTEM}/tools/clang/tools/extra" } -package_mingw-w64-i686-libc++abi(){ - package_libcxxabi -} +package_compiler-rt() { + pkgdesc="Runtime libraries for Clang and LLVM (mingw-w64)" + url="https://compiler-rt.llvm.org/" + depends=($( (( _clangprefix )) || echo "${MINGW_PACKAGE_PREFIX}-gcc-libs")) -package_mingw-w64-i686-libc++(){ - package_libcxx + DESTDIR="${pkgdir}" cmake --install "${srcdir}/build-${MSYSTEM}/projects/compiler-rt" + mkdir -p "${pkgdir}${MINGW_PREFIX}/bin/" + 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 } -package_mingw-w64-i686-lld(){ - package_lld -} +package_gcc-compat() { + pkgdesc="GCC compatibility aliases for Clang (mingw-w64)" + url="https://clang.llvm.org/" + depends=("${MINGW_PACKAGE_PREFIX}-clang=${pkgver}-${pkgrel}") + provides=("${MINGW_PACKAGE_PREFIX}-gcc") + conflicts=("${MINGW_PACKAGE_PREFIX}-gcc") -package_mingw-w64-i686-lldb(){ - package_lldb + mkdir -p "${pkgdir}${MINGW_PREFIX}/bin" + local _alias + for _alias in gcc g++ ${MINGW_CHOST}-gcc ${MINGW_CHOST}-g++; do + cp -f "${srcdir}/build-${MSYSTEM}/bin/clang.exe" "${pkgdir}${MINGW_PREFIX}/bin/${_alias}.exe" + done } -package_mingw-w64-i686-libunwind(){ - package_libunwind +package_lld() { + pkgdesc="Linker tools for LLVM (mingw-w64)" + url="https://lld.llvm.org/" + depends=("${MINGW_PACKAGE_PREFIX}-llvm=${pkgver}") + provides=($( (( _clangprefix )) && echo \ + "${MINGW_PACKAGE_PREFIX}-binutils" \ + || true)) + + DESTDIR="${pkgdir}" cmake --install "${srcdir}/build-${MSYSTEM}/tools/lld" + if (( _clangprefix )); then + install -Dm755 "${pkgdir}${MINGW_PREFIX}/bin/lld.exe" "${pkgdir}${MINGW_PREFIX}/bin/ld.exe" + fi } -package_mingw-w64-i686-llvm(){ - package_llvm -} +package_llvm() { + pkgdesc="Low Level Virtual Machine (mingw-w64)" + depends=("${MINGW_PACKAGE_PREFIX}-llvm-libs") -package_mingw-w64-i686-polly(){ - package_polly -} + cd "${srcdir}"/llvm -package_mingw-w64-x86_64-clang(){ - package_clang -} + DESTDIR="${pkgdir}" cmake --install "${srcdir}/build-${MSYSTEM}" -package_mingw-w64-x86_64-clang-analyzer(){ - package_clang-analyzer -} + install -Dm644 "${srcdir}/llvm/LICENSE.TXT" "${pkgdir}${MINGW_PREFIX}/share/licenses/llvm/LICENSE" -package_mingw-w64-x86_64-clang-tools-extra(){ - package_clang-tools-extra -} + # Runtime libraries + rm -rf "${srcdir}/llvm-libs" + mkdir -p "${srcdir}/llvm-libs/${MINGW_PREFIX}/bin" + mv -f "${pkgdir}${MINGW_PREFIX}"/bin/lib{LLVM-*,LTO,Remarks}.dll "${srcdir}/llvm-libs/${MINGW_PREFIX}/bin" -package_mingw-w64-x86_64-compiler-rt(){ - package_compiler-rt -} + # Provide gcov on CLANG* + if [[ ${MINGW_PACKAGE_PREFIX} == *-clang-* ]]; then + cp "${pkgdir}"${MINGW_PREFIX}/bin/llvm-cov.exe "${pkgdir}"${MINGW_PREFIX}/bin/gcov.exe + fi -package_mingw-w64-x86_64-libc++abi(){ - package_libcxxabi -} + # Install CMake stuff + install -d "${pkgdir}"${MINGW_PREFIX}/share/llvm/cmake/{modules,platforms} + install -Dm644 "${srcdir}"/llvm/cmake/modules/*.cmake "${pkgdir}"${MINGW_PREFIX}/share/llvm/cmake/modules/ + install -Dm644 "${srcdir}"/llvm/cmake/platforms/*.cmake "${pkgdir}"${MINGW_PREFIX}/share/llvm/cmake/platforms/ -package_mingw-w64-x86_64-libc++(){ - package_libcxx + # fix cmake files. + local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX}) + sed -e "s|${PREFIX_WIN}|${MINGW_PREFIX}|g" -i ${pkgdir}/${MINGW_PREFIX}/lib/cmake/llvm/LLVMExports.cmake } -package_mingw-w64-x86_64-lld(){ - package_lld -} +package_llvm-libs() { + pkgdesc="Low Level Virtual Machine Runtime Libraries (mingw-w64)" + depends=("${MINGW_PACKAGE_PREFIX}-libffi" + "${MINGW_PACKAGE_PREFIX}-gcc-libs" + "${MINGW_PACKAGE_PREFIX}-zlib" + "${MINGW_PACKAGE_PREFIX}-libxml2" + "${MINGW_PACKAGE_PREFIX}-zstd") + conflicts=("${MINGW_PACKAGE_PREFIX}-llvm<16.0.2-2") -package_mingw-w64-x86_64-lldb(){ - package_lldb -} + cp -r "${srcdir}/llvm-libs/${MINGW_PREFIX}" "${pkgdir}${MINGW_PREFIX}" -package_mingw-w64-x86_64-libunwind(){ - package_libunwind + install -Dm644 "${srcdir}/llvm/LICENSE.TXT" "${pkgdir}${MINGW_PREFIX}/share/licenses/llvm-libs/LICENSE" } -package_mingw-w64-x86_64-llvm(){ - package_llvm -} +# template start; name=mingw-w64-splitpkg-wrappers; version=1.0; +# vim: set ft=bash : -package_mingw-w64-x86_64-polly(){ - package_polly -} +# generate wrappers +for _name in "${pkgname[@]}"; do + _short="package_${_name#${MINGW_PACKAGE_PREFIX}-}" + _func="$(declare -f "${_short}")" + eval "${_func/#${_short}/package_${_name}}" +done +# template end; diff --git a/mingw-w64-clang/README-patches.md b/mingw-w64-clang/README-patches.md new file mode 100644 index 0000000000000..96dadbeeedf84 --- /dev/null +++ b/mingw-w64-clang/README-patches.md @@ -0,0 +1,18 @@ +# Patches statuses + +Legend: + +- :grey_exclamation: - not meant to upstream, for compatibility with GCC only +- :x: - not upstreamed +- :grey_question: - sent but not merged yet +- :arrow_up_small: - upstreamed +- :arrow_down_small: - backported + +----- + +- `"0001-Fix-GetHostTriple-for-mingw-w64-in-msys.patch"` :x: +- `"0003-add-pthread-as-system-lib-for-mingw.patch"` :grey_exclamation: +- `"0004-enable-emutls-for-mingw.patch"` :grey_exclamation: +- `"0101-link-pthread-with-mingw.patch"` :grey_exclamation: +- `"0102-Rename-flang-new-flang-experimental-exec-to-flang.patch"` :grey_question: https://reviews.llvm.org/D143592 +- `"0303-ignore-new-bfd-options.patch"` :x: From e498979a45237c35a0ea33519496c2628314137e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= Date: Fri, 30 Jun 2023 21:40:31 +0200 Subject: [PATCH 2/3] clang: build a smaller clang/llvm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Msys2 builds pretty versatile Clang and LLVM packages with LLVM backends to cross compile for various target architectures. That comes at the cost of big binaries, that challenge how we manage the Git for Windows SDK[1]. But for Git for Windows we don't need all of this. We only need a Clang that can compile ARM64 binaries on ARM64. [1] https://github.com/git-for-windows/git-sdk-arm64/issues/7 Signed-off-by: Matthias Aßhauer --- mingw-w64-clang/PKGBUILD | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/mingw-w64-clang/PKGBUILD b/mingw-w64-clang/PKGBUILD index db7aaf8e43ffe..2536a053d0a9f 100644 --- a/mingw-w64-clang/PKGBUILD +++ b/mingw-w64-clang/PKGBUILD @@ -27,7 +27,7 @@ _version=17.0.2 _rc= _tag=llvmorg-${_version}${_rc} pkgver=${_version}${_rc/-/} -pkgrel=2 +pkgrel=3 pkgdesc="C language family frontend for LLVM (mingw-w64)" arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64') @@ -176,7 +176,7 @@ build() { common_cmake_args+=(-DCMAKE_BUILD_TYPE=Debug) VERBOSE="VERBOSE=1" else - common_cmake_args+=(-DCMAKE_BUILD_TYPE=Release) + common_cmake_args+=(-DCMAKE_BUILD_TYPE=MinSizeRel) fi common_cmake_args+=(-Wno-dev -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} @@ -226,9 +226,9 @@ build() { # List of targets to build in CMake style # For more info see: https://github.com/msys2/MINGW-packages/discussions/9765 if [ "${_compiler}" == "clang" ]; then - platform_config+=(-DLLVM_TARGETS_TO_BUILD="all") + platform_config+=(-DLLVM_TARGETS_TO_BUILD="host") else - platform_config+=(-DLLVM_TARGETS_TO_BUILD="AArch64;AMDGPU;ARM;AVR;BPF;Mips;MSP430;NVPTX;RISCV;WebAssembly;X86") + platform_config+=(-DLLVM_TARGETS_TO_BUILD="host") fi mkdir build-${MSYSTEM} && cd build-${MSYSTEM} @@ -244,7 +244,7 @@ build() { -DLLVM_ENABLE_ASSERTIONS=OFF \ -DLLVM_ENABLE_FFI=ON \ -DLLVM_ENABLE_PROJECTS="${_projects}" \ - -DLLVM_ENABLE_SPHINX=ON \ + -DLLVM_ENABLE_SPHINX=OFF \ -DLLVM_ENABLE_THREADS=ON \ -DLLVM_ENABLE_RTTI=ON \ -DLLVM_INCLUDE_EXAMPLES=OFF \ @@ -266,15 +266,6 @@ build() { sed -i.orig '/compiler-rt\/cmake_install.cmake/d' projects/cmake_install.cmake } -check() { - cd "${srcdir}"/build-${MSYSTEM} - # 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 -} package_clang() { pkgdesc="C language family frontend for LLVM (mingw-w64)" From 608ca468efa24101fdeb66ce2f31172a4d69b010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= Date: Fri, 30 Jun 2023 21:49:59 +0200 Subject: [PATCH 3/3] clang: add helper script to keep package updated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We'll need to update our clang when Msys2 updates theirs and reapply our customisations every time, so a script makes this job less tedious and leaves no room to miss a step of the process. This script performs the same steps as the previous two commits. (it was used to generate the files for those) Signed-off-by: Matthias Aßhauer --- mingw-w64-clang/update-clang-from-msys2.sh | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 mingw-w64-clang/update-clang-from-msys2.sh diff --git a/mingw-w64-clang/update-clang-from-msys2.sh b/mingw-w64-clang/update-clang-from-msys2.sh new file mode 100644 index 0000000000000..099859a3bc72b --- /dev/null +++ b/mingw-w64-clang/update-clang-from-msys2.sh @@ -0,0 +1,57 @@ +#!/usr/bin/bash +die () { + printf "$@" >&2 + cleanup + exit 1 +} +cleanup(){ + rm -rf upstream +} + +pkgname=mingw-w64-clang + +old_pkgver="$(sed -ne 's/pkgver=\([.0-9]*\).*/\1/p' -e 's/_version=\([.0-9]*\).*/\1/p' < PKGBUILD)" +old_pkgrel="$(sed -ne 's/pkgrel=\([0-9]*\).*/\1/p' < PKGBUILD)" + +test -n "$old_pkgver" || + die "$0: could not determine current pkgver\n" + +test -n "$old_pkgrel" || + die "$0: could not determine current pkgrel\n" + +git clone --sparse --depth 1 --filter=blob:none https://github.com/msys2/MINGW-packages upstream +git -C upstream sparse-checkout add $pkgname + +new_pkgver="$(sed -ne 's/pkgver=\([.0-9]*\).*/\1/p' -e 's/_version=\([.0-9]*\).*/\1/p' < upstream/$pkgname/PKGBUILD)" +new_pkgrel="$(sed -ne 's/pkgrel=\([0-9]*\).*/\1/p' < upstream/$pkgname/PKGBUILD)" +rc="$(sed -ne 's/_rc="\(*\)".*/\1/p' < upstream/$pkgname/PKGBUILD)" + +test -n "$new_pkgver" || + die "$0: could not determine new pkgver\n" + +test -n "$new_pkgrel" || + die "$0: could not determine new pkgrel\n" + +test -z "$rc" || + die "$0: MSYS2 is currently on an RC version. This script is not able to handle RC versions." + +test "$new_pkgver" = "$old_pkgver" && + new_pkgrel="$old_pkgrel" + +new_pkgrel=$(("$new_pkgrel"+1)) + +rm -f *.patch && +mv upstream/$pkgname/*.patch ./ && +rm -f PKGBUILD && +mv upstream/$pkgname/PKGBUILD ./ && +rm -f README-patches.md && +mv upstream/$pkgname/README-patches.md ./ || die "$0: failed to replace existing files with upstream files" + +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="host"/' \ + -e 's/-DLLVM_ENABLE_SPHINX=ON/-DLLVM_ENABLE_SPHINX=OFF/'\ + -e '/^check()/,/^}/d' \ + -i PKGBUILD + +cleanup