]> wimlib.net Git - wimlib/commitdiff
make-windows-release: support MSYS2 clang environments
authorEric Biggers <ebiggers3@gmail.com>
Mon, 27 Mar 2023 05:30:54 +0000 (22:30 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 27 Mar 2023 06:12:50 +0000 (23:12 -0700)
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.

.github/workflows/ci.yml
NEWS
README.WINDOWS
tools/make-releases
tools/make-windows-release

index 29527bba0916c21cfab7c89a4b43d168e6ea0f5c..e77d7d56f64ac44cc3a64cdfcaf23f29170f8cd7 100644 (file)
@@ -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 df8603359f02eb0c1705908ba952903022e7af3b..200defb0ed85281bb8a900b53a538e617ac49dbc 100644 (file)
--- 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.
 
index 2c7fd9cda852a06faa5baa6f893a839971e087ca..14fc0d284e05e0de52ae92a3534de72c2e060892 100644 (file)
@@ -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.
index f15036127fbad4c3d952f65379bee291a8561e79..1e0f736578816e8d2c546db308ef8796f6808541 100755 (executable)
@@ -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
index a2d92b0d72262abc7209958f0e23409526ded623..a91a6bb30b102ce8ea7aacf0b08e02bae0a341bb 100755 (executable)
@@ -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