From: Eric Biggers Date: Mon, 27 Mar 2023 05:30:54 +0000 (-0700) Subject: make-windows-release: support MSYS2 clang environments X-Git-Tag: v1.14.0~59 X-Git-Url: https://wimlib.net/git/?a=commitdiff_plain;h=4bf6a314246d8f7d088eb4bf3b1e3575a6ac329f;p=wimlib make-windows-release: support MSYS2 clang environments Update tools/make-windows-release to support the CLANG32 and CLANG64 MSYS2 environments, and update ci.yml to test them in GitHub Actions. Also try to support CLANGARM64, though I have no way to test that yet. Finally, make a couple more tweaks to make-windows-release: - Run the configure script unless it's explicitly requested to be skipped, as the previous logic was too fragile. - Default to no docs and no zip. --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29527bba..e77d7d56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,8 +127,10 @@ jobs: strategy: matrix: include: - - { sys: mingw32, env: i686 } - - { sys: mingw64, env: x86_64 } + - { msystem: mingw32, cc_pkg: mingw-w64-i686-gcc } + - { msystem: mingw64, cc_pkg: mingw-w64-x86_64-gcc } + - { msystem: clang32, cc_pkg: mingw-w64-clang-i686-clang } + - { msystem: clang64, cc_pkg: mingw-w64-clang-x86_64-clang } defaults: run: shell: msys2 {0} @@ -136,7 +138,7 @@ jobs: - uses: actions/checkout@v3 - uses: msys2/setup-msys2@v2 with: - msystem: ${{matrix.sys}} + msystem: ${{matrix.msystem}} update: true install: > autoconf @@ -144,9 +146,9 @@ jobs: git libtool make - mingw-w64-${{matrix.env}}-gcc + ${{matrix.cc_pkg}} pkgconf - - run: CFLAGS="$DEF_CFLAGS" ./tools/make-windows-release --no-docs --no-zip + - run: CFLAGS="$DEF_CFLAGS" ./tools/make-windows-release fuzz-with-libFuzzer: name: Fuzz with libFuzzer (${{matrix.target}} ${{matrix.sanitizer}}) diff --git a/NEWS b/NEWS index df860335..200defb0 100644 --- a/NEWS +++ b/NEWS @@ -5,11 +5,16 @@ Version 1.14.0-BETA1: Improved the performance of the Windows binaries on CPUs that have SHA-1 instructions. - Removed support for Windows XP. - Fixed a bug in 'wimsplit' where it didn't accept part sizes of 4 GiB or larger on Windows and on 32-bit platforms. + The README.WINDOWS file and the tools/make-windows-release script have + been improved to make it easier to build wimlib on Windows. The + instructions now use MSYS2 (instead of Cygwin as they did before), and + both gcc and clang are supported. + + Removed support for Windows XP. + Version 1.13.6: wimsplit no longer prints a success message on failure. diff --git a/README.WINDOWS b/README.WINDOWS index 2c7fd9cd..14fc0d28 100644 --- a/README.WINDOWS +++ b/README.WINDOWS @@ -97,11 +97,11 @@ Cygwin. The following instructions show the MSYS2 method. First, install MSYS2 by running the installer from https://www.msys2.org/. -Then, open an MSYS2 shell and run the following command: +Then, open any MSYS2 shell and run the following command: pacman -Syu --noconfirm -After that, open an MSYS2 shell again and run the following commands: +After that, open any MSYS2 shell again and run the following commands: pacman -Syu --noconfirm git git clone git://wimlib.net/wimlib @@ -114,12 +114,23 @@ possible to use a release tarball (e.g. wimlib-1.14.0.tar.gz) instead of the git repository; however, the make-windows-release script will not be available in that case and you will need to handle more things yourself. -To build 64-bit (x86_64) binaries, close the MSYS2 shell you have open, then -open "MSYS2 MinGW 64-bit" from the Start menu and run the following commands: +Finally, to actually do a build, close the MSYS2 shell you have open, then open +one of the following from the Start menu: - cd wimlib - tools/make-windows-release --install-msys2-packages --no-docs --no-zip + * "MSYS2 MINGW64" - for x86_64 binaries, built with gcc + * "MSYS2 CLANG64" - for x86_64 binaries, built with clang + * "MSYS2 MINGW32" - for i686 binaries, built with gcc + * "MSYS2 CLANG32" - for i686 binaries, built with clang + * "MSYS2 CLANGARM64" - for ARM64 binaries (EXPERIMENTAL, needs Windows ARM64) -The output will be in a folder named like "wimlib-1.14.0-windows-x86_64-bin". +(If unsure, use "MSYS2 MINGW64".) Then run the following commands: -For 32-bit (i686) binaries, do the same but use "MSYS2 MinGW 32-bit" instead. + cd wimlib + tools/make-windows-release --install-msys2-packages + +The script will automatically download and install the MSYS2 packages needed to +build wimlib in the chosen MSYS2 environment, then build wimlib. The output +will be in a folder named similarly to "wimlib-1.14.0-windows-x86_64-bin". Note +that your "home" folder within MSYS2 is C:\msys64\home\%USERNAME% by default. +Therefore, the full path to the output folder will be similar to +C:\msys64\home\%USERNAME%\wimlib\wimlib-1.14.0-windows-x86_64-bin. diff --git a/tools/make-releases b/tools/make-releases index f1503612..1e0f7365 100755 --- a/tools/make-releases +++ b/tools/make-releases @@ -17,5 +17,5 @@ libdeflate-gunzip $gzfile libdeflate-gzip -12 $tarfile for arch in i686 x86_64; do - ./tools/make-windows-release --arch=$arch + ./tools/make-windows-release --arch=$arch --include-docs --zip done diff --git a/tools/make-windows-release b/tools/make-windows-release index a2d92b0d..a91a6bb3 100755 --- a/tools/make-windows-release +++ b/tools/make-windows-release @@ -15,37 +15,62 @@ else case "$MSYSTEM" in MINGW32) ARCH=i686 + CC_PKG=mingw-w64-i686-gcc ;; MINGW64) ARCH=x86_64 + CC_PKG=mingw-w64-x86_64-gcc + ;; + CLANG32) + ARCH=i686 + CC_PKG=mingw-w64-clang-i686-clang + ;; + CLANG64) + ARCH=x86_64 + CC_PKG=mingw-w64-clang-x86_64-clang + ;; + CLANGARM64) + ARCH=aarch64 + CC_PKG=mingw-w64-clang-aarch64-clang ;; *) - echo 1>&2 "Unsupported MSYS2 environment: $MSYSTEM" - echo 1>&2 "In MSYS2, you must use the MINGW32 or MINGW64 environment." + echo 1>&2 "Unsupported MSYS2 environment: $MSYSTEM. This script supports" + echo 1>&2 "MINGW32, MINGW64, CLANG32, CLANG64, and CLANGARM64." echo 1>&2 "See https://www.msys2.org/docs/environments/" exit 1 esac fi +INCLUDE_DOCS=false INSTALL_MSYS2_PACKAGES=false -BUILD_DOCS=true -BUILD_ZIP=true +SKIP_CONFIGURE=false +ZIP=false longopts="help" longopts+=",arch:" +longopts+=",include-docs" longopts+=",install-msys2-packages" -longopts+=",no-docs" -longopts+=",no-zip" +longopts+=",skip-configure" +longopts+=",zip" usage() { cat << EOF Usage: $SCRIPTNAME [OPTION]... [EXTRA_CONFIGURE_ARG]... Options: - --arch=ARCH Specify the architecture. The default is taken - from MSYSTEM if available, otherwise is x86_64. - --install-msys2-packages Install prerequisite MSYS2 packages - --no-docs Don't build and install PDF manual pages - --no-zip Don't create the final zip file + --arch=ARCH Specify the CPU architecture. This is unnecessary + when using MSYS2. + + --include-docs Build and install the PDF manual pages. + + --install-msys2-packages Install the MSYS2 packages needed to build wimlib. + You can omit this if you have already done this for + the same MSYS2 environment. + + --skip-configure Skip running the configure script again. You can + use this to save time in incremental builds if you + are sure you didn't change any options. + + --zip Zip the output files up into a zip file. EOF } @@ -64,6 +89,9 @@ while true; do ARCH=$2 shift ;; + --include-docs) + INCLUDE_DOCS=true + ;; --install-msys2-packages) if [ -z "$MSYSTEM" ]; then echo 1>&2 "--install-msys2-packages is not allowed outside MSYS2." @@ -71,11 +99,11 @@ while true; do fi INSTALL_MSYS2_PACKAGES=true ;; - --no-docs) - BUILD_DOCS=false + --skip-configure) + SKIP_CONFIGURE=true ;; - --no-zip) - BUILD_ZIP=false + --zip) + ZIP=true ;; --) shift @@ -93,7 +121,7 @@ done EXTRA_CONFIGURE_ARGS=("$@") case "$ARCH" in -i686|x86_64) +i686|x86_64|aarch64) ;; *) echo 1>&2 "Unknown ARCH: $ARCH. Please specify a supported architecture with --arch" @@ -111,16 +139,16 @@ mkdir "$DESTDIR" # Install the required MSYS2 packages if requested. if $INSTALL_MSYS2_PACKAGES; then - echo "Installing the MSYS2 packages required to build wimlib ($MSYSTEM)..." + echo "Installing the MSYS2 $MSYSTEM packages needed to build wimlib..." pacman -Syu --noconfirm --needed \ autoconf \ automake \ git \ libtool \ make \ - "mingw-w64-${ARCH}-gcc" \ + "$CC_PKG" \ pkgconf - echo "Done installing the MSYS2 packages required to build wimlib ($MSYSTEM)." + echo "Done installing the MSYS2 $MSYSTEM packages needed to build wimlib." fi # Bootstrap the repository if not already done. @@ -129,19 +157,19 @@ if [ ! -e configure ]; then ./bootstrap fi -# Configure wimlib for the given $ARCH if not already done. -if ! [ -e config.log ] || - ! grep -q "./configure --host=${ARCH}-w64-mingw32" config.log || \ - ! grep -q "configure: exit 0" config.log || \ - [ ${#EXTRA_CONFIGURE_ARGS[@]} -gt 0 ] -then - # Note: putting -static-libgcc in CC is a workaround for libtool - # stripping it: - # http://www.gnu.org/software/libtool/manual/libtool.html#Stripped-link-flags +# Configure wimlib. +if ! [ -e config.log ] || ! $SKIP_CONFIGURE; then echo "Configuring wimlib..." - ./configure --host="${ARCH}-w64-mingw32" --disable-static \ - CC="${ARCH}-w64-mingw32-gcc -static-libgcc" \ - "${EXTRA_CONFIGURE_ARGS[@]}" + configure_args=("--host=${ARCH}-w64-mingw32") + configure_args+=("--disable-static") + # -static-libgcc is needed with gcc. It should go in the CFLAGS, but + # libtool strips it, so it must go directly in CC instead. See + # http://www.gnu.org/software/libtool/manual/libtool.html#Stripped-link-flags + if "${ARCH}-w64-mingw32-cc" --version | grep -q '(GCC)'; then + configure_args+=("CC=${ARCH}-w64-mingw32-cc -static-libgcc") + fi + configure_args+=("${EXTRA_CONFIGURE_ARGS[@]}") + ./configure "${configure_args[@]}" $MAKE clean fi @@ -188,7 +216,7 @@ function gen_pdf_from_man_page() MANPATH="./doc" man -t "$cmd" | ps2pdf - "$pdf" } -if $BUILD_DOCS; then +if $INCLUDE_DOCS; then echo "Installing manual pages..." mkdir "$DESTDIR"/doc for cmd in "${IMAGEX_CMDS[@]}"; do @@ -211,7 +239,7 @@ mkdir "$DESTDIR"/devel cp .libs/libwim.dll.a "$DESTDIR"/devel/libwim.lib cp include/wimlib.h "$DESTDIR"/devel/ -if $BUILD_ZIP; then +if $ZIP; then echo "Creating zip file..." cd "$DESTDIR" 7z -mx9 a ../"$ZIPFILE" . > /dev/null