From f49e2f9aa5ef97468834f72bd0cae2b1b8939626 Mon Sep 17 00:00:00 2001 From: Zhongteng Gui Date: Tue, 30 Jun 2026 03:27:22 +0800 Subject: [PATCH 1/3] ghc: restore version 8.6.5 --- mingw-w64-ghc/0001-use-system-gmp.patch | 10 + ...0.patch => 0002-Switch-LLVM-version.patch} | 2 +- mingw-w64-ghc/0003-fix-build-with-ucrt.patch | 60 +++++ mingw-w64-ghc/0004-fix-windres.patch | 26 ++ mingw-w64-ghc/0005-fix-install.patch | 57 +++++ mingw-w64-ghc/PKGBUILD | 238 ++++++++++-------- mingw-w64-ghc/build.mk | 9 +- mingw-w64-ghc/print-provide-replaces.sh | 12 +- 8 files changed, 296 insertions(+), 118 deletions(-) create mode 100644 mingw-w64-ghc/0001-use-system-gmp.patch rename mingw-w64-ghc/{0002-Switch-to-LLVM-version-7.0.patch => 0002-Switch-LLVM-version.patch} (96%) create mode 100644 mingw-w64-ghc/0003-fix-build-with-ucrt.patch create mode 100644 mingw-w64-ghc/0004-fix-windres.patch create mode 100644 mingw-w64-ghc/0005-fix-install.patch diff --git a/mingw-w64-ghc/0001-use-system-gmp.patch b/mingw-w64-ghc/0001-use-system-gmp.patch new file mode 100644 index 0000000000000..4bdc9ac942804 --- /dev/null +++ b/mingw-w64-ghc/0001-use-system-gmp.patch @@ -0,0 +1,10 @@ +--- ghc-8.6.5/libraries/integer-gmp/gmp/ghc.mk.orig 2019-04-08 03:39:58.000000000 +0800 ++++ ghc-8.6.5/libraries/integer-gmp/gmp/ghc.mk 2026-06-29 20:27:55.692507600 +0800 +@@ -42,7 +42,6 @@ + ifeq "$(Windows_Host)" "YES" + # Apparently building on Windows fails when there is a system gmp + # available, so we never try to use the system gmp on Windows +-libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp + endif + + ifeq "$(GMP_PREFER_FRAMEWORK)" "YES" diff --git a/mingw-w64-ghc/0002-Switch-to-LLVM-version-7.0.patch b/mingw-w64-ghc/0002-Switch-LLVM-version.patch similarity index 96% rename from mingw-w64-ghc/0002-Switch-to-LLVM-version-7.0.patch rename to mingw-w64-ghc/0002-Switch-LLVM-version.patch index 1c8d37c7b4b8c..311a786549ac3 100644 --- a/mingw-w64-ghc/0002-Switch-to-LLVM-version-7.0.patch +++ b/mingw-w64-ghc/0002-Switch-LLVM-version.patch @@ -7,7 +7,7 @@ index 664deb4..f4b839e 100644 # versions of LLVM simultaneously, but that stopped working around # 3.5/3.6 release of LLVM. -LlvmVersion=6.0 -+LlvmVersion=7.0 ++LlvmVersion=22.1 AC_SUBST([LlvmVersion]) sUPPORTED_LLVM_VERSION=$(echo \($LlvmVersion\) | sed 's/\./,/') AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION], ${sUPPORTED_LLVM_VERSION}, [The supported LLVM version number]) diff --git a/mingw-w64-ghc/0003-fix-build-with-ucrt.patch b/mingw-w64-ghc/0003-fix-build-with-ucrt.patch new file mode 100644 index 0000000000000..b7ed7389b7743 --- /dev/null +++ b/mingw-w64-ghc/0003-fix-build-with-ucrt.patch @@ -0,0 +1,60 @@ +--- ghc-8.6.5/rts/RtsSymbols.c.orig 2026-06-29 22:22:19.848368500 +0800 ++++ ghc-8.6.5/rts/RtsSymbols.c 2026-06-29 22:59:30.712087400 +0800 +@@ -102,14 +102,11 @@ + SymI_HasProto(atexit) \ + RTS_WIN32_ONLY(SymI_NeedsProto(__chkstk_ms)) \ + RTS_WIN64_ONLY(SymI_NeedsProto(___chkstk_ms)) \ +- RTS_WIN32_ONLY(SymI_HasProto(_imp___environ)) \ +- RTS_WIN64_ONLY(SymI_HasProto(__imp__environ)) \ +- RTS_WIN32_ONLY(SymI_HasProto(_imp___iob)) \ +- RTS_WIN64_ONLY(SymI_HasProto(__iob_func)) \ + RTS_WIN64_ONLY(SymI_HasProto(__mingw_vsnwprintf)) \ + /* see Note [Symbols for MinGW's printf] */ \ + SymI_HasProto(_lock_file) \ +- SymI_HasProto(_unlock_file) ++ SymI_HasProto(_unlock_file) \ ++ SymI_HasProto(__acrt_iob_func) + + #define RTS_MINGW_COMPAT_SYMBOLS \ + SymI_HasProto_deprecated(access) \ +--- ghc-8.6.5/rts/win32/ConsoleHandler.c.orig 2026-06-29 22:22:19.928336300 +0800 ++++ ghc-8.6.5/rts/win32/ConsoleHandler.c 2026-06-30 00:01:15.856326200 +0800 +@@ -9,6 +9,7 @@ + #include "RtsUtils.h" + #include "AsyncIO.h" + #include "RtsSignals.h" ++#include "ThreadLabels.h" + + extern int stg_InstallConsoleEvent(int action, StgStablePtr *handler); + +--- ghc-8.6.5/rts/win32/OSMem.c.orig 2026-06-29 22:22:19.923546300 +0800 ++++ ghc-8.6.5/rts/win32/OSMem.c 2026-06-30 00:00:37.631885300 +0800 +@@ -37,28 +37,11 @@ + /* free_blocks are kept in ascending order, and adjacent blocks are merged */ + static block_rec* free_blocks = NULL; + +-/* Mingw-w64 does not currently have this in their header. So we have to import it.*/ +-typedef LPVOID(WINAPI *VirtualAllocExNumaProc)(HANDLE, LPVOID, SIZE_T, DWORD, DWORD, DWORD); +- +-/* Cache NUMA API call. */ +-VirtualAllocExNumaProc VirtualAllocExNuma; +- + void + osMemInit(void) + { + allocs = NULL; + free_blocks = NULL; +- +- /* Resolve and cache VirtualAllocExNuma. */ +- if (osNumaAvailable() && RtsFlags.GcFlags.numa) +- { +- VirtualAllocExNuma = (VirtualAllocExNumaProc)GetProcAddress(GetModuleHandleW(L"kernel32"), "VirtualAllocExNuma"); +- if (!VirtualAllocExNuma) +- { +- sysErrorBelch( +- "osBindMBlocksToNode: VirtualAllocExNuma does not exist. How did you get this far?"); +- } +- } + } + + static diff --git a/mingw-w64-ghc/0004-fix-windres.patch b/mingw-w64-ghc/0004-fix-windres.patch new file mode 100644 index 0000000000000..9d0fe879f27a6 --- /dev/null +++ b/mingw-w64-ghc/0004-fix-windres.patch @@ -0,0 +1,26 @@ +Port from https://github.com/ghc/ghc/commit/3302f42a57a9e26423e30221e455de5a173cd6c5 +--- ghc-8.6.5/compiler/main/SysTools/Tasks.hs.orig 2026-06-29 23:10:09.998057500 +0800 ++++ ghc-8.6.5/compiler/main/SysTools/Tasks.hs 2026-06-29 23:11:02.861676300 +0800 +@@ -326,17 +326,15 @@ + args' = -- If windres.exe and gcc.exe are in a directory containing + -- spaces then windres fails to run gcc. We therefore need + -- to tell it what command to use... +- Option ("--preprocessor=" ++ +- unwords (map quote (gcc : +- map showOpt gcc_args ++ +- map showOpt opts ++ +- ["-E", "-xc", "-DRC_INVOKED"]))) ++ [ Option ("--preprocessor=" ++ quote gcc) ] ++ ++ map (Option . ("--preprocessor-arg=" ++) . quote) ++ (map showOpt gcc_args ++ map showOpt opts ++ ["-E", "-xc", "-DRC_INVOKED"]) + -- ...but if we do that then if windres calls popen then + -- it can't understand the quoting, so we have to use + -- --use-temp-file so that it interprets it correctly. + -- See #1828. +- : Option "--use-temp-file" +- : args ++ ++ [ Option "--use-temp-file" ] ++ ++ args + mb_env <- getGccEnv gcc_args + runSomethingFiltered dflags id "Windres" windres args' Nothing mb_env + diff --git a/mingw-w64-ghc/0005-fix-install.patch b/mingw-w64-ghc/0005-fix-install.patch new file mode 100644 index 0000000000000..a07c3f5be6915 --- /dev/null +++ b/mingw-w64-ghc/0005-fix-install.patch @@ -0,0 +1,57 @@ +--- ghc-8.6.5/ghc.mk.orig 2019-04-08 03:39:58.000000000 +0800 ++++ ghc-8.6.5/ghc.mk 2026-06-30 02:55:18.543108600 +0800 +@@ -819,20 +819,6 @@ + # ----------------------------------------------------------------------------- + # Creating a local mingw copy on Windows + +-ifeq "$(Windows_Host)" "YES" +- +-install : install_mingw +-.PHONY: install_mingw +-install_mingw : $(INPLACE_MINGW) +- "$(CP)" -Rp $(INPLACE_MINGW) $(prefix) +- +-install : install_perl +-.PHONY: install_perl +-install_perl : $(INPLACE_PERL) +- "$(CP)" -Rp $(INPLACE_PERL) $(prefix) +- +-endif # Windows_Host +- + ifneq "$(BINDIST)" "YES" + $(ghc-prim-$(libraries/ghc-prim_dist-install_VERSION)_HADDOCK_FILE): \ + libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs +--- ghc-8.6.5/compiler/main/SysTools/BaseDir.hs.orig 2019-04-08 03:39:58.000000000 +0800 ++++ ghc-8.6.5/compiler/main/SysTools/BaseDir.hs 2026-06-30 03:03:20.276421800 +0800 +@@ -92,12 +92,7 @@ + -- | Expand occurrences of the @$tooldir@ interpolation in a string + -- on Windows, leave the string untouched otherwise. + expandToolDir :: Maybe FilePath -> String -> String +-#if defined(mingw32_HOST_OS) +-expandToolDir (Just tool_dir) s = expandPathVar "tooldir" tool_dir s +-expandToolDir Nothing _ = panic "Could not determine $tooldir" +-#else + expandToolDir _ s = s +-#endif + + -- | @expandPathVar var value str@ + -- +@@ -230,18 +230,4 @@ + findToolDir + :: FilePath -- ^ topdir + -> IO (Maybe FilePath) +-#if defined(mingw32_HOST_OS) +-findToolDir top_dir = go 0 (top_dir "..") +- where maxDepth = 2 +- go :: Int -> FilePath -> IO (Maybe FilePath) +- go k path +- | k == maxDepth = throwGhcExceptionIO $ +- InstallationError "could not detect mingw toolchain" +- | otherwise = do +- oneLevel <- doesDirectoryExist (path "mingw") +- if oneLevel +- then return (Just path) +- else go (k+1) (path "..") +-#else + findToolDir _ = return Nothing +-#endif diff --git a/mingw-w64-ghc/PKGBUILD b/mingw-w64-ghc/PKGBUILD index 6ef9be3240cb5..e25423c042b60 100644 --- a/mingw-w64-ghc/PKGBUILD +++ b/mingw-w64-ghc/PKGBUILD @@ -1,95 +1,100 @@ # Maintainer ncihnegn # Maintainer: Alethea Rose +# Contributor: dragon-archer _realname=ghc pkgbase=mingw-w64-${_realname} pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" pkgver=8.6.5 -pkgrel=2 +pkgrel=3 pkgdesc="The Glorious Glasgow Haskell Compilation System (mingw-w64)" arch=('any') -mingw_arch=() +mingw_arch=('ucrt64') group="${MINGW_PACKAGE_PREFIX}-haskell-platform" url='https://www.haskell.org/ghc/' msys2_repository_url='https://gitlab.haskell.org/ghc/ghc' license=('The Glasgow Haskell Compiler License') -depends=("${MINGW_PACKAGE_PREFIX}-cc" - "${MINGW_PACKAGE_PREFIX}-cc-libs" - "${MINGW_PACKAGE_PREFIX}-gmp" - "${MINGW_PACKAGE_PREFIX}-isl" - "${MINGW_PACKAGE_PREFIX}-libiconv" - "${MINGW_PACKAGE_PREFIX}-libffi" - "${MINGW_PACKAGE_PREFIX}-libwinpthread" - "${MINGW_PACKAGE_PREFIX}-mpc" - "${MINGW_PACKAGE_PREFIX}-mpfr") -makedepends=("${MINGW_PACKAGE_PREFIX}-python-sphinx" - "${MINGW_PACKAGE_PREFIX}-llvm" - "${MINGW_PACKAGE_PREFIX}-autotools" - 'perl') -provides=("${MINGW_PACKAGE_PREFIX}-haskell-array=0.5.3.0" - "${MINGW_PACKAGE_PREFIX}-haskell-base=4.12.0.0" - "${MINGW_PACKAGE_PREFIX}-haskell-binary=0.8.6.0" - "${MINGW_PACKAGE_PREFIX}-haskell-bytestring=0.10.8.2" - "${MINGW_PACKAGE_PREFIX}-haskell-containers=0.6.0.1" - "${MINGW_PACKAGE_PREFIX}-haskell-deepseq=1.4.4.0" - "${MINGW_PACKAGE_PREFIX}-haskell-directory=1.3.3.0" - "${MINGW_PACKAGE_PREFIX}-haskell-filepath=1.4.2.1" - "${MINGW_PACKAGE_PREFIX}-haskell-ghc-boot=${pkgver}" - "${MINGW_PACKAGE_PREFIX}-haskell-ghc-boot-th=${pkgver}" - "${MINGW_PACKAGE_PREFIX}-haskell-ghc-compact=0.1.0.0" - "${MINGW_PACKAGE_PREFIX}-haskell-ghci=${pkgver}" - "${MINGW_PACKAGE_PREFIX}-haskell-ghc-heap=${pkgver}" - "${MINGW_PACKAGE_PREFIX}-haskell-ghc-prim=0.5.3.0" - "${MINGW_PACKAGE_PREFIX}-haskell-haskeline=0.7.4.3" - "${MINGW_PACKAGE_PREFIX}-haskell-hpc=0.6.0.3" - "${MINGW_PACKAGE_PREFIX}-haskell-integer-gmp=1.0.2.0" - "${MINGW_PACKAGE_PREFIX}-haskell-integer-simple=0.1.1.1" - "${MINGW_PACKAGE_PREFIX}-haskell-libiserv=${pkgver}" - "${MINGW_PACKAGE_PREFIX}-haskell-mtl=2.2.2" - "${MINGW_PACKAGE_PREFIX}-haskell-parsec=3.1.13.0" - "${MINGW_PACKAGE_PREFIX}-haskell-pretty=1.1.3.6" - "${MINGW_PACKAGE_PREFIX}-haskell-process=1.6.5.0" - "${MINGW_PACKAGE_PREFIX}-haskell-stm=2.5.0.0" - "${MINGW_PACKAGE_PREFIX}-haskell-template-haskell=2.14.0.0" - "${MINGW_PACKAGE_PREFIX}-haskell-terminfo=0.4.1.2" - "${MINGW_PACKAGE_PREFIX}-haskell-text=1.2.3.1" - "${MINGW_PACKAGE_PREFIX}-haskell-time=1.8.0.2" - "${MINGW_PACKAGE_PREFIX}-haskell-transformers=0.5.6.2" - "${MINGW_PACKAGE_PREFIX}-haskell-win32=2.7.2.2" - "${MINGW_PACKAGE_PREFIX}-haskell-xhtml=3000.2.2.1" - "${MINGW_PACKAGE_PREFIX}-haskell-cabal=2.4.0.1") -replaces=("${MINGW_PACKAGE_PREFIX}-haskell-array" - "${MINGW_PACKAGE_PREFIX}-haskell-base" - "${MINGW_PACKAGE_PREFIX}-haskell-binary" - "${MINGW_PACKAGE_PREFIX}-haskell-bytestring" - "${MINGW_PACKAGE_PREFIX}-haskell-containers" - "${MINGW_PACKAGE_PREFIX}-haskell-deepseq" - "${MINGW_PACKAGE_PREFIX}-haskell-directory" - "${MINGW_PACKAGE_PREFIX}-haskell-filepath" - "${MINGW_PACKAGE_PREFIX}-haskell-ghc-boot" - "${MINGW_PACKAGE_PREFIX}-haskell-ghc-boot-th" - "${MINGW_PACKAGE_PREFIX}-haskell-ghc-compact" - "${MINGW_PACKAGE_PREFIX}-haskell-ghci" - "${MINGW_PACKAGE_PREFIX}-haskell-ghc-heap" - "${MINGW_PACKAGE_PREFIX}-haskell-ghc-prim" - "${MINGW_PACKAGE_PREFIX}-haskell-haskeline" - "${MINGW_PACKAGE_PREFIX}-haskell-hpc" - "${MINGW_PACKAGE_PREFIX}-haskell-integer-gmp" - "${MINGW_PACKAGE_PREFIX}-haskell-integer-simple" - "${MINGW_PACKAGE_PREFIX}-haskell-libiserv" - "${MINGW_PACKAGE_PREFIX}-haskell-mtl" - "${MINGW_PACKAGE_PREFIX}-haskell-parsec" - "${MINGW_PACKAGE_PREFIX}-haskell-pretty" - "${MINGW_PACKAGE_PREFIX}-haskell-process" - "${MINGW_PACKAGE_PREFIX}-haskell-stm" - "${MINGW_PACKAGE_PREFIX}-haskell-template-haskell" - "${MINGW_PACKAGE_PREFIX}-haskell-terminfo" - "${MINGW_PACKAGE_PREFIX}-haskell-text" - "${MINGW_PACKAGE_PREFIX}-haskell-time" - "${MINGW_PACKAGE_PREFIX}-haskell-transformers" - "${MINGW_PACKAGE_PREFIX}-haskell-win32" - "${MINGW_PACKAGE_PREFIX}-haskell-xhtml" - "${MINGW_PACKAGE_PREFIX}-haskell-cabal") +depends=( + "${MINGW_PACKAGE_PREFIX}-cc" + "${MINGW_PACKAGE_PREFIX}-cc-libs" + "${MINGW_PACKAGE_PREFIX}-gmp" + "${MINGW_PACKAGE_PREFIX}-isl" + "${MINGW_PACKAGE_PREFIX}-libiconv" + "${MINGW_PACKAGE_PREFIX}-libffi" + "${MINGW_PACKAGE_PREFIX}-libwinpthread" + "${MINGW_PACKAGE_PREFIX}-mpc" + "${MINGW_PACKAGE_PREFIX}-mpfr" +) +makedepends=( + "${MINGW_PACKAGE_PREFIX}-python-sphinx" + "${MINGW_PACKAGE_PREFIX}-llvm" + "${MINGW_PACKAGE_PREFIX}-autotools" + "${MINGW_PACKAGE_PREFIX}-perl" +) +provides=( + "${MINGW_PACKAGE_PREFIX}-haskell-array=0.5.3.0" + "${MINGW_PACKAGE_PREFIX}-haskell-base=4.12.0.0" + "${MINGW_PACKAGE_PREFIX}-haskell-binary=0.8.6.0" + "${MINGW_PACKAGE_PREFIX}-haskell-bytestring=0.10.8.2" + "${MINGW_PACKAGE_PREFIX}-haskell-containers=0.6.0.1" + "${MINGW_PACKAGE_PREFIX}-haskell-deepseq=1.4.4.0" + "${MINGW_PACKAGE_PREFIX}-haskell-directory=1.3.3.0" + "${MINGW_PACKAGE_PREFIX}-haskell-filepath=1.4.2.1" + "${MINGW_PACKAGE_PREFIX}-haskell-ghc-boot=8.6.5" + "${MINGW_PACKAGE_PREFIX}-haskell-ghc-boot-th=8.6.5" + "${MINGW_PACKAGE_PREFIX}-haskell-ghc-compact=0.1.0.0" + "${MINGW_PACKAGE_PREFIX}-haskell-ghc-heap=8.6.5" + "${MINGW_PACKAGE_PREFIX}-haskell-ghc-prim=0.5.3" + "${MINGW_PACKAGE_PREFIX}-haskell-haskeline=0.7.4.3" + "${MINGW_PACKAGE_PREFIX}-haskell-hpc=0.6.0.3" + "${MINGW_PACKAGE_PREFIX}-haskell-integer-gmp=1.0.2.0" + "${MINGW_PACKAGE_PREFIX}-haskell-libiserv=8.6.3" + "${MINGW_PACKAGE_PREFIX}-haskell-mtl=2.2.2" + "${MINGW_PACKAGE_PREFIX}-haskell-parsec=3.1.13.0" + "${MINGW_PACKAGE_PREFIX}-haskell-pretty=1.1.3.6" + "${MINGW_PACKAGE_PREFIX}-haskell-process=1.6.5.0" + "${MINGW_PACKAGE_PREFIX}-haskell-stm=2.5.0.0" + "${MINGW_PACKAGE_PREFIX}-haskell-template-haskell=2.14.0.0" + "${MINGW_PACKAGE_PREFIX}-haskell-terminfo=0.4.1.2" + "${MINGW_PACKAGE_PREFIX}-haskell-text=1.2.3.1" + "${MINGW_PACKAGE_PREFIX}-haskell-time=1.8.0.2" + "${MINGW_PACKAGE_PREFIX}-haskell-transformers=0.5.6.2" + "${MINGW_PACKAGE_PREFIX}-haskell-win32=2.6.1.0" + "${MINGW_PACKAGE_PREFIX}-haskell-xhtml=3000.2.2.1" + "${MINGW_PACKAGE_PREFIX}-haskell-cabal=2.4.0.1" + ) +replaces=( + "${MINGW_PACKAGE_PREFIX}-haskell-array" + "${MINGW_PACKAGE_PREFIX}-haskell-base" + "${MINGW_PACKAGE_PREFIX}-haskell-binary" + "${MINGW_PACKAGE_PREFIX}-haskell-bytestring" + "${MINGW_PACKAGE_PREFIX}-haskell-containers" + "${MINGW_PACKAGE_PREFIX}-haskell-deepseq" + "${MINGW_PACKAGE_PREFIX}-haskell-directory" + "${MINGW_PACKAGE_PREFIX}-haskell-filepath" + "${MINGW_PACKAGE_PREFIX}-haskell-ghc-boot" + "${MINGW_PACKAGE_PREFIX}-haskell-ghc-boot-th" + "${MINGW_PACKAGE_PREFIX}-haskell-ghc-compact" + "${MINGW_PACKAGE_PREFIX}-haskell-ghc-heap" + "${MINGW_PACKAGE_PREFIX}-haskell-ghc-prim" + "${MINGW_PACKAGE_PREFIX}-haskell-haskeline" + "${MINGW_PACKAGE_PREFIX}-haskell-hpc" + "${MINGW_PACKAGE_PREFIX}-haskell-integer-gmp" + "${MINGW_PACKAGE_PREFIX}-haskell-libiserv" + "${MINGW_PACKAGE_PREFIX}-haskell-mtl" + "${MINGW_PACKAGE_PREFIX}-haskell-parsec" + "${MINGW_PACKAGE_PREFIX}-haskell-pretty" + "${MINGW_PACKAGE_PREFIX}-haskell-process" + "${MINGW_PACKAGE_PREFIX}-haskell-stm" + "${MINGW_PACKAGE_PREFIX}-haskell-template-haskell" + "${MINGW_PACKAGE_PREFIX}-haskell-terminfo" + "${MINGW_PACKAGE_PREFIX}-haskell-text" + "${MINGW_PACKAGE_PREFIX}-haskell-time" + "${MINGW_PACKAGE_PREFIX}-haskell-transformers" + "${MINGW_PACKAGE_PREFIX}-haskell-win32" + "${MINGW_PACKAGE_PREFIX}-haskell-xhtml" + "${MINGW_PACKAGE_PREFIX}-haskell-cabal" + ) optdepends=("${MINGW_PACKAGE_PREFIX}-llvm: use LLVM for an optimized backend") install="ghc-${MSYSTEM}.install" @@ -103,53 +108,66 @@ source=("https://downloads.haskell.org/~ghc/${pkgver}/ghc-${pkgver}-src.tar.xz"{ "https://downloads.haskell.org/~ghc/${pkgver}/ghc-${pkgver}-testsuite.tar.xz"{,.sig} "https://downloads.haskell.org/~ghc/${pkgver}/ghc-${pkgver}-${_hsarch}-unknown-mingw32.tar.xz"{,.sig} 'build.mk' - '0002-Switch-to-LLVM-version-7.0.patch' + '0001-use-system-gmp.patch' + '0002-Switch-LLVM-version.patch' + '0003-fix-build-with-ucrt.patch' + '0004-fix-windres.patch' + '0005-fix-install.patch' 'ghc-register.hook' 'ghc-unregister.hook' 'ghc-rebuild-doc-index.hook') -noextract=("ghc-${pkgver}-${_hsarch}-unknown-mingw32.tar.xz") - sha256sums=('4d4aa1e96f4001b934ac6193ab09af5d6172f41f5a5d39d8e43393b9aafee361' 'SKIP' '21391cb63a8a6b327f6c9519217a3dad39493e72c48967008ae35af142ca895f' 'SKIP' - '2a8fb73080ed4335f7a172fe6cf9da1a2faa51fdb72817c50088292f497fc57a' + '457024c6ea43bdce340af428d86319931f267089398b859b00efdfe2fd4ce93f' 'SKIP' - '7001599139d0e81bcb098158eede2a3910428f69d65dbcacb9372633d0fa6076' - '6904893a6f97b2818abe89b952765752d6894e611c4838f7ebff5a6a577c18d5' + 'd1803d805849c9de2eacd72039fd00cd99899db478d4853aad202a72fc33a3f9' + '8c01538d934500fd23df1a412f848921dae00ad6267e822dd23a491769a9d96d' + 'b4b50bd478afa878a2952c6ab97c4e17bd46d671649bb5c9a7c80e6b10830b42' + '963da1916ead9f77226e9df7b13b775cb15056098fc54ed3778770b8b038f93d' + '1fd204d8c142e5aec8bdc0d104d4183c24f271478d2ba9bbe628bb708f6b0298' + '4c1d380dbb6f720f87f3414b9f9e741460916cecc542a6157b56a065993bf755' '633b6a02efa3a6f30c4c40062f24bf0ffa9689c21d0e16da09ed8b699ba6050e' '33bde1f07e6317017e9c7fc7b2e7ad2d63ed3dcde407a23401d0a03861301cea' '31f3b191bcfe7ad09a886e90f6d71c3be5bee02304a81bffe61ac1f5dcdae703') validpgpkeys=('FFEB7CE81E16A36B3E2DED6F2DE04D4E97DB64AD') # Benjamin Gamari +noextract=("ghc-${pkgver}-${_hsarch}-unknown-mingw32.tar.xz") prepare() { cd "${srcdir}" - mkdir -p ${MSYSTEM}/host - rm -rf ${MSYSTEM}/ghc-${pkgver} - mv {,$CARCH/}ghc-${pkgver} + mkdir -p prebuilt - msg "Extracting binaries: ghc-${pkgver}-${_hsarch}-unknown-mingw32.tar.xz..." - bsdtar -xf ghc-${pkgver}-${_hsarch}-unknown-mingw32.tar.xz \ - -C ${MSYSTEM}/host --strip-components 1 + msg "Extracting binaries: ${_realname}-${pkgver}-${_hsarch}-unknown-mingw32.tar.xz..." + bsdtar -xf ${_realname}-${pkgver}-${_hsarch}-unknown-mingw32.tar.xz -C prebuilt --strip-components 1 + + cp -a ${_realname}-${pkgver} build-${MSYSTEM} || true for _hook in "${_hooks[@]}"; do echo $_hook sed -e "s|MINGW_PREFIX|$(basename ${MINGW_PREFIX})|" \ - ${_hook} > ${MSYSTEM}/${_hook} + ${_hook} > build-${MSYSTEM}/${_hook} done - export PATH="${srcdir}/${MSYSTEM}/host/bin:$PATH" - - cp -v "${srcdir}/build.mk" "${srcdir}/${MSYSTEM}/ghc-${pkgver}/mk/build.mk" + cp -av "${srcdir}/build.mk" "${srcdir}/build-${MSYSTEM}/mk/build.mk" - cd "${srcdir}/${MSYSTEM}/ghc-${pkgver}" - patch -Np1 -i "${srcdir}/0002-Switch-to-LLVM-version-7.0.patch" + cd "${srcdir}/build-${MSYSTEM}" + patch -Nbp1 -i "${srcdir}/0001-use-system-gmp.patch" + patch -Nbp1 -i "${srcdir}/0002-Switch-LLVM-version.patch" + patch -Nbp1 -i "${srcdir}/0003-fix-build-with-ucrt.patch" + patch -Nbp1 -i "${srcdir}/0004-fix-windres.patch" + patch -Nbp1 -i "${srcdir}/0005-fix-install.patch" } build() { - export PATH="${srcdir}/${MSYSTEM}/host/bin:${PATH}" - cd "${srcdir}/${MSYSTEM}/ghc-${pkgver}" + cd "${srcdir}/build-${MSYSTEM}" + + export PATH="${srcdir}/prebuilt/bin:$PATH" + + ln -sfn ${MINGW_PREFIX} mingw + mkdir -p inplace + (cd inplace && ln -sfn ${MINGW_PREFIX} mingw) ./boot ./configure \ @@ -157,28 +175,30 @@ build() { --build=${MINGW_CHOST} \ --host=${MINGW_CHOST} \ --with-system-libffi \ - --enable-distro-toolchain \ - --with-ffi-includes="$(cygpath -u $(pkg-config --variable=includedir libffi))" + --enable-distro-toolchain - make - make html + # Force static linking to libffi, otherwise ghc-stage2.exe failed with + # Mingw-w64 runtime failure: 32 bit pseudo relocation at XXX out of range + install -Dm644 "${MINGW_PREFIX}/lib/libffi.a" rts/dist/build/libffi.a + + make -j } -check() { - cd "${srcdir}/${MSYSTEM}/ghc-${pkgver}" +# check() { +# cd "${srcdir}/build-${MSYSTEM}" - make test -} +# make test -j || true +# } package() { - cd "${srcdir}/${MSYSTEM}/ghc-${pkgver}" + cd "${srcdir}/build-${MSYSTEM}" make prefix="${pkgdir}${MINGW_PREFIX}" \ docdir="${pkgdir}${MINGW_PREFIX}/share/docs/ghc" \ install for _hook in "${_hooks[@]}"; do - install -Dm644 "${srcdir}/${MSYSTEM}/${_hook}" \ + install -Dm644 "${srcdir}/build-${MSYSTEM}/${_hook}" \ "${pkgdir}/usr/share/libalpm/hooks/${MINGW_PACKAGE_PREFIX}-${_hook}" done diff --git a/mingw-w64-ghc/build.mk b/mingw-w64-ghc/build.mk index de8d8c8e00036..b216e9840d572 100644 --- a/mingw-w64-ghc/build.mk +++ b/mingw-w64-ghc/build.mk @@ -8,7 +8,7 @@ # Uncomment one of these to select a build profile below: # Full build with max optimisation and everything enabled (very slow build) -BuildFlavour = perf +#BuildFlavour = perf # As above but build GHC using the LLVM backend #BuildFlavour = perf-llvm @@ -20,7 +20,7 @@ BuildFlavour = perf #BuildFlavour = perf-cross-ncg # Fast build with optimised libraries, no profiling (RECOMMENDED): -#BuildFlavour = quick +BuildFlavour = quick # Fast build with optimised libraries, no profiling, with LLVM: #BuildFlavour = quick-llvm @@ -112,3 +112,8 @@ V=0 # Don't strip debug and other unneeded symbols from libraries and executables. STRIP_CMD = : + +SRC_CC_OPTS += -std=gnu11 +# `--image-base 0x400000` roughly equals to `--default-image-base-low`, +# but the latter isn't recognized by older binutils provided by ghc bootstrap +SRC_LD_OPTS += -Wl,--image-base,0x400000 diff --git a/mingw-w64-ghc/print-provide-replaces.sh b/mingw-w64-ghc/print-provide-replaces.sh index 6af912371e679..7ed1753f89363 100755 --- a/mingw-w64-ghc/print-provide-replaces.sh +++ b/mingw-w64-ghc/print-provide-replaces.sh @@ -2,8 +2,8 @@ . PKGBUILD -if [[ ! -d src/${MSYSTEM_CARCH}/ghc-${pkgver}/libraries ]]; then - echo "error: no directory src/${MSYSTEM_CARCH}/ghc-${pkgver}/libraries: You must extract the source tarball under src/" +if [[ ! -d src/ghc-${pkgver}/libraries ]]; then + echo "error: no directory src/ghc-${pkgver}/libraries: You must extract the source tarball under src/" exit 1 fi @@ -13,16 +13,16 @@ exclude['unix']=1 # no integer-simple because we use integer-gmp exclude['integer-simple']=1 # extract excluded libraries from ghc.mk -for exclude_pkg in $(sed 's/PKGS_THAT_ARE_INTREE_ONLY := //p' -n src/${MSYSTEM_CARCH}/ghc-${pkgver}/ghc.mk); do +for exclude_pkg in $(sed 's/PKGS_THAT_ARE_INTREE_ONLY := //p' -n src/ghc-${pkgver}/ghc.mk); do exclude[${exclude_pkg}]=1 done -cd src/${MSYSTEM_CARCH}/ghc-${pkgver}/libraries +cd src/ghc-${pkgver}/libraries # $1 is the name of the variable # $2 is the string for the test, either '=' or '<' print_var() { - printf "$1=(" + printf "$1=(\n " for path in $(ls ./*/*.cabal Cabal/Cabal*/Cabal.cabal); do dirname=$(echo $path | awk -F '/' '{ print $2 }') cabalfile=$(echo $path | awk -F '/' '{ print $3 }') @@ -31,7 +31,7 @@ print_var() { version=$(awk 'tolower($0) ~ /^version:/ {print $2 }' $path) printf "\"\${MINGW_PACKAGE_PREFIX}-haskell-${cabalname,,}" [[ -n "$2" ]] && printf "$2$version" - printf "\"\n " + printf "\"\n " done echo -e '\b)' } From ce248f6b9a39653e007ab7012a1ce05cd9642e10 Mon Sep 17 00:00:00 2001 From: Zhongteng Gui Date: Tue, 30 Jun 2026 03:45:31 +0800 Subject: [PATCH 2/3] fix missing import --- mingw-w64-ghc/0003-fix-build-with-ucrt.patch | 5 +++-- mingw-w64-ghc/PKGBUILD | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mingw-w64-ghc/0003-fix-build-with-ucrt.patch b/mingw-w64-ghc/0003-fix-build-with-ucrt.patch index b7ed7389b7743..af8269986f43b 100644 --- a/mingw-w64-ghc/0003-fix-build-with-ucrt.patch +++ b/mingw-w64-ghc/0003-fix-build-with-ucrt.patch @@ -1,6 +1,6 @@ --- ghc-8.6.5/rts/RtsSymbols.c.orig 2026-06-29 22:22:19.848368500 +0800 +++ ghc-8.6.5/rts/RtsSymbols.c 2026-06-29 22:59:30.712087400 +0800 -@@ -102,14 +102,11 @@ +@@ -102,14 +102,12 @@ SymI_HasProto(atexit) \ RTS_WIN32_ONLY(SymI_NeedsProto(__chkstk_ms)) \ RTS_WIN64_ONLY(SymI_NeedsProto(___chkstk_ms)) \ @@ -13,7 +13,8 @@ SymI_HasProto(_lock_file) \ - SymI_HasProto(_unlock_file) + SymI_HasProto(_unlock_file) \ -+ SymI_HasProto(__acrt_iob_func) ++ SymI_HasProto(__acrt_iob_func) \ ++ RTS_WIN64_ONLY(SymI_NeedsDataProto(__imp___acrt_iob_func)) #define RTS_MINGW_COMPAT_SYMBOLS \ SymI_HasProto_deprecated(access) \ diff --git a/mingw-w64-ghc/PKGBUILD b/mingw-w64-ghc/PKGBUILD index e25423c042b60..259fa81f655de 100644 --- a/mingw-w64-ghc/PKGBUILD +++ b/mingw-w64-ghc/PKGBUILD @@ -125,7 +125,7 @@ sha256sums=('4d4aa1e96f4001b934ac6193ab09af5d6172f41f5a5d39d8e43393b9aafee361' 'd1803d805849c9de2eacd72039fd00cd99899db478d4853aad202a72fc33a3f9' '8c01538d934500fd23df1a412f848921dae00ad6267e822dd23a491769a9d96d' 'b4b50bd478afa878a2952c6ab97c4e17bd46d671649bb5c9a7c80e6b10830b42' - '963da1916ead9f77226e9df7b13b775cb15056098fc54ed3778770b8b038f93d' + 'c86c87edda0482c8b978c5cd19ef171c109c0d192ab8e1641e3526cf3586bdbb' '1fd204d8c142e5aec8bdc0d104d4183c24f271478d2ba9bbe628bb708f6b0298' '4c1d380dbb6f720f87f3414b9f9e741460916cecc542a6157b56a065993bf755' '633b6a02efa3a6f30c4c40062f24bf0ffa9689c21d0e16da09ed8b699ba6050e' From 71731413080a477dc4cd09aa029de3dba1fa6654 Mon Sep 17 00:00:00 2001 From: Zhongteng Gui Date: Sat, 4 Jul 2026 17:22:23 +0800 Subject: [PATCH 3/3] try fix static linking --- mingw-w64-ghc/0003-fix-build-with-ucrt.patch | 129 +++++++++++++++++- ...l.patch => 0005-fix-hardcoded-mingw.patch} | 20 +++ mingw-w64-ghc/0006-dynamic-libs.patch | 96 +++++++++++++ mingw-w64-ghc/PKGBUILD | 30 ++-- mingw-w64-ghc/build.mk | 2 +- 5 files changed, 258 insertions(+), 19 deletions(-) rename mingw-w64-ghc/{0005-fix-install.patch => 0005-fix-hardcoded-mingw.patch} (73%) create mode 100644 mingw-w64-ghc/0006-dynamic-libs.patch diff --git a/mingw-w64-ghc/0003-fix-build-with-ucrt.patch b/mingw-w64-ghc/0003-fix-build-with-ucrt.patch index af8269986f43b..1d34a095a7150 100644 --- a/mingw-w64-ghc/0003-fix-build-with-ucrt.patch +++ b/mingw-w64-ghc/0003-fix-build-with-ucrt.patch @@ -1,5 +1,35 @@ +--- ghc-8.6.5/libraries/base/base.cabal.orig ++++ ghc-8.6.5/libraries/base/base.cabal +@@ -366,7 +366,7 @@ + -- mingw32: Unfortunately required because of a resource leak between + -- mingwex and mingw32. the __math_err symbol is defined in + -- mingw32 which is required by mingwex. +- extra-libraries: wsock32, user32, shell32, msvcrt, mingw32, mingwex ++ extra-libraries: wsock32, user32, shell32, shlwapi, msvcrt, mingw32, mingwex + exposed-modules: + GHC.IO.Encoding.CodePage.API + GHC.IO.Encoding.CodePage.Table --- ghc-8.6.5/rts/RtsSymbols.c.orig 2026-06-29 22:22:19.848368500 +0800 +++ ghc-8.6.5/rts/RtsSymbols.c 2026-06-29 22:59:30.712087400 +0800 +@@ -38,12 +38,12 @@ + SymI_HasProto(stg_finalizzeWeakzh) + + #define RTS_LIBDW_SYMBOLS \ +- SymE_HasProto(backtraceFree) \ +- SymE_HasProto(libdwGetBacktrace) \ +- SymE_HasProto(libdwLookupLocation) \ +- SymE_HasProto(libdwPoolTake) \ +- SymE_HasProto(libdwPoolRelease) \ +- SymE_HasProto(libdwPoolClear) ++ SymI_HasProto(backtraceFree) \ ++ SymI_HasProto(libdwGetBacktrace) \ ++ SymI_HasProto(libdwLookupLocation) \ ++ SymI_HasProto(libdwPoolTake) \ ++ SymI_HasProto(libdwPoolRelease) \ ++ SymI_HasProto(libdwPoolClear) + + #if !defined (mingw32_HOST_OS) + #define RTS_POSIX_ONLY_SYMBOLS \ @@ -102,14 +102,12 @@ SymI_HasProto(atexit) \ RTS_WIN32_ONLY(SymI_NeedsProto(__chkstk_ms)) \ @@ -14,10 +44,107 @@ - SymI_HasProto(_unlock_file) + SymI_HasProto(_unlock_file) \ + SymI_HasProto(__acrt_iob_func) \ -+ RTS_WIN64_ONLY(SymI_NeedsDataProto(__imp___acrt_iob_func)) ++ SymI_NeedsDataProto(__imp___acrt_iob_func) #define RTS_MINGW_COMPAT_SYMBOLS \ SymI_HasProto_deprecated(access) \ +@@ -966,7 +964,7 @@ + #define SymI_NeedsProto(vvv) extern void vvv(void); + #define SymI_NeedsDataProto(vvv) extern StgWord vvv[]; + #if defined(COMPILING_WINDOWS_DLL) +-#define SymE_HasProto(vvv) SymE_HasProto(vvv); ++#define SymE_HasProto(vvv) SymE_NeedsProto(vvv); + # if defined(x86_64_HOST_ARCH) + # define SymE_NeedsProto(vvv) extern void __imp_ ## vvv (void); + # define SymE_NeedsDataProto(vvv) SymE_NeedsProto(vvv) +--- ghc-8.6.5/rts/RtsAPI.c.orig 2019-04-08 03:39:58.000000000 +0800 ++++ ghc-8.6.5/rts/RtsAPI.c 2026-06-30 15:14:13.097572400 +0800 +@@ -475,7 +475,7 @@ + SchedulerStatus stat; + + p = (StgClosure *)deRefStablePtr(s); +- w = rts_apply(*cap, &base_GHCziTopHandler_runMainIO_closure, p); ++ w = rts_apply(*cap, runMainIO_closure, p); + tso = createStrictIOThread(*cap, RtsFlags.GcFlags.initialStkSize, w); + // async exceptions are always blocked by default in the created + // thread. See #1048. +--- ghc-8.6.5/rts/ghc.mk.orig 2019-04-08 03:39:58.000000000 +0800 ++++ ghc-8.6.5/rts/ghc.mk 2026-06-30 17:00:00.000000000 +0800 +@@ -203,14 +203,18 @@ + + ifneq "$$(UseSystemLibFFI)" "YES" + rts_dist_FFI_SO = rts/dist/build/lib$$(LIBFFI_NAME)$$(soext) ++rts_dist_FFI_DLL = rts/dist/build/$$(LIBFFI_DLL) ++rts_dist_FFI_LIBS = -Lrts/dist/build -l$$(LIBFFI_NAME) + else + rts_dist_FFI_SO = ++rts_dist_FFI_DLL = ++rts_dist_FFI_LIBS = + endif + + # Making a shared library for the RTS. + ifneq "$$(findstring dyn, $1)" "" + ifeq "$$(TargetOS_CPP)" "mingw32" +-$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/dist/libs.depend rts/dist/build/$$(LIBFFI_DLL) ++$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/dist/libs.depend $$(rts_dist_FFI_DLL) + "$$(RM)" $$(RM_OPTS) $$@ + # Call out to the shell script to decide how to build the dll. + # Making a shared library for the RTS. +@@ -226,7 +230,7 @@ + # $$10 = SxS Name + # $$11 = SxS Version + $$(gen-dll_INPLACE) link "rts/dist/build" "rts/dist/build" "" "" "$$(ALL_RTS_DEF_LIBS)" "$$(rts_$1_OBJS)" "$$@" "$$(rts_dist_HC) -this-unit-id rts -no-hs-main -shared -dynamic -dynload deploy \ +- -no-auto-link-packages -Lrts/dist/build -l$$(LIBFFI_NAME) \ ++ -no-auto-link-packages $$(rts_dist_FFI_LIBS) \ + `cat rts/dist/libs.depend | tr '\n' ' '` \ + $$(rts_dist_$1_GHC_LD_OPTS)" "NO" \ + "$(rts_INSTALL_INFO)-$(subst dyn,,$(subst _dyn,,$(subst v,,$1)))" "$(ProjectVersion)" +--- ghc-8.6.5/rts/rts.cabal.in.orig 2019-04-08 03:39:58.000000000 +0800 ++++ ghc-8.6.5/rts/rts.cabal.in 2026-06-30 16:20:00.000000000 +0800 +@@ -36,9 +36,7 @@ + -- expects the unit-id to be + -- set without version + ghc-options: -this-unit-id rts +- if os(windows) +- extra-bundled-libraries: Cffi-6 +- else ++ if !os(windows) + extra-bundled-libraries: Cffi + -- the rts comes in a variety of flavours that ar built outside + -- of cabal. The combination of extra-bundled-libraries and +--- ghc-8.6.5/rts/rts.cabal.orig 2019-04-08 03:39:58.000000000 +0800 ++++ ghc-8.6.5/rts/rts.cabal 2026-06-30 16:20:00.000000000 +0800 +@@ -36,9 +36,7 @@ + -- expects the unit-id to be + -- set without version + ghc-options: -this-unit-id rts +- if os(windows) +- extra-bundled-libraries: Cffi-6 +- else ++ if !os(windows) + extra-bundled-libraries: Cffi + -- the rts comes in a variety of flavours that ar built outside + -- of cabal. The combination of extra-bundled-libraries and +--- ghc-8.6.5/rts/win32/libHSbase.def.orig ++++ ghc-8.6.5/rts/win32/libHSbase.def +@@ -18,6 +18,7 @@ + base_GHCziPack_unpackCString_closure + + base_GHCziTopHandler_runIO_closure ++ base_GHCziTopHandler_runMainIO_closure + base_GHCziTopHandler_runNonIO_closure + + base_GHCziIOziException_stackOverflow_closure +--- ghc-8.6.5/rts/win32/libHSghc-prim.def.orig ++++ ghc-8.6.5/rts/win32/libHSghc-prim.def +@@ -3,6 +3,7 @@ + + EXPORTS + ++ ghczmprim_GHCziTuple_Z0T_closure + ghczmprim_GHCziTypes_True_closure + ghczmprim_GHCziTypes_False_closure + ghczmprim_GHCziTypes_Czh_con_info --- ghc-8.6.5/rts/win32/ConsoleHandler.c.orig 2026-06-29 22:22:19.928336300 +0800 +++ ghc-8.6.5/rts/win32/ConsoleHandler.c 2026-06-30 00:01:15.856326200 +0800 @@ -9,6 +9,7 @@ diff --git a/mingw-w64-ghc/0005-fix-install.patch b/mingw-w64-ghc/0005-fix-hardcoded-mingw.patch similarity index 73% rename from mingw-w64-ghc/0005-fix-install.patch rename to mingw-w64-ghc/0005-fix-hardcoded-mingw.patch index a07c3f5be6915..a94101e191246 100644 --- a/mingw-w64-ghc/0005-fix-install.patch +++ b/mingw-w64-ghc/0005-fix-hardcoded-mingw.patch @@ -55,3 +55,23 @@ -#else findToolDir _ = return Nothing -#endif +--- ghc-8.6.5/mk/config.mk.in.orig ++++ ghc-8.6.5/mk/config.mk.in +@@ -670,7 +670,7 @@ + ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32" + WINDRES = $(INPLACE_MINGW)/bin/windres + else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32" +-WINDRES = $(INPLACE_MINGW)/bin/windres ++WINDRES = windres + endif + + #----------------------------------------------------------------------------- +@@ -680,7 +680,7 @@ + ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32" + DLLTOOL = inplace/mingw/bin/dlltool.exe + else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32" +-DLLTOOL = inplace/mingw/bin/dlltool.exe ++DLLTOOL = dlltool.exe + endif + + #----------------------------------------------------------------------------- diff --git a/mingw-w64-ghc/0006-dynamic-libs.patch b/mingw-w64-ghc/0006-dynamic-libs.patch new file mode 100644 index 0000000000000..138873f7ab755 --- /dev/null +++ b/mingw-w64-ghc/0006-dynamic-libs.patch @@ -0,0 +1,96 @@ +--- ghc-8.6.5/mk/config.mk.in.orig ++++ ghc-8.6.5/mk/config.mk.in +@@ -111,7 +111,6 @@ + # Some platforms don't support shared libraries + NoSharedLibsPlatformList = \ + powerpc-ibm-aix \ +- x86_64-unknown-mingw32 \ + i386-unknown-mingw32 + + ifeq "$(SOLARIS_BROKEN_SHLD)" "YES" +@@ -129,9 +128,7 @@ + # Currently this isn't possible on Windows, and we have not yet enabled + # it on i386 while we consider the performance implications. + # +-ifeq "$(TargetOS_CPP)" "mingw32" +-DYNAMIC_BY_DEFAULT = NO +-else ifeq "$(TargetArch_CPP)" "i386" ++ifeq "$(TargetArch_CPP)" "i386" + DYNAMIC_BY_DEFAULT = NO + else + DYNAMIC_BY_DEFAULT = YES +@@ -144,15 +141,14 @@ + # If building both v and dyn ways, then use -dynamic-too to build them. + # This makes the build faster. + DYNAMIC_TOO = YES ++ifeq "$(TargetOS_CPP)" "mingw32" ++DYNAMIC_TOO = NO ++endif + + # Use the dynamic way when building programs in the GHC tree. In + # particular, this means that GHCi will use DLLs rather than loading + # object files directly. +-ifeq "$(TargetOS_CPP)" "mingw32" +-# This doesn't work on Windows yet +-DYNAMIC_GHC_PROGRAMS = NO +-DYNAMIC_TOO=NO +-else ifeq "$(PlatformSupportsSharedLibs)" "NO" ++ifeq "$(PlatformSupportsSharedLibs)" "NO" + DYNAMIC_GHC_PROGRAMS = NO + else + DYNAMIC_GHC_PROGRAMS = YES +--- ghc-8.6.5/configure.ac.orig ++++ ghc-8.6.5/configure.ac +@@ -636,7 +636,7 @@ + # tools for Windows. See #14274. + if test "$HostOS" = "mingw32" + then +- AC_PATH_PROG([LIBTOOL],[libtool]) ++ AC_PATH_PROG([LIBTOOL],[dlltool]) + LibtoolCmd="$(cygpath -m $LIBTOOL)" + else + AC_CHECK_TARGET_TOOL([LIBTOOL], [libtool]) +--- ghc-8.6.5/configure.orig ++++ ghc-8.6.5/configure +@@ -8575,8 +8575,8 @@ + # tools for Windows. See #14274. + if test "$HostOS" = "mingw32" + then +- # Extract the first word of "libtool", so it can be a program name with args. +-set dummy libtool; ac_word=$2 ++ # Extract the first word of "dlltool", so it can be a program name with args. ++set dummy dlltool; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 + $as_echo_n "checking for $ac_word... " >&6; } + if ${ac_cv_path_LIBTOOL+:} false; then : +--- ghc-8.6.5/rules/build-package-way.mk.orig ++++ ghc-8.6.5/rules/build-package-way.mk +@@ -58,7 +58,7 @@ + # On windows we have to supply the extra libs this one links to when building it. + ifeq "$$(TargetOS_CPP)" "mingw32" + $$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS) +- $$(call build-dll,$1,$2,$3,-L$1/$2/build,,$$($1_$2_$3_HS_OBJS) $$($1_$2_$3_NON_HS_OBJS),"$$@","NO","$$($1_PACKAGE)","$$($1_$2_VERSION)") ++ $$(call build-dll,$1,$2,$3,-L$1/$2/build $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) $$(addprefix -L,$$($1_$2_EXTRA_LIBDIRS)),,$$($1_$2_$3_HS_OBJS) $$($1_$2_$3_NON_HS_OBJS),"$$@","NO","$$($1_PACKAGE)","$$($1_$2_VERSION)") + + else # ifneq "$$(TargetOS_CPP)" "mingw32" + $$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS) +@@ -150,7 +150,7 @@ + # 9 = create delay load import lib + # 10 = SxS Name + # 11 = SxS Version +-$(gen-dll_INPLACE) link "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$(call cmd,$1_$2_HC) $(subst -no-hs-main,,$($1_$2_$3_ALL_HC_OPTS) $($1_$2_$3_GHC_LD_OPTS)) \ ++$(gen-dll_INPLACE) link "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$($1_$2_HC) $(subst -no-hs-main,,$($1_$2_$3_ALL_HC_OPTS) $($1_$2_$3_GHC_LD_OPTS)) \ + -shared -dynamic -dynload deploy \ + $(addprefix -l,$($1_$2_EXTRA_LIBRARIES)) \ + -no-auto-link-packages" "$8" \ +--- ghc-8.6.5/rules/build-prog.mk.orig ++++ ghc-8.6.5/rules/build-prog.mk +@@ -261,7 +261,7 @@ + $$(call cmd,$1_$2_HC) -no-hs-main -no-auto-link-packages -optc-g -optc-O0 -Iincludes $$< -o $$@ + + $1/$2/build/tmp/$$($1_$2_PROG).dll : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/. +- $$(call build-dll,$1,$2,$$($1_$2_PROGRAM_WAY),,$$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS),$$@) ++ $$(call build-dll,$1,$2,$$($1_$2_PROGRAM_WAY),,,$$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS),$$@,"NO","$$($1_$2_PROG)","$$($1_$2_VERSION)") + else # $1_$2_PROG_NEEDS_C_WRAPPER=NO + ifeq "$$($1_$2_LINK_WITH_GCC)" "NO" + $1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/. diff --git a/mingw-w64-ghc/PKGBUILD b/mingw-w64-ghc/PKGBUILD index 259fa81f655de..52d7420e46809 100644 --- a/mingw-w64-ghc/PKGBUILD +++ b/mingw-w64-ghc/PKGBUILD @@ -112,7 +112,8 @@ source=("https://downloads.haskell.org/~ghc/${pkgver}/ghc-${pkgver}-src.tar.xz"{ '0002-Switch-LLVM-version.patch' '0003-fix-build-with-ucrt.patch' '0004-fix-windres.patch' - '0005-fix-install.patch' + '0005-fix-hardcoded-mingw.patch' + '0006-dynamic-libs.patch' 'ghc-register.hook' 'ghc-unregister.hook' 'ghc-rebuild-doc-index.hook') @@ -122,12 +123,13 @@ sha256sums=('4d4aa1e96f4001b934ac6193ab09af5d6172f41f5a5d39d8e43393b9aafee361' 'SKIP' '457024c6ea43bdce340af428d86319931f267089398b859b00efdfe2fd4ce93f' 'SKIP' - 'd1803d805849c9de2eacd72039fd00cd99899db478d4853aad202a72fc33a3f9' + '6e5b36a575f5e02c48c7920a2be2ec0bd75a1250218f29bf8cb4acea2126cb37' '8c01538d934500fd23df1a412f848921dae00ad6267e822dd23a491769a9d96d' 'b4b50bd478afa878a2952c6ab97c4e17bd46d671649bb5c9a7c80e6b10830b42' - 'c86c87edda0482c8b978c5cd19ef171c109c0d192ab8e1641e3526cf3586bdbb' + '62eaf8cb692011771fe3fce62c184468f3e836aca6f9f4843a28315dc7068a66' '1fd204d8c142e5aec8bdc0d104d4183c24f271478d2ba9bbe628bb708f6b0298' - '4c1d380dbb6f720f87f3414b9f9e741460916cecc542a6157b56a065993bf755' + 'b7f32ba928fc65518e94a35b3b51e717084c0cc404f571f6bc56fb73a56a4595' + '611b39dd53d8a9481ac6cd9ce3f60b89d127fa643f6d71d5ec9834cc57e09fe7' '633b6a02efa3a6f30c4c40062f24bf0ffa9689c21d0e16da09ed8b699ba6050e' '33bde1f07e6317017e9c7fc7b2e7ad2d63ed3dcde407a23401d0a03861301cea' '31f3b191bcfe7ad09a886e90f6d71c3be5bee02304a81bffe61ac1f5dcdae703') @@ -157,7 +159,9 @@ prepare() { patch -Nbp1 -i "${srcdir}/0002-Switch-LLVM-version.patch" patch -Nbp1 -i "${srcdir}/0003-fix-build-with-ucrt.patch" patch -Nbp1 -i "${srcdir}/0004-fix-windres.patch" - patch -Nbp1 -i "${srcdir}/0005-fix-install.patch" + patch -Nbp1 -i "${srcdir}/0005-fix-hardcoded-mingw.patch" + # Buggy now + # patch -Nbp1 -i "${srcdir}/0006-dynamic-libs.patch" } build() { @@ -165,10 +169,6 @@ build() { export PATH="${srcdir}/prebuilt/bin:$PATH" - ln -sfn ${MINGW_PREFIX} mingw - mkdir -p inplace - (cd inplace && ln -sfn ${MINGW_PREFIX} mingw) - ./boot ./configure \ --prefix=${MINGW_PREFIX} \ @@ -177,18 +177,14 @@ build() { --with-system-libffi \ --enable-distro-toolchain - # Force static linking to libffi, otherwise ghc-stage2.exe failed with - # Mingw-w64 runtime failure: 32 bit pseudo relocation at XXX out of range - install -Dm644 "${MINGW_PREFIX}/lib/libffi.a" rts/dist/build/libffi.a - make -j } -# check() { -# cd "${srcdir}/build-${MSYSTEM}" +check() { + cd "${srcdir}/build-${MSYSTEM}" -# make test -j || true -# } + make test -j || true +} package() { cd "${srcdir}/build-${MSYSTEM}" diff --git a/mingw-w64-ghc/build.mk b/mingw-w64-ghc/build.mk index b216e9840d572..f9fac0151e7f6 100644 --- a/mingw-w64-ghc/build.mk +++ b/mingw-w64-ghc/build.mk @@ -113,7 +113,7 @@ V=0 # Don't strip debug and other unneeded symbols from libraries and executables. STRIP_CMD = : -SRC_CC_OPTS += -std=gnu11 +SRC_CC_OPTS += -std=gnu11 -mcmodel=medium # `--image-base 0x400000` roughly equals to `--default-image-base-low`, # but the latter isn't recognized by older binutils provided by ghc bootstrap SRC_LD_OPTS += -Wl,--image-base,0x400000