Link to this script
#
# Willus.com MSYS2 script to build gcc for Windows
#
cd /
#
# This install base development tools including vim
#
pacman --noconfirm -S base-devel git
rm -rf MINGW-packages
git clone https://github.com/msys2/MINGW-packages.git
cd /MINGW-packages/mingw-w64-gcc
#
# Stop here and fix /MINGW-packages/mingw-w64-gcc/PKGBUILD
# 1. Change line 10 to: _enable_jit=no
#
# Other past edits I've had to do to PKGBUILD:
#      1. Remove patch files with jit in the name (10.3.0) (look for apply_patch_with_msg)
#           a. 0022-jit-port-libgccjit-to-Windows.patch
#           b. 0023-gcc-jit-Rename-libgccjit.dll-to-libgccjit-0.dll.patch
#      2. Change --enable-sjlj-exceptions to --disable-sjlj-exceptions (preferred)
#      3. make sure options line does not have 'debug' enabled:
#          options=('staticlibs' '!emptydirs') # '!strip' 'debug')]
#
pacman --noconfirm -S mingw-w64-x86_64-toolchain
pacman --noconfirm -S mingw-w64-x86_64-autotools
pacman --noconfirm -S mingw-w64-i686-toolchain
pacman --noconfirm -S mingw-w64-i686-autotools
#
# Build 32-bit chain
# Takes ~2 hours on core i9-9900 with SSD
#
# If "unmet dependencies", just use pacman -S to install them.
#
export MINGW_ARCH=mingw32
makepkg-mingw --skippgpcheck
#
# Build 64-bit chain
#
rm -rf src pkg
export MINGW_ARCH=mingw64
makepkg-mingw --skippgpcheck
#
# Decompress .zst tar files and copy to D: drive
#
zstd -d *.zst
mkdir /d/mingw64
cp -p *.pkg.tar /d/mingw64
#
# Clean up
#
rm -rf *.pkg.tar