diff --git a/8.9/build.sh b/8.9/build.sh index 84cf7292..e5a60a1d 100755 --- a/8.9/build.sh +++ b/8.9/build.sh @@ -22,12 +22,14 @@ target="${2:-x86_64-w64-mingw32.shared.win32}" # This ensures that it will not suddenly break a build. # Note: Must be regularly updated. revision="169c1da1e70307258cf763cd41f50a18071587c2" +initialize=false if [ -f "$mxe_dir/Makefile" ]; then echo "Skip cloning, MXE already exists at $mxe_dir" cd $mxe_dir && git fetch else git clone https://github.com/mxe/mxe && cd $mxe_dir + initialize=true fi curr_revision=$(git rev-parse HEAD) @@ -35,6 +37,12 @@ curr_revision=$(git rev-parse HEAD) # Is our branch up-to-date? if [ ! "$curr_revision" = "$revision" ]; then git pull && git reset --hard $revision + initialize=true +fi + +if [ "$initialize" = true ] ; then + # Patch MXE to support the ARM/ARM64 targets + git apply $work_dir/plugins/llvm-mingw/patches/mxe-fixes.patch fi # The 'plugins' variable controls which plugins are in use. @@ -75,6 +83,13 @@ make meson-wrapper gendef vips-$deps \ MXE_PLUGIN_DIRS="$plugins" \ MXE_TARGETS=$target.$deps +# Build and bundle llvm-mingw tests +if [ "$LLVM" = "true" ]; then + make test-llvm-mingw \ + MXE_PLUGIN_DIRS="$plugins" \ + MXE_TARGETS=$target.$deps +fi + cd $work_dir # Packaging diff --git a/8.9/libde265.mk b/8.9/libde265.mk index 4a130ef2..60fbc30f 100644 --- a/8.9/libde265.mk +++ b/8.9/libde265.mk @@ -13,12 +13,9 @@ define $(PKG)_BUILD (cd '$(SOURCE_DIR)' && $(PATCH) -p1 -u) < $(realpath $(dir $(lastword $(libde265_PATCHES))))/libde265-mingw-std-threads.patch) cd '$(BUILD_DIR)' && $(TARGET)-cmake '$(SOURCE_DIR)' \ - -DCMAKE_C_FLAGS="$(CFLAGS) -msse4.1" \ $(if $(findstring win32,$(TARGET)), \ - -DCMAKE_CXX_FLAGS='$(CXXFLAGS) -msse4.1 -I$(PREFIX)/$(TARGET)/include/mingw-std-threads' \ - $(else), \ - -DCMAKE_CXX_FLAGS='$(CXXFLAGS) -msse4.1') \ - -DDISABLE_SSE=OFF + -DCMAKE_CXX_FLAGS='$(CXXFLAGS) -I$(PREFIX)/$(TARGET)/include/mingw-std-threads') \ + -DDISABLE_SIMD=OFF $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' $(MAKE) -C '$(BUILD_DIR)' -j 1 install endef diff --git a/8.9/libexif.mk b/8.9/libexif.mk index 7587556c..76d80d67 100644 --- a/8.9/libexif.mk +++ b/8.9/libexif.mk @@ -17,6 +17,9 @@ define $(PKG)_UPDATE endef define $(PKG)_BUILD + # configure script is ancient so regenerate + cd '$(SOURCE_DIR)' && autoreconf -fi + cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \ $(MXE_CONFIGURE_OPTS) $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' $(MXE_DISABLE_PROGRAMS) diff --git a/8.9/overrides.mk b/8.9/overrides.mk index d96572fa..20dae984 100644 --- a/8.9/overrides.mk +++ b/8.9/overrides.mk @@ -10,8 +10,8 @@ mingw-w64-headers_CONFIGURE_OPTS=--prefix='$(PREFIX)/$(TARGET)/mingw' common_CONFIGURE_OPTS=--prefix='$(PREFIX)/$(TARGET)/mingw' \ --with-sysroot='$(PREFIX)/$(TARGET)/mingw' \ CPPFLAGS='-I$(PREFIX)/$(TARGET)/mingw/include' \ -CFLAGS='-I$(PREFIX)/$(TARGET)/mingw/include' \ -CXXFLAGS='-I$(PREFIX)/$(TARGET)/mingw/include' \ +CFLAGS='-I$(PREFIX)/$(TARGET)/mingw/include -s -O3' \ +CXXFLAGS='-I$(PREFIX)/$(TARGET)/mingw/include -s -O3' \ LDFLAGS='-L$(PREFIX)/$(TARGET)/mingw/lib' \ RCFLAGS='-I$(PREFIX)/$(TARGET)/mingw/include' @@ -49,17 +49,31 @@ define gcc_BUILD_i686-w64-mingw32 endef define llvm-mingw_BUILD_x86_64-w64-mingw32 - $(subst # install the usual wrappers, ln -sf $(PREFIX)/$(TARGET)/mingw/bin/* $(PREFIX)/$(TARGET)/bin && \ - ln -sf '$(PREFIX)/$(TARGET)/mingw/lib/'* '$(PREFIX)/$(TARGET)/lib' && \ - ln -sf '$(PREFIX)/$(TARGET)/mingw/include/'* '$(PREFIX)/$(TARGET)/include', \ - $(subst @mingw-crt-config-opts@,--disable-lib32 --enable-lib64 $(common_CONFIGURE_OPTS), $(llvm-mingw_BUILD_mingw-w64))) + $(subst @mingw-crt-config-opts@,--disable-lib32 --enable-lib64 $(common_CONFIGURE_OPTS),$(llvm-mingw_BUILD_mingw-w64)) + ln -sf '$(PREFIX)/$(TARGET)/mingw/bin/'* '$(PREFIX)/$(TARGET)/bin' + ln -sf '$(PREFIX)/$(TARGET)/mingw/lib/'* '$(PREFIX)/$(TARGET)/lib' + ln -sf '$(PREFIX)/$(TARGET)/mingw/include/'* '$(PREFIX)/$(TARGET)/include' endef define llvm-mingw_BUILD_i686-w64-mingw32 - $(subst # install the usual wrappers, ln -sf $(PREFIX)/$(TARGET)/mingw/bin/* $(PREFIX)/$(TARGET)/bin && \ - ln -sf '$(PREFIX)/$(TARGET)/mingw/lib/'* '$(PREFIX)/$(TARGET)/lib' && \ - ln -sf '$(PREFIX)/$(TARGET)/mingw/include/'* '$(PREFIX)/$(TARGET)/include', \ - $(subst @mingw-crt-config-opts@,--enable-lib32 --disable-lib64 $(common_CONFIGURE_OPTS), $(llvm-mingw_BUILD_mingw-w64))) + $(subst @mingw-crt-config-opts@,--enable-lib32 --disable-lib64 $(common_CONFIGURE_OPTS),$(llvm-mingw_BUILD_mingw-w64)) + ln -sf '$(PREFIX)/$(TARGET)/mingw/bin/'* '$(PREFIX)/$(TARGET)/bin' + ln -sf '$(PREFIX)/$(TARGET)/mingw/lib/'* '$(PREFIX)/$(TARGET)/lib' + ln -sf '$(PREFIX)/$(TARGET)/mingw/include/'* '$(PREFIX)/$(TARGET)/include' +endef + +define llvm-mingw_BUILD_armv7-w64-mingw32 + $(subst @mingw-crt-config-opts@,--disable-lib32 --disable-lib64 --enable-libarm32 $(common_CONFIGURE_OPTS),$(llvm-mingw_BUILD_mingw-w64)) + ln -sf '$(PREFIX)/$(TARGET)/mingw/bin/'* '$(PREFIX)/$(TARGET)/bin' + ln -sf '$(PREFIX)/$(TARGET)/mingw/lib/'* '$(PREFIX)/$(TARGET)/lib' + ln -sf '$(PREFIX)/$(TARGET)/mingw/include/'* '$(PREFIX)/$(TARGET)/include' +endef + +define llvm-mingw_BUILD_aarch64-w64-mingw32 + $(subst @mingw-crt-config-opts@,--disable-lib32 --disable-lib64 --enable-libarm64 $(common_CONFIGURE_OPTS),$(llvm-mingw_BUILD_mingw-w64)) + ln -sf '$(PREFIX)/$(TARGET)/mingw/bin/'* '$(PREFIX)/$(TARGET)/bin' + ln -sf '$(PREFIX)/$(TARGET)/mingw/lib/'* '$(PREFIX)/$(TARGET)/lib' + ln -sf '$(PREFIX)/$(TARGET)/mingw/include/'* '$(PREFIX)/$(TARGET)/include' endef ## Update dependencies @@ -262,7 +276,7 @@ zlib_PATCHES := $(realpath $(sort $(wildcard $(dir $(lastword $(MAKEFILE_LIST)) # Added: mingw-std-threads, libjpeg-turbo, lcms # librsvg: # Removed: libcroco, libgsf -# Added: libxml2 +# Added: libxml2, rust # libwebp: # Added: gettext # Cairo: @@ -286,14 +300,28 @@ openexr_DEPS := cc ilmbase zlib $(BUILD)~cmake ilmbase_DEPS := cc $(BUILD)~cmake pango_DEPS := $(pango_DEPS) fribidi poppler_DEPS := cc mingw-std-threads cairo libjpeg-turbo freetype glib openjpeg lcms libpng tiff zlib -librsvg_DEPS := cc cairo gdk-pixbuf glib pango libxml2 +librsvg_DEPS := $(filter-out libcroco libgsf ,$(librsvg_DEPS)) libxml2 rust libwebp_DEPS := $(libwebp_DEPS) gettext cairo_DEPS := cc fontconfig freetype-bootstrap glib libpng pixman -hdf5_DEPS := cc zlib $(BUILD)~cmake -x265_DEPS := cc $(BUILD)~nasm +hdf5_DEPS := $(filter-out pthreads ,$(hdf5_DEPS)) $(BUILD)~cmake +x265_DEPS := $(subst yasm,$(BUILD)~nasm,$(x265_DEPS)) ## Override build scripts +# libasprintf isn't needed, so build with --disable-libasprintf +define gettext_BUILD + cd '$(SOURCE_DIR)' && autoreconf -fi + cd '$(BUILD_DIR)' && '$(SOURCE_DIR)/gettext-runtime/configure' \ + $(MXE_CONFIGURE_OPTS) \ + --enable-threads=win32 \ + --without-libexpat-prefix \ + --without-libxml2-prefix \ + --disable-libasprintf \ + CONFIG_SHELL=$(SHELL) + $(MAKE) -C '$(BUILD_DIR)/intl' -j '$(JOBS)' + $(MAKE) -C '$(BUILD_DIR)/intl' -j 1 install +endef + # disable version script on llvm-mingw # make the raw api unavailable when building a statically linked binary define libffi_BUILD @@ -302,10 +330,15 @@ define libffi_BUILD $(MXE_CONFIGURE_OPTS) \ --disable-multi-os-directory \ $(if $(BUILD_STATIC), --disable-raw-api) \ - $(if $(findstring posix,$(TARGET)), --disable-symvers) + $(if $(IS_LLVM), --disable-symvers) $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' $(MAKE) -C '$(BUILD_DIR)' -j 1 install + + '$(TARGET)-gcc' \ + -W -Wall -Werror -std=c99 -pedantic \ + '$(TEST_FILE)' -o '$(PREFIX)/$(TARGET)/bin/test-libffi.exe' \ + `'$(TARGET)-pkg-config' libffi --cflags --libs` endef # icu will pull in standard linux headers, which we don't want, @@ -435,23 +468,14 @@ define lcms_BUILD $(MAKE) -C '$(BUILD_DIR)' -j 1 install $(MXE_DISABLE_PROGRAMS) endef -define imagemagick_REVISION - $(SED) -n 's/MAGICK_GIT_REVISION=\(.*\)/\1/p' $(SOURCE_DIR)/configure -endef - # disable largefile support, we rely on vips for that and ImageMagick's # detection does not work when cross-compiling # build with jpeg-turbo and without lzma # disable POSIX threads with --without-threads, use Win32 threads instead # exclude deprecated methods in MagickCore API define imagemagick_BUILD - $(SED) -i "s|\(\[MAGICK_GIT_REVISION\],\).*\]|\1['$(shell $(imagemagick_REVISION))']|" $(SOURCE_DIR)/configure.ac - # avoid linking against -lgdi32, see: https://github.com/kleisauke/net-vips/issues/61 - $(SED) -i 's,-lgdi32,,g' $(SOURCE_DIR)/configure.ac - - # need to regenerate the configure script - cd '$(SOURCE_DIR)' && autoreconf -fi + $(SED) -i 's,-lgdi32,,g' $(SOURCE_DIR)/configure cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \ $(MXE_CONFIGURE_OPTS) \ @@ -514,13 +538,25 @@ endef # compile with the Rust toolchain define librsvg_BUILD + # We need to explicitly link against msvcrt-os after commit ae95d7c + # on the mingw-w64 repo. Otherwise the __ms_vsnprintf symbol is + # undefined during linking. The standard library of Rust appears + # to link against this symbol by default. + # Note: this can probably be removed when the standard library of + # Rust is build with the latest mingw-w64 version (> v7.0.0). + $(if $(IS_LLVM), \ + $(SED) -i 's/^\(Libs:.*\)/\1 -lmsvcrt-os/' '$(SOURCE_DIR)/librsvg.pc.in') + cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \ $(MXE_CONFIGURE_OPTS) \ --disable-pixbuf-loader \ --disable-gtk-doc \ --disable-introspection \ --disable-tools \ - RUST_TARGET=$(firstword $(subst -, ,$(TARGET)))-pc-windows-gnu + RUST_TARGET='$(PROCESSOR)-pc-windows-gnu' \ + CARGO='$(TARGET)-cargo' \ + RUSTC='$(TARGET)-rustc' \ + $(if $(IS_LLVM), LIBS='-lmsvcrt-os -lucrt') $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' $(MAKE) -C '$(BUILD_DIR)' -j 1 $(INSTALL_STRIP_LIB) @@ -685,7 +721,7 @@ define libxml2_BUILD --without-debug \ --without-python \ --without-threads \ - $(if $(findstring posix,$(TARGET)), --disable-ld-version-script) + $(if $(IS_LLVM), --disable-ld-version-script) $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' $(MXE_DISABLE_CRUFT) $(MAKE) -C '$(BUILD_DIR)' -j 1 install $(MXE_DISABLE_CRUFT) ln -sf '$(PREFIX)/$(TARGET)/bin/xml2-config' '$(PREFIX)/bin/$(TARGET)-xml2-config' @@ -827,7 +863,7 @@ define hdf5_BUILD -DH5_LLONG_TO_LDOUBLE_CORRECT=ON \ -DH5_DISABLE_SOME_LDOUBLE_CONV=OFF \ -DH5_NO_ALIGNMENT_RESTRICTIONS=ON \ - -DH5_HAVE_IOEO=$(if $(findstring posix,$(TARGET)),1,0) \ + -DH5_HAVE_IOEO=$(if $(IS_LLVM),1,0) \ -DTEST_LFS_WORKS_RUN=0 \ -DHDF5_ENABLE_THREADSAFE=ON \ -DHDF5_USE_PREGEN=ON \ diff --git a/8.9/package-vipsdev.sh b/8.9/package-vipsdev.sh index add40ecc..804caf07 100755 --- a/8.9/package-vipsdev.sh +++ b/8.9/package-vipsdev.sh @@ -21,8 +21,12 @@ build_os=`$mxe_dir/ext/config.guess` if [ "$arch" = "i686" ]; then arch="w32" -else +elif [ "$arch" = "x86_64" ]; then arch="w64" +elif [ "$arch" = "armv7" ]; then + arch="arm32" +elif [ "$arch" = "aarch64" ]; then + arch="arm64" fi # Make sure that the repackaging dir is empty @@ -42,7 +46,7 @@ if [ "$MOZJPEG" = "true" ]; then zip_suffix+="-mozjpeg" fi -if [ "$LLVM" = "true" ]; then +if [ "$LLVM" = "true" ] && [[ "$arch" != "arm"* ]]; then zip_suffix+="-llvm" fi @@ -78,9 +82,10 @@ echo "Generating import files" echo "Cleaning unnecessary files / directories" # TODO Do we need to keep /share/doc and /share/gtk-doc? -rm -rf $repackage_dir/share/{aclocal,bash-completion,clang,cmake,config.site,doc,gdb,glib-2.0,gtk-2.0,gtk-doc,installed-tests,man,meson,opt-viewer,scan-build,scan-view,thumbnailers,xml} +rm -rf $repackage_dir/share/{aclocal,bash-completion,clang,cmake,config.site,doc,gdb,glib-2.0,gtk-2.0,gtk-doc,installed-tests,man,meson,opt-viewer,scan-build,scan-view,thumbnailers,xml,zsh} rm -rf $repackage_dir/include/{cairo,clang-c,c++,llvm-c} -rm -rf $repackage_dir/lib/{*.so*,*cairo*,*gdk*,clang,ldscripts} +rm -rf $repackage_dir/lib/{*.so*,*cairo*,*gdk*,clang,ldscripts,rustlib} +rm -rf $repackage_dir/etc/bash_completion.d find $repackage_dir/lib -name "*.la" -exec rm -f {} \; diff --git a/8.9/patches/cairo-1-fixes.patch b/8.9/patches/cairo-1-fixes.patch index d9dd1f13..b4446c31 100644 --- a/8.9/patches/cairo-1-fixes.patch +++ b/8.9/patches/cairo-1-fixes.patch @@ -5,7 +5,7 @@ Contains ad hoc patches for cross building. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Sun, 3 Mar 2019 00:01:34 -0800 -Subject: [PATCH 1/3] Revert "clip-boxes: Drop too-early return" +Subject: [PATCH 1/4] Revert "clip-boxes: Drop too-early return" This reverts commit cb871c6c692af68d8e0bf9e26472af45435f8a2c. @@ -30,7 +30,7 @@ index 1111111..2222222 100644 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 25 Nov 2019 15:30:00 +0100 -Subject: [PATCH 2/3] Remove -D_FORTIFY_SOURCE=2 flag +Subject: [PATCH 2/4] Remove -D_FORTIFY_SOURCE=2 flag See: https://github.com/msys2/MINGW-packages/issues/5803 @@ -54,7 +54,7 @@ index 1111111..2222222 100644 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Wed, 12 Feb 2020 20:00:00 +0100 -Subject: [PATCH 3/3] Always define _cairo_utf8_to_utf16 on Windows +Subject: [PATCH 3/4] Always define _cairo_utf8_to_utf16 on Windows _cairo_utf8_to_utf16 is used by _cairo_fopen on Windows so it must be defined even if Win32 fonts or other features are disabled. @@ -72,3 +72,23 @@ index 1111111..2222222 100644 # define CAIRO_HAS_UTF8_TO_UTF16 1 #endif #if CAIRO_HAS_UTF8_TO_UTF16 + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kleis Auke Wolthuizen +Date: Fri, 20 Mar 2020 13:00:00 +0100 +Subject: [PATCH 4/4] Avoid mapping platform-specific functions on MinGW + + +diff --git a/src/cairo-compiler-private.h b/src/cairo-compiler-private.h +index 1111111..2222222 100644 +--- a/src/cairo-compiler-private.h ++++ b/src/cairo-compiler-private.h +@@ -195,7 +195,7 @@ + #define __attribute__(x) + #endif + +-#if (defined(__WIN32__) && !defined(__WINE__)) || defined(_MSC_VER) ++#if (defined(__WIN32__) && !defined(__WINE__) && !defined(__MINGW32__)) || defined(_MSC_VER) + #define access _access + #define fdopen _fdopen + #define hypot _hypot diff --git a/8.9/patches/fftw-3-fixes.patch b/8.9/patches/fftw-3-fixes.patch new file mode 100644 index 00000000..cf106b92 --- /dev/null +++ b/8.9/patches/fftw-3-fixes.patch @@ -0,0 +1,30 @@ +This file is part of MXE. See LICENSE.md for licensing information. + +Contains ad hoc patches for cross building. + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kleis Auke Wolthuizen +Date: Sun, 16 Feb 2020 19:20:00 +0100 +Subject: [PATCH 1/1] Fixes for the llvm-mingw ARM/ARM64 build + + +diff --git a/threads/threads.c b/threads/threads.c +index 1111111..2222222 100644 +--- a/threads/threads.c ++++ b/threads/threads.c +@@ -236,7 +236,15 @@ typedef volatile LONG os_static_mutex_t; + static void os_static_mutex_lock(os_static_mutex_t *s) + { + while (InterlockedExchange(s, 1) == 1) { ++#if defined(_MSC_VER) + YieldProcessor(); ++#elif defined(__i386__) || defined(__x86_64__) ++ __asm__ __volatile__("pause"); ++#elif defined(__ia64__) || defined(__ia64) ++ __asm__ __volatile__ ("hint @pause"); ++#elif defined(__arm__) || defined(__aarch64__) ++ __asm__ __volatile__ ("yield"); ++#endif + Sleep(0); + } + } diff --git a/8.9/patches/glib-2-fixes.patch b/8.9/patches/glib-2-fixes.patch index 425fd6d3..f4dd559e 100644 --- a/8.9/patches/glib-2-fixes.patch +++ b/8.9/patches/glib-2-fixes.patch @@ -5,7 +5,7 @@ Contains ad hoc patches for cross building. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Sat, 2 Feb 2019 15:00:00 +0200 -Subject: [PATCH 1/4] Add missing -liconv and -lintl to linker +Subject: [PATCH 1/5] Add missing -liconv and -lintl to linker diff --git a/glib/meson.build b/glib/meson.build @@ -71,7 +71,7 @@ index 1111111..2222222 100644 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 13 May 2019 18:00:00 +0200 -Subject: [PATCH 2/4] Disable some tests +Subject: [PATCH 2/5] Disable some tests diff --git a/gio/tests/meson.build b/gio/tests/meson.build @@ -100,7 +100,7 @@ index 1111111..2222222 100644 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 25 Nov 2019 00:20:00 +0100 -Subject: [PATCH 3/4] Fix build error with llvm-mingw +Subject: [PATCH 3/5] Fix build error with llvm-mingw diff --git a/glib/gnulib/meson.build b/glib/gnulib/meson.build @@ -153,7 +153,7 @@ index 1111111..2222222 100644 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 25 Nov 2019 10:10:00 +0100 -Subject: [PATCH 4/4] Fix non-literal format string issues +Subject: [PATCH 4/5] Fix non-literal format string issues Clang errors out when using -Werror=format-nonliteral since the definition of g_strdup_vprintf() uses va_list. Clang warns for this whereas GCC doesn't do @@ -219,3 +219,41 @@ index 1111111..2222222 100644 return p; } + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kleis Auke Wolthuizen +Date: Sat, 15 Feb 2020 19:00:00 +0100 +Subject: [PATCH 5/5] Fixes for the llvm-mingw ARM/ARM64 build + + +diff --git a/glib/gbacktrace.h b/glib/gbacktrace.h +index 1111111..2222222 100644 +--- a/glib/gbacktrace.h ++++ b/glib/gbacktrace.h +@@ -61,7 +61,7 @@ void g_on_error_stack_trace (const gchar *prg_name); + # define G_BREAKPOINT() G_STMT_START{ __debugbreak(); }G_STMT_END + #elif defined (__alpha__) && !defined(__osf__) && defined (__GNUC__) && __GNUC__ >= 2 + # define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("bpt"); }G_STMT_END +-#elif defined (__APPLE__) ++#elif g_macro__has_builtin(__builtin_trap) + # define G_BREAKPOINT() G_STMT_START{ __builtin_trap(); }G_STMT_END + #else /* !__i386__ && !__alpha__ */ + # define G_BREAKPOINT() G_STMT_START{ raise (SIGTRAP); }G_STMT_END +diff --git a/glib/valgrind.h b/glib/valgrind.h +index 1111111..2222222 100644 +--- a/glib/valgrind.h ++++ b/glib/valgrind.h +@@ -130,11 +130,11 @@ + # define PLAT_x86_darwin 1 + #elif defined(__APPLE__) && defined(__x86_64__) + # define PLAT_amd64_darwin 1 +-#elif (defined(__MINGW32__) && !defined(__MINGW64__)) \ ++#elif (defined(__MINGW32__) && !defined(__MINGW64__) && !defined(__arm__)) \ + || defined(__CYGWIN32__) \ + || (defined(_WIN32) && defined(_M_IX86)) + # define PLAT_x86_win32 1 +-#elif defined(__MINGW64__) \ ++#elif (defined(__MINGW64__) && !defined(__aarch64__)) \ + || (defined(_WIN64) && defined(_M_X64)) + # define PLAT_amd64_win64 1 + #elif defined(__linux__) && defined(__i386__) diff --git a/8.9/patches/libde265-1-fixes.patch b/8.9/patches/libde265-1-fixes.patch index 9b1d4e65..f96f1006 100644 --- a/8.9/patches/libde265-1-fixes.patch +++ b/8.9/patches/libde265-1-fixes.patch @@ -5,7 +5,7 @@ Contains ad hoc patches for cross building. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Thu, 14 Mar 2019 14:00:00 +0200 -Subject: [PATCH 1/1] Fix build errors + add install targets +Subject: [PATCH 1/5] Fix build errors + add install targets diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -71,3 +71,177 @@ index 1111111..2222222 100644 target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake COMPATIBILITY ExactVersion) + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 20011 +From: Kleis Auke Wolthuizen +Date: Sun, 16 Feb 2020 19:00:00 +0100 +Subject: [PATCH 2/5] Apply SSE flags to x86 builds as well + + +diff --git a/libde265/x86/CMakeLists.txt b/libde265/x86/CMakeLists.txt +index 1111111..2222222 100644 +--- a/libde265/x86/CMakeLists.txt ++++ b/libde265/x86/CMakeLists.txt +@@ -18,6 +18,4 @@ endif() + + set(X86_OBJECTS $ $ PARENT_SCOPE) + +-if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +- SET_TARGET_PROPERTIES(x86_sse PROPERTIES COMPILE_FLAGS "${sse_flags}") +-endif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") ++SET_TARGET_PROPERTIES(x86_sse PROPERTIES COMPILE_FLAGS "${sse_flags}") + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 20011 +From: Kleis Auke Wolthuizen +Date: Sun, 16 Feb 2020 19:30:00 +0100 +Subject: [PATCH 3/5] Enable PIC code only for shared non-win32 builds + + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1111111..2222222 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -8,7 +8,10 @@ project (libde265 + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) ++ ++if(NOT WIN32 AND ENABLE_SHARED) ++ set(CMAKE_POSITION_INDEPENDENT_CODE ON) ++endif() + + # The version number. + set (NUMERIC_VERSION 0x01000500) + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 20011 +From: Kleis Auke Wolthuizen +Date: Sun, 16 Feb 2020 20:00:00 +0100 +Subject: [PATCH 4/5] Fix -DDISABLE_SIMD=ON option parsing + + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1111111..2222222 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -47,8 +47,8 @@ if(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} MATCHES Clang) + add_definitions(-Wall) + endif() + +-option(DISABLE_SSE "Disable SSE optimizations") +-if(NOT ${DISABLE_SSE} EQUAL OFF) ++option(DISABLE_SIMD "Disable SIMD optimizations" OFF) ++if(NOT DISABLE_SIMD) + if(MSVC) + set(SUPPORTS_SSE4_1 1) + else() + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 20011 +From: Kleis Auke Wolthuizen +Date: Mon, 17 Feb 2020 12:00:00 +0100 +Subject: [PATCH 5/5] Add CMake support for NEON optimizations + + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1111111..2222222 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -55,7 +55,16 @@ if(NOT DISABLE_SIMD) + if(MSVC) + set(SUPPORTS_SSE4_1 1) + else() +- CHECK_C_COMPILER_FLAG(-msse4.1 SUPPORTS_SSE4_1) ++ # Detect CPU type ++ string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} CMAKE_SYSTEM_PROCESSOR_LC) ++ if(CMAKE_SYSTEM_PROCESSOR_LC STREQUAL "aarch64" OR ++ CMAKE_SYSTEM_PROCESSOR_LC MATCHES "arm*64*") ++ # TODO ARM64 SIMD optimizations ++ elseif(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "arm*") ++ CHECK_C_COMPILER_FLAG(-mfpu=neon SUPPORTS_NEON) ++ else() ++ CHECK_C_COMPILER_FLAG(-msse4.1 SUPPORTS_SSE4_1) ++ endif() + endif() + endif() + +diff --git a/libde265/CMakeLists.txt b/libde265/CMakeLists.txt +index 1111111..2222222 100644 +--- a/libde265/CMakeLists.txt ++++ b/libde265/CMakeLists.txt +@@ -90,7 +90,12 @@ if(SUPPORTS_SSE4_1) + add_subdirectory (x86) + endif() + +-add_library(${PROJECT_NAME} SHARED ${libde265_sources} ${ENCODER_OBJECTS} ${X86_OBJECTS}) ++if(SUPPORTS_NEON) ++ add_definitions(-DHAVE_NEON) ++ add_subdirectory (arm) ++endif() ++ ++add_library(${PROJECT_NAME} SHARED ${libde265_sources} ${ENCODER_OBJECTS} ${X86_OBJECTS} ${ARM_OBJECTS}) + set_target_properties(${PROJECT_NAME} PROPERTIES + PREFIX "" + IMPORT_PREFIX "" +diff --git a/libde265/arm/CMakeLists.txt b/libde265/arm/CMakeLists.txt +new file mode 100644 +index 1111111..2222222 +--- /dev/null ++++ b/libde265/arm/CMakeLists.txt +@@ -0,0 +1,25 @@ ++enable_language(ASM) ++ ++option(DISABLE_THUMB "Disable ARM THUMB instructions" OFF) ++ ++set (arm_sources ++ arm.cc arm.h ++) ++ ++add_library(arm OBJECT ${arm_sources}) ++ ++set (arm_neon_sources ++ asm.S cpudetect.S hevcdsp_qpel_neon.S neon.S ++) ++ ++add_library(arm_neon OBJECT ${arm_neon_sources}) ++ ++set(BUILD_FLAGS -x assembler-with-cpp -mfpu=neon -DHAVE_NEON -DEXTERN_ASM= -DHAVE_SECTION_DATA_REL_RO) ++ ++if(NOT DISABLE_THUMB) ++ set(BUILD_FLAGS ${BUILD_FLAGS} -DCONFIG_THUMB) ++endif() ++ ++set_target_properties(arm_neon PROPERTIES COMPILE_OPTIONS "${BUILD_FLAGS}") ++ ++set(ARM_OBJECTS $ $ PARENT_SCOPE) +diff --git a/libde265/arm/asm.S b/libde265/arm/asm.S +index 1111111..2222222 100644 +--- a/libde265/arm/asm.S ++++ b/libde265/arm/asm.S +@@ -18,7 +18,9 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + ++#ifdef HAVE_CONFIG_H + #include "config.h" ++#endif + + #ifdef __ELF__ + # define ELF +@@ -40,7 +42,7 @@ + # define FUNC @ + #endif + +-#if HAVE_NEON ++#if HAVE_NEON && !CONFIG_THUMB + .arch armv7-a + #elif HAVE_ARMV6T2 + .arch armv6t2 +@@ -50,7 +52,7 @@ + .arch armv5te + #endif + +-#if HAVE_NEON ++#if HAVE_NEON && !CONFIG_THUMB + .fpu neon + #elif HAVE_VFP + .fpu vfp diff --git a/8.9/patches/libffi-3-fixes.patch b/8.9/patches/libffi-3-fixes.patch index 822a199b..f2ea5a78 100644 --- a/8.9/patches/libffi-3-fixes.patch +++ b/8.9/patches/libffi-3-fixes.patch @@ -5,7 +5,7 @@ Contains ad hoc patches for cross building. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Fri, 27 Dec 2019 18:00:00 +0100 -Subject: [PATCH 1/1] Quote the ffi_closure_inner symbol +Subject: [PATCH 1/2] Quote the ffi_closure_inner symbol Fixes the llvm-mingw x86 build. @@ -24,3 +24,604 @@ index 1111111..2222222 100644 #else # define ffi_call_i386 C(ffi_call_i386) # define ffi_closure_inner C(ffi_closure_inner) + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kleis Auke Wolthuizen +Date: Fri, 14 Feb 2020 21:30:00 +0100 +Subject: [PATCH 2/2] Fixes for the llvm-mingw ARM/ARM64 build + + +diff --git a/configure.host b/configure.host +index 1111111..2222222 100644 +--- a/configure.host ++++ b/configure.host +@@ -8,7 +8,9 @@ + case "${host}" in + aarch64*-*-cygwin* | aarch64*-*-mingw* | aarch64*-*-win* ) + TARGET=ARM_WIN64; TARGETDIR=aarch64 +- MSVC=1 ++ if test "${ax_cv_c_compiler_vendor}" = "microsoft"; then ++ MSVC=1 ++ fi + ;; + + aarch64*-*-*) +@@ -30,7 +32,9 @@ case "${host}" in + + arm*-*-cygwin* | arm*-*-mingw* | arm*-*-win* ) + TARGET=ARM_WIN32; TARGETDIR=arm +- MSVC=1 ++ if test "${ax_cv_c_compiler_vendor}" = "microsoft"; then ++ MSVC=1 ++ fi + ;; + + arm*-*-*) +@@ -253,10 +257,18 @@ esac + # ... but some of the cases above share configury. + case "${TARGET}" in + ARM_WIN32) +- SOURCES="ffi.c sysv_msvc_arm32.S" ++ if test "$MSVC" = 1; then ++ SOURCES="ffi.c sysv_msvc_arm32.S" ++ else ++ SOURCES="ffi.c sysv.S" ++ fi + ;; + ARM_WIN64) +- SOURCES="ffi.c win64_armasm.S" ++ if test "$MSVC" = 1; then ++ SOURCES="ffi.c win64_armasm.S" ++ else ++ SOURCES="ffi.c sysv.S" ++ fi + ;; + MIPS) + SOURCES="ffi.c o32.S n32.S" +diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c +index 1111111..2222222 100644 +--- a/src/aarch64/ffi.c ++++ b/src/aarch64/ffi.c +@@ -19,7 +19,7 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +-#if defined(__aarch64__) || defined(__arm64__)|| defined (_M_ARM64) ++#if defined(__aarch64__) || defined(__arm64__)|| defined (ARM_WIN64) + #include + #include + #include +@@ -27,7 +27,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + #include + #include + #include "internal.h" +-#ifdef _M_ARM64 ++#ifdef ARM_WIN64 + #include /* FlushInstructionCache */ + #endif + +@@ -78,7 +78,7 @@ ffi_clear_cache (void *start, void *end) + sys_icache_invalidate (start, (char *)end - (char *)start); + #elif defined (__GNUC__) + __builtin___clear_cache (start, end); +-#elif defined (_M_ARM64) ++#elif defined (ARM_WIN64) + FlushInstructionCache(GetCurrentProcess(), start, (char*)end - (char*)start); + #else + #error "Missing builtin to flush instruction cache" +@@ -665,7 +665,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue, + if (h) + { + int elems = 4 - (h & 3); +-#ifdef _M_ARM64 /* for handling armasm calling convention */ ++#ifdef ARM_WIN64 /* for handling armasm calling convention */ + if (cif->is_variadic) + { + if (state.ngrn + elems <= N_X_ARG_REG) +@@ -690,7 +690,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue, + } + state.nsrn = N_V_ARG_REG; + dest = allocate_to_stack (&state, stack, ty->alignment, s); +-#ifdef _M_ARM64 /* for handling armasm calling convention */ ++#ifdef ARM_WIN64 /* for handling armasm calling convention */ + } + #endif /* for handling armasm calling convention */ + } +@@ -808,7 +808,7 @@ ffi_prep_closure_loc (ffi_closure *closure, + ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE); + + /* Also flush the cache for code mapping. */ +-#ifdef _M_ARM64 ++#ifdef ARM_WIN64 + // Not using dlmalloc.c for Windows ARM64 builds + // so calling ffi_data_to_code_pointer() isn't necessary + unsigned char *tramp_code = tramp; +@@ -914,7 +914,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif, + if (h) + { + n = 4 - (h & 3); +-#ifdef _M_ARM64 /* for handling armasm calling convention */ ++#ifdef ARM_WIN64 /* for handling armasm calling convention */ + if (cif->is_variadic) + { + if (state.ngrn + n <= N_X_ARG_REG) +@@ -954,7 +954,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif, + avalue[i] = allocate_to_stack(&state, stack, + ty->alignment, s); + } +-#ifdef _M_ARM64 /* for handling armasm calling convention */ ++#ifdef ARM_WIN64 /* for handling armasm calling convention */ + } + #endif /* for handling armasm calling convention */ + } +@@ -1006,4 +1006,4 @@ ffi_closure_SYSV_inner (ffi_cif *cif, + return flags; + } + +-#endif /* (__aarch64__) || defined(__arm64__)|| defined (_M_ARM64)*/ ++#endif /* defined(__aarch64__) || defined(__arm64__) || defined(ARM_WIN64)*/ +diff --git a/src/aarch64/ffitarget.h b/src/aarch64/ffitarget.h +index 1111111..2222222 100644 +--- a/src/aarch64/ffitarget.h ++++ b/src/aarch64/ffitarget.h +@@ -32,8 +32,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + #define FFI_SIZEOF_JAVA_RAW 4 + typedef unsigned long long ffi_arg; + typedef signed long long ffi_sarg; +-#elif defined(_M_ARM64) ++#elif defined(ARM_WIN64) + #define FFI_SIZEOF_ARG 8 ++#ifdef __MINGW32__ ++#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ ++#endif + typedef unsigned long long ffi_arg; + typedef signed long long ffi_sarg; + #else +@@ -69,7 +72,7 @@ typedef enum ffi_abi + #define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE + #endif + +-#ifdef _M_ARM64 ++#ifdef ARM_WIN64 + #define FFI_EXTRA_CIF_FIELDS unsigned is_variadic + #endif + +@@ -78,13 +81,13 @@ typedef enum ffi_abi + #if defined (__APPLE__) + #define FFI_TARGET_SPECIFIC_VARIADIC + #define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs +-#elif !defined(_M_ARM64) ++#elif !defined(ARM_WIN64) + /* iOS and Windows reserve x18 for the system. Disable Go closures until + a new static chain is chosen. */ + #define FFI_GO_CLOSURES 1 + #endif + +-#ifndef _M_ARM64 ++#ifndef ARM_WIN64 + /* No complex type on Windows */ + #define FFI_TARGET_HAS_COMPLEX_TYPE + #endif +diff --git a/src/arm/ffi.c b/src/arm/ffi.c +index 1111111..2222222 100644 +--- a/src/arm/ffi.c ++++ b/src/arm/ffi.c +@@ -28,7 +28,7 @@ + DEALINGS IN THE SOFTWARE. + ----------------------------------------------------------------------- */ + +-#if defined(__arm__) || defined(_M_ARM) ++#if defined(__arm__) || defined(ARM_WIN32) + #include + #include + #include +@@ -36,7 +36,7 @@ + #include + #include "internal.h" + +-#if defined(_MSC_VER) && defined(_M_ARM) ++#ifdef ARM_WIN32 + #define WIN32_LEAN_AND_MEAN + #include + #endif +@@ -48,7 +48,7 @@ + #endif + + #else +-#ifndef _M_ARM ++#ifndef ARM_WIN32 + extern unsigned int ffi_arm_trampoline[2] FFI_HIDDEN; + #else + extern unsigned int ffi_arm_trampoline[3] FFI_HIDDEN; +@@ -592,24 +592,26 @@ ffi_prep_closure_loc (ffi_closure * closure, + config[1] = closure_func; + #else + +-#ifndef _M_ARM ++#ifndef ARM_WIN32 + memcpy(closure->tramp, ffi_arm_trampoline, 8); +-#else ++#elif defined(_MSC_VER) + // cast away function type so MSVC doesn't set the lower bit of the function pointer + memcpy(closure->tramp, (void*)((uintptr_t)ffi_arm_trampoline & 0xFFFFFFFE), FFI_TRAMPOLINE_CLOSURE_OFFSET); ++#else ++ memcpy(closure->tramp, ffi_arm_trampoline, FFI_TRAMPOLINE_CLOSURE_OFFSET); + #endif + + #if defined (__QNX__) + msync(closure->tramp, 8, 0x1000000); /* clear data map */ + msync(codeloc, 8, 0x1000000); /* clear insn map */ +-#elif defined(_MSC_VER) ++#elif defined(ARM_WIN32) + FlushInstructionCache(GetCurrentProcess(), closure->tramp, FFI_TRAMPOLINE_SIZE); + #else + __clear_cache(closure->tramp, closure->tramp + 8); /* clear data map */ + __clear_cache(codeloc, codeloc + 8); /* clear insn map */ + #endif +-#ifdef _M_ARM +- *(void(**)(void))(closure->tramp + FFI_TRAMPOLINE_CLOSURE_FUNCTION) = closure_func; ++#ifdef ARM_WIN32 ++ *(void (**)(void))(closure->tramp + FFI_TRAMPOLINE_CLOSURE_FUNCTION) = closure_func; + #else + *(void (**)(void))(closure->tramp + 8) = closure_func; + #endif +@@ -851,4 +853,4 @@ layout_vfp_args (ffi_cif * cif) + } + } + +-#endif /* __arm__ or _M_ARM */ ++#endif /* defined(__arm__) || defined(ARM_WIN32) */ +diff --git a/src/arm/ffitarget.h b/src/arm/ffitarget.h +index 1111111..2222222 100644 +--- a/src/arm/ffitarget.h ++++ b/src/arm/ffitarget.h +@@ -43,7 +43,7 @@ typedef enum ffi_abi { + FFI_SYSV, + FFI_VFP, + FFI_LAST_ABI, +-#if defined(__ARM_PCS_VFP) || defined(_M_ARM) ++#if defined(__ARM_PCS_VFP) || defined(ARM_WIN32) + FFI_DEFAULT_ABI = FFI_VFP, + #else + FFI_DEFAULT_ABI = FFI_SYSV, +@@ -56,8 +56,13 @@ typedef enum ffi_abi { + unsigned short vfp_reg_free, vfp_nargs; \ + signed char vfp_args[16] \ + ++#ifdef __MINGW32__ ++#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ ++#endif ++ + #define FFI_TARGET_SPECIFIC_VARIADIC +-#ifndef _M_ARM ++#ifndef ARM_WIN32 ++/* No complex type on Windows */ + #define FFI_TARGET_HAS_COMPLEX_TYPE + #endif + +@@ -77,7 +82,7 @@ typedef enum ffi_abi { + #endif + + #else +-#ifdef _MSC_VER ++#ifdef ARM_WIN32 + #define FFI_TRAMPOLINE_SIZE 16 + #define FFI_TRAMPOLINE_CLOSURE_FUNCTION 12 + #else +diff --git a/src/arm/sysv.S b/src/arm/sysv.S +index 1111111..2222222 100644 +--- a/src/arm/sysv.S ++++ b/src/arm/sysv.S +@@ -94,7 +94,10 @@ + + /* Aid in defining a jump table with 8 bytes between entries. */ + /* ??? The clang assembler doesn't handle .if with symbolic expressions. */ +-#ifdef __clang__ ++#ifdef ARM_WIN32 ++# define E(index) \ ++ .balign 8 ++#elif defined(__clang__) + # define E(index) + #else + # define E(index) \ +@@ -105,7 +108,11 @@ + + .text + .syntax unified ++#ifdef ARM_WIN32 ++ .thumb ++#else + .arm ++#endif + + #ifndef __clang__ + /* We require interworking on LDM, which implies ARMv5T, +@@ -128,7 +135,11 @@ ARM_FUNC_START(ffi_call_VFP) + cfi_startproc + + cmp r3, #3 @ load only d0 if possible +-#ifdef __clang__ ++#ifdef ARM_WIN32 ++ ITE LE ++ vldrle d0, [r0] ++ vldmgt r0, {d0-d7} ++#elif defined(__clang__) + vldrle d0, [sp] + vldmgt sp, {d0-d7} + #else +@@ -167,8 +178,16 @@ ARM_FUNC_START(ffi_call_SYSV) + cfi_def_cfa_register(sp) + + @ Store values stored in registers. ++#ifdef ARM_WIN32 ++ .balign 8 ++ lsl r3, #3 ++ add r3, r3, pc ++ add r3, #8 ++ mov pc, r3 ++#else + .align 3 + add pc, pc, r3, lsl #3 ++#endif + nop + 0: + E(ARM_TYPE_VFP_S) +@@ -202,6 +221,9 @@ E(ARM_TYPE_VOID) + pop {fp,pc} + nop + E(ARM_TYPE_STRUCT) ++#ifdef ARM_WIN32 ++ cmp r3, #ARM_TYPE_STRUCT ++#endif + pop {fp,pc} + + cfi_endproc +@@ -227,6 +249,9 @@ ARM_FUNC_END(ffi_go_closure_SYSV) + ARM_FUNC_START(ffi_closure_SYSV) + UNWIND(.fnstart) + cfi_startproc ++#ifdef ARM_WIN32 ++ pop {r0,ip} @ restore fp (r0 is used for stack alignment) ++#endif + stmdb sp!, {r0-r3} @ save argument regs + cfi_adjust_cfa_offset(16) + +@@ -240,6 +265,10 @@ ARM_FUNC_START(ffi_closure_SYSV) + add ip, sp, #16 @ compute entry sp + sub sp, sp, #64+32 @ allocate frame + cfi_adjust_cfa_offset(64+32) ++ ++#ifdef ARM_WIN32 ++ mov r3, sp @ set frame parameter ++#endif + stmdb sp!, {ip,lr} + + /* Remember that EABI unwind info only applies at call sites. +@@ -249,13 +278,23 @@ ARM_FUNC_START(ffi_closure_SYSV) + cfi_adjust_cfa_offset(8) + cfi_rel_offset(lr, 4) + ++#ifndef ARM_WIN32 + add r3, sp, #8 @ load frame ++#endif + bl CNAME(ffi_closure_inner_SYSV) + + @ Load values returned in registers. + add r2, sp, #8+64 @ load result ++#ifdef ARM_WIN32 ++ bl CNAME(ffi_closure_ret) @ move result to correct register or memory for type ++ ++ pop {ip,lr} ++ mov sp, ip @ restore stack pointer ++ mov pc, lr ++#else + adr r3, CNAME(ffi_closure_ret) + add pc, r3, r0, lsl #3 ++#endif + cfi_endproc + UNWIND(.fnend) + ARM_FUNC_END(ffi_closure_SYSV) +@@ -274,6 +313,9 @@ ARM_FUNC_END(ffi_go_closure_VFP) + ARM_FUNC_START(ffi_closure_VFP) + UNWIND(.fnstart) + cfi_startproc ++#ifdef ARM_WIN32 ++ pop {r0,ip} @ restore fp (r0 is used for stack alignment) ++#endif + stmdb sp!, {r0-r3} @ save argument regs + cfi_adjust_cfa_offset(16) + +@@ -284,13 +326,22 @@ ARM_FUNC_START(ffi_closure_VFP) + ldr r1, [ip, #FFI_TRAMPOLINE_CLOSURE_OFFSET+4] @ load fun + ldr r2, [ip, #FFI_TRAMPOLINE_CLOSURE_OFFSET+8] @ load user_data + 0: +- add ip, sp, #16 ++ add ip, sp, #16 @ compute entry sp ++#ifdef ARM_WIN32 ++ sub sp, sp, #32 @ save space for closure_frame->result ++ cfi_adjust_cfa_offset(32) ++ ++ vstmdb sp!, {d0-d7} @ push closure_frame->vfp_space ++ ++ mov r3, sp @ save closure_frame ++#else + sub sp, sp, #64+32 @ allocate frame + cfi_adjust_cfa_offset(64+32) + #ifdef __clang__ + vstm sp, {d0-d7} + #else + stc p11, cr0, [sp], {16} @ vstm sp, {d0-d7} ++#endif + #endif + stmdb sp!, {ip,lr} + +@@ -299,13 +350,22 @@ ARM_FUNC_START(ffi_closure_VFP) + cfi_adjust_cfa_offset(8) + cfi_rel_offset(lr, 4) + ++#ifndef ARM_WIN32 + add r3, sp, #8 @ load frame ++#endif + bl CNAME(ffi_closure_inner_VFP) + + @ Load values returned in registers. + add r2, sp, #8+64 @ load result ++#ifdef ARM_WIN32 ++ bl CNAME(ffi_closure_ret) ++ pop {ip,lr} ++ mov sp, ip @ restore stack pointer ++ mov pc, lr ++#else + adr r3, CNAME(ffi_closure_ret) + add pc, r3, r0, lsl #3 ++#endif + cfi_endproc + UNWIND(.fnend) + ARM_FUNC_END(ffi_closure_VFP) +@@ -316,6 +376,15 @@ ARM_FUNC_END(ffi_closure_VFP) + + ARM_FUNC_START_LOCAL(ffi_closure_ret) + cfi_startproc ++#ifdef ARM_WIN32 ++ stmdb sp!, {fp,lr} ++ ++ .balign 8 ++ lsl r0, #3 ++ add r0, r0, pc ++ add r0, #8 ++ mov pc, r0 ++#endif + cfi_rel_offset(sp, 0) + cfi_rel_offset(lr, 4) + 0: +@@ -325,32 +394,38 @@ E(ARM_TYPE_VFP_S) + #else + ldc p10, cr0, [r2] @ vldr s0, [r2] + #endif +- ldm sp, {sp,pc} ++ b call_epilogue + E(ARM_TYPE_VFP_D) + #ifdef __clang__ + vldr d0, [r2] + #else + ldc p11, cr0, [r2] @ vldr d0, [r2] + #endif +- ldm sp, {sp,pc} ++ b call_epilogue + E(ARM_TYPE_VFP_N) + #ifdef __clang__ + vldm r2, {d0-d3} + #else + ldc p11, cr0, [r2], {8} @ vldm r2, {d0-d3} + #endif +- ldm sp, {sp,pc} ++ b call_epilogue + E(ARM_TYPE_INT64) + ldr r1, [r2, #4] + nop + E(ARM_TYPE_INT) + ldr r0, [r2] +- ldm sp, {sp,pc} ++ b call_epilogue + E(ARM_TYPE_VOID) +- ldm sp, {sp,pc} ++ b call_epilogue + nop + E(ARM_TYPE_STRUCT) ++ b call_epilogue ++call_epilogue: ++#ifdef ARM_WIN32 ++ pop {fp,pc} ++#else + ldm sp, {sp,pc} ++#endif + cfi_endproc + ARM_FUNC_END(ffi_closure_ret) + +@@ -373,6 +448,9 @@ ARM_FUNC_END(ffi_closure_trampoline_table_page) + + ARM_FUNC_START(ffi_arm_trampoline) + 0: adr ip, 0b ++#ifdef ARM_WIN32 ++ stmdb sp!, {r0, ip} ++#endif + ldr pc, 1f + 1: .long 0 + ARM_FUNC_END(ffi_arm_trampoline) +diff --git a/src/closures.c b/src/closures.c +index 1111111..2222222 100644 +--- a/src/closures.c ++++ b/src/closures.c +@@ -123,7 +123,7 @@ ffi_closure_free (void *ptr) + # define FFI_MMAP_EXEC_WRIT 1 + # define HAVE_MNTENT 1 + # endif +-# if defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) || defined(__OS2__) ++# if defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM_WIN32) || defined(ARM_WIN64) || defined(__OS2__) + /* Windows systems may have Data Execution Protection (DEP) enabled, + which requires the use of VirtualMalloc/VirtualFree to alloc/free + executable memory. */ +@@ -386,7 +386,7 @@ ffi_closure_free (void *ptr) + #endif + #include + #include +-#if !defined(X86_WIN32) && !defined(X86_WIN64) && !defined(_M_ARM64) ++#if !defined(X86_WIN32) && !defined(X86_WIN64) && !defined(ARM_WIN32) && !defined(ARM_WIN64) + #ifdef HAVE_MNTENT + #include + #endif /* HAVE_MNTENT */ +@@ -512,7 +512,7 @@ static int dlmalloc_trim(size_t) MAYBE_UNUSED; + static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED; + static void dlmalloc_stats(void) MAYBE_UNUSED; + +-#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) ++#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM_WIN32) || defined(ARM_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) + /* Use these for mmap and munmap within dlmalloc.c. */ + static void *dlmmap(void *, size_t, int, int, int, off_t); + static int dlmunmap(void *, size_t); +@@ -526,7 +526,7 @@ static int dlmunmap(void *, size_t); + #undef mmap + #undef munmap + +-#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) ++#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM_WIN32) || defined(ARM_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) + + /* A mutex used to synchronize access to *exec* variables in this file. */ + static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER; +@@ -908,7 +908,7 @@ segment_holding_code (mstate m, char* addr) + } + #endif + +-#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ ++#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM_WIN32) || defined(ARM_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ + + /* Allocate a chunk of memory with the given size. Returns a pointer + to the writable address, and sets *CODE to the executable +diff --git a/src/prep_cif.c b/src/prep_cif.c +index 1111111..2222222 100644 +--- a/src/prep_cif.c ++++ b/src/prep_cif.c +@@ -129,7 +129,7 @@ ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi, + cif->rtype = rtype; + + cif->flags = 0; +-#ifdef _M_ARM64 ++#ifdef ARM_WIN64 + cif->is_variadic = isvariadic; + #endif + #if HAVE_LONG_DOUBLE_VARIANT +diff --git a/src/x86/ffitarget.h b/src/x86/ffitarget.h +index 1111111..2222222 100644 +--- a/src/x86/ffitarget.h ++++ b/src/x86/ffitarget.h +@@ -46,8 +46,10 @@ + + #ifdef X86_WIN64 + #define FFI_SIZEOF_ARG 8 ++#ifdef __MINGW32__ + #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ + #endif ++#endif + + #define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION + #ifndef _MSC_VER diff --git a/8.9/patches/libgsf-1-fixes.patch b/8.9/patches/libgsf-1-fixes.patch index 41679fed..8e361dee 100644 --- a/8.9/patches/libgsf-1-fixes.patch +++ b/8.9/patches/libgsf-1-fixes.patch @@ -5,7 +5,7 @@ Contains ad hoc patches for cross building. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: "fix@me" Date: Fri, 24 Sep 2010 23:34:26 +0200 -Subject: [PATCH 1/3] s,DllMain,static _disabled_DllMain, +Subject: [PATCH 1/4] s,DllMain,static _disabled_DllMain, diff --git a/gsf/gsf-utils.c b/gsf/gsf-utils.c @@ -28,7 +28,7 @@ index 1111111..2222222 100644 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 25 Nov 2019 20:20:00 +0100 -Subject: [PATCH 2/3] Simplify ISO 8601 parser +Subject: [PATCH 2/4] Simplify ISO 8601 parser By using g_date_time_new_from_iso8601 and g_date_time_format_iso8601. @@ -164,10 +164,120 @@ index 1111111..2222222 100644 guint +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kleis Auke Wolthuizen +Date: Mon, 2 Mar 2020 17:00:00 +0100 +Subject: [PATCH 3/4] Revert "Attempt ARM fix." + +This reverts commit 2e7e842fd277fbbbf3f943dfd8511a7eee6721f3. + +diff --git a/gsf/gsf-utils.c b/gsf/gsf-utils.c +index 1111111..2222222 100644 +--- a/gsf/gsf-utils.c ++++ b/gsf/gsf-utils.c +@@ -29,17 +29,6 @@ + #include + #include + +-/* +- * Glib gets this wrong, really. ARM's floating point format is a weird +- * mixture. +- */ +-#define G_ARMFLOAT_ENDIAN 56781234 +-#if defined(__arm__) && !defined(__ARM_EABI__) && (G_BYTE_ORDER == G_LITTLE_ENDIAN) +-#define G_FLOAT_BYTE_ORDER G_ARMFLOAT_ENDIAN +-#else +-#define G_FLOAT_BYTE_ORDER G_BYTE_ORDER +-#endif +- + gboolean + gsf_debug_flag (const char *flag) + { +@@ -361,7 +350,7 @@ gsf_le_get_guint64 (void const *p) + float + gsf_le_get_float (void const *p) + { +-#if G_FLOAT_BYTE_ORDER == G_BIG_ENDIAN ++#if G_BYTE_ORDER == G_BIG_ENDIAN + if (sizeof (float) == 4) { + float f; + int i; +@@ -376,7 +365,7 @@ gsf_le_get_float (void const *p) + } else { + g_error ("Big endian machine, but weird size of floats"); + } +-#elif (G_FLOAT_BYTE_ORDER == G_LITTLE_ENDIAN) || (G_FLOAT_BYTE_ORDER == G_ARMFLOAT_ENDIAN) ++#elif G_BYTE_ORDER == G_LITTLE_ENDIAN + if (sizeof (float) == 4) { + /* + * On i86, we could access directly, but Alphas require +@@ -403,7 +392,7 @@ gsf_le_get_float (void const *p) + void + gsf_le_set_float (void *p, float f) + { +-#if G_FLOAT_BYTE_ORDER == G_BIG_ENDIAN ++#if G_BYTE_ORDER == G_BIG_ENDIAN + if (sizeof (float) == 4) { + int i; + guint8 *t = (guint8 *)&f; +@@ -415,7 +404,7 @@ gsf_le_set_float (void *p, float f) + } else { + g_error ("Big endian machine, but weird size of floats"); + } +-#elif (G_FLOAT_BYTE_ORDER == G_LITTLE_ENDIAN) || (G_FLOAT_BYTE_ORDER == G_ARMFLOAT_ENDIAN) ++#elif G_BYTE_ORDER == G_LITTLE_ENDIAN + if (sizeof (float) == 4) { + /* + * On i86, we could access directly, but Alphas require +@@ -441,12 +430,7 @@ gsf_le_set_float (void *p, float f) + double + gsf_le_get_double (void const *p) + { +-#if G_FLOAT_BYTE_ORDER == G_ARMFLOAT_ENDIAN +- double data; +- memcpy ((char *)&data + 4, p, 4); +- memcpy ((char *)&data, (char const *)p + 4, 4); +- return data; +-#elif G_FLOAT_BYTE_ORDER == G_BIG_ENDIAN ++#if G_BYTE_ORDER == G_BIG_ENDIAN + if (sizeof (double) == 8) { + double d; + int i; +@@ -461,7 +445,7 @@ gsf_le_get_double (void const *p) + } else { + g_error ("Big endian machine, but weird size of doubles"); + } +-#elif G_FLOAT_BYTE_ORDER == G_LITTLE_ENDIAN ++#elif G_BYTE_ORDER == G_LITTLE_ENDIAN + if (sizeof (double) == 8) { + /* + * On i86, we could access directly, but Alphas require +@@ -488,10 +472,7 @@ gsf_le_get_double (void const *p) + void + gsf_le_set_double (void *p, double d) + { +-#if G_FLOAT_BYTE_ORDER == G_ARMFLOAT_ENDIAN +- memcpy (p, (char const *)&d + 4, 4); +- memcpy ((char *)p + 4, &d, 4); +-#elif G_FLOAT_BYTE_ORDER == G_BIG_ENDIAN ++#if G_BYTE_ORDER == G_BIG_ENDIAN + if (sizeof (double) == 8) { + int i; + guint8 *t = (guint8 *)&d; +@@ -503,7 +484,7 @@ gsf_le_set_double (void *p, double d) + } else { + g_error ("Big endian machine, but weird size of doubles"); + } +-#elif G_FLOAT_BYTE_ORDER == G_LITTLE_ENDIAN ++#elif G_BYTE_ORDER == G_LITTLE_ENDIAN + if (sizeof (double) == 8) { + /* + * On i86, we could access directly, but Alphas require + From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Sun, 29 Mar 2020 12:40:00 +0200 -Subject: [PATCH 3/3] Avoid having multiple -exported-symbols arguments on win32 +Subject: [PATCH 4/4] Avoid having multiple -exported-symbols arguments on win32 More than one -exported-symbols argument is not allowed. diff --git a/8.9/patches/libjpeg-turbo-2-fixes.patch b/8.9/patches/libjpeg-turbo-2-fixes.patch index 4d91af3c..e1288869 100644 --- a/8.9/patches/libjpeg-turbo-2-fixes.patch +++ b/8.9/patches/libjpeg-turbo-2-fixes.patch @@ -5,7 +5,7 @@ Contains ad hoc patches for cross building. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Alexpux Date: Sun, 18 Jan 2015 16:49:05 +0300 -Subject: [PATCH 1/1] Fix compatibility with "basestd.h" header +Subject: [PATCH 1/2] Fix compatibility with "basestd.h" header Taken from: https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-libjpeg-turbo/0001-header-compat.mingw.patch @@ -50,3 +50,103 @@ index 1111111..2222222 100644 /* Datatype used for image dimensions. The JPEG standard only supports * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kleis Auke Wolthuizen +Date: Sat, 15 Feb 2020 20:00:00 +0100 +Subject: [PATCH 2/2] Fixes for the llvm-mingw ARM/ARM64 build + + +diff --git a/simd/CMakeLists.txt b/simd/CMakeLists.txt +index 1111111..2222222 100644 +--- a/simd/CMakeLists.txt ++++ b/simd/CMakeLists.txt +@@ -212,6 +212,14 @@ elseif(CPU_TYPE STREQUAL "arm64" OR CPU_TYPE STREQUAL "arm") + + enable_language(ASM) + ++if(WIN32) ++ if(CPU_TYPE STREQUAL "arm64") ++ set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -DARM_WIN64") ++ elseif(CPU_TYPE STREQUAL "arm") ++ set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -DARM_WIN32") ++ endif() ++endif() ++ + set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ASM_FLAGS}") + + string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC) +@@ -225,7 +233,11 @@ if(CPU_TYPE STREQUAL "arm") + .fpu neon + .arch armv7a + .object_arch armv4 ++#ifdef ARM_WIN32 ++ .thumb ++#else + .arm ++#endif + pld [r0] + vmovn.u16 d0, q0") + else() +@@ -253,6 +265,9 @@ if(NOT RESULT EQUAL 0) + return() + else() + message(STATUS "Using gas-preprocessor.pl") ++ if(WIN32 AND CPU_TYPE STREQUAL "arm") ++ set(CMAKE_ASM_COMPILER "-force-thumb ${CMAKE_ASM_COMPILER}") ++ endif() + configure_file(gas-preprocessor.in gas-preprocessor @ONLY) + set(CMAKE_ASM_COMPILER ${CMAKE_CURRENT_BINARY_DIR}/gas-preprocessor) + endif() +@@ -264,7 +272,7 @@ file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/gastest.S) + + add_library(simd OBJECT ${CPU_TYPE}/jsimd_neon.S ${CPU_TYPE}/jsimd.c) + +-if(CMAKE_POSITION_INDEPENDENT_CODE OR ENABLE_SHARED) ++if(NOT WIN32 AND (CMAKE_POSITION_INDEPENDENT_CODE OR ENABLE_SHARED)) + set_target_properties(simd PROPERTIES POSITION_INDEPENDENT_CODE 1) + endif() + +diff --git a/simd/arm/jsimd_neon.S b/simd/arm/jsimd_neon.S +index 1111111..2222222 100644 +--- a/simd/arm/jsimd_neon.S ++++ b/simd/arm/jsimd_neon.S +@@ -2457,15 +2457,22 @@ asm_function jsimd_h2v1_fancy_upsample_neon + uxtb \TMP, \TMP + strb \TMP, [\BUFFER, #1]! + cmp \TMP, #0xff +- /*it eq*/ ++#ifdef ARM_WIN32 ++ IT EQ ++#endif + strbeq \ZERO, [\BUFFER, #1]! + .endm + + .macro put_bits PUT_BUFFER, PUT_BITS, CODE, SIZE +- /*lsl \PUT_BUFFER, \PUT_BUFFER, \SIZE*/ ++#ifdef ARM_WIN32 ++ lsl \PUT_BUFFER, \PUT_BUFFER, \SIZE ++#endif + add \PUT_BITS, \SIZE +- /*orr \PUT_BUFFER, \PUT_BUFFER, \CODE*/ ++#ifdef ARM_WIN32 ++ orr \PUT_BUFFER, \PUT_BUFFER, \CODE ++#else + orr \PUT_BUFFER, \CODE, \PUT_BUFFER, lsl \SIZE ++#endif + .endm + + .macro checkbuf15 BUFFER, PUT_BUFFER, PUT_BITS, ZERO, TMP +diff --git a/simd/arm64/jsimd_neon.S b/simd/arm64/jsimd_neon.S +index 1111111..2222222 100644 +--- a/simd/arm64/jsimd_neon.S ++++ b/simd/arm64/jsimd_neon.S +@@ -33,6 +33,8 @@ + + #if defined(__APPLE__) + .section __DATA, __const ++#elif defined(ARM_WIN64) ++.section .rodata, "a" + #else + .section .rodata, "a", %progbits + #endif diff --git a/8.9/patches/pango-1-fixes.patch b/8.9/patches/pango-1-fixes.patch new file mode 100644 index 00000000..b45cf9e2 --- /dev/null +++ b/8.9/patches/pango-1-fixes.patch @@ -0,0 +1,121 @@ +This file is part of MXE. See LICENSE.md for licensing information. + +Contains ad hoc patches for cross building. + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kleis Auke Wolthuizen +Date: Tue, 24 Mar 2020 18:42:57 +0100 +Subject: [PATCH 1/1] Properly define fallthrough + +Fixes build with LLVM 10. + +(Perhaps Pango should not be compiled with -Werror?) + +diff --git a/pango/break.c b/pango/break.c +index 1111111..2222222 100644 +--- a/pango/break.c ++++ b/pango/break.c +@@ -31,6 +31,16 @@ + #define PARAGRAPH_SEPARATOR 0x2029 + #define PARAGRAPH_SEPARATOR_STRING "\xE2\x80\xA9" + ++#ifndef __has_attribute ++#define __has_attribute(x) 0 ++#endif ++ ++#if __has_attribute(__fallthrough__) ++# define FALL_THROUGH __attribute__ ((fallthrough)) ++#else ++# define FALL_THROUGH ((void)0) /* fall through */ ++#endif ++ + /* See http://www.unicode.org/unicode/reports/tr14/ if you hope + * to understand the line breaking code. + */ +@@ -405,7 +415,7 @@ pango_default_break (const gchar *text, + GB_type = GB_Prepend; + break; + } +- /* fall through */ ++ FALL_THROUGH; + case G_UNICODE_CONTROL: + case G_UNICODE_LINE_SEPARATOR: + case G_UNICODE_PARAGRAPH_SEPARATOR: +@@ -421,7 +431,7 @@ pango_default_break (const gchar *text, + GB_type = GB_ControlCRLF; + break; + } +- /* fall through */ ++ FALL_THROUGH; + + case G_UNICODE_OTHER_LETTER: + if (makes_hangul_syllable) +@@ -594,7 +604,7 @@ pango_default_break (const gchar *text, + case G_UNICODE_CONTROL: + if (wc != 0x000D && wc != 0x000A && wc != 0x000B && wc != 0x000C && wc != 0x0085) + break; +- /* fall through */ ++ FALL_THROUGH; + case G_UNICODE_LINE_SEPARATOR: + case G_UNICODE_PARAGRAPH_SEPARATOR: + WB_type = WB_NewlineCRLF; /* CR, LF, Newline */ +diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c +index 1111111..2222222 100644 +--- a/pango/pango-renderer.c ++++ b/pango/pango-renderer.c +@@ -31,6 +31,16 @@ + #define PANGO_IS_RENDERER_FAST(renderer) (renderer != NULL) + #define IS_VALID_PART(part) ((guint)part < N_RENDER_PARTS) + ++#ifndef __has_attribute ++#define __has_attribute(x) 0 ++#endif ++ ++#if __has_attribute(__fallthrough__) ++# define FALL_THROUGH __attribute__ ((fallthrough)) ++#else ++# define FALL_THROUGH ((void)0) /* fall through */ ++#endif ++ + typedef struct _LineState LineState; + typedef struct _Point Point; + +@@ -222,7 +232,7 @@ draw_underline (PangoRenderer *renderer, + rect->y + 2 * rect->height, + rect->width, + rect->height); +- /* Fall through */ ++ FALL_THROUGH; + case PANGO_UNDERLINE_SINGLE: + case PANGO_UNDERLINE_LOW: + pango_renderer_draw_rectangle (renderer, +diff --git a/tests/testboundaries_ucd.c b/tests/testboundaries_ucd.c +index 1111111..2222222 100644 +--- a/tests/testboundaries_ucd.c ++++ b/tests/testboundaries_ucd.c +@@ -25,6 +25,16 @@ + #include + #include + ++#ifndef __has_attribute ++#define __has_attribute(x) 0 ++#endif ++ ++#if __has_attribute(__fallthrough__) ++# define FALL_THROUGH __attribute__ ((fallthrough)) ++#else ++# define FALL_THROUGH ((void)0) /* fall through */ ++#endif ++ + static gboolean failed = FALSE; + + /* PangoLogAttr has to be the same size as guint or this hack breaks */ +@@ -104,7 +114,7 @@ parse_line (gchar *line, + { + case 0x00f7: /* DIVISION SIGN: boundary here */ + temp_attr.bits |= bits.bits; +- /* fall through */ ++ FALL_THROUGH; + + case 0x00d7: /* MULTIPLICATION SIGN: no boundary here */ + break; diff --git a/8.9/plugins/llvm-mingw/clang.mk b/8.9/plugins/llvm-mingw/clang.mk index 7abcd192..cef63a78 100644 --- a/8.9/plugins/llvm-mingw/clang.mk +++ b/8.9/plugins/llvm-mingw/clang.mk @@ -3,8 +3,8 @@ PKG := clang $(PKG)_WEBSITE := https://clang.llvm.org/ $(PKG)_IGNORE := -$(PKG)_VERSION := 9.0.1 -$(PKG)_CHECKSUM := 5778512b2e065c204010f88777d44b95250671103e434f9dc7363ab2e3804253 +$(PKG)_VERSION := 10.0.0 +$(PKG)_CHECKSUM := 885b062b00e903df72631c5f98b9579ed1ed2790f74e5646b4234fa084eacb21 $(PKG)_PATCHES := $(realpath $(sort $(wildcard $(dir $(lastword $(MAKEFILE_LIST)))/patches/clang-[0-9]*.patch))) $(PKG)_GH_CONF := llvm/llvm-project/releases,llvmorg-,,,,.tar.xz $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION).src diff --git a/8.9/plugins/llvm-mingw/compiler-rt-builtins.mk b/8.9/plugins/llvm-mingw/compiler-rt-builtins.mk new file mode 100644 index 00000000..d3960151 --- /dev/null +++ b/8.9/plugins/llvm-mingw/compiler-rt-builtins.mk @@ -0,0 +1,30 @@ +# This file is part of MXE. See LICENSE.md for licensing information. + +PKG := compiler-rt-builtins +$(PKG)_WEBSITE := https://compiler-rt.llvm.org/ +$(PKG)_VERSION := 10.0.0 +$(PKG)_DEPS := llvm-mingw compiler-rt +$(PKG)_TYPE := meta + +define $(PKG)_BUILD + # i686 -> i386 + $(eval BUILD_ARCH_NAME := $(if $(findstring i686,$(PROCESSOR)),i386,$(PROCESSOR))) + + # armv7 -> arm + $(eval LIB_ARCH_NAME := $(if $(findstring armv7,$(PROCESSOR)),arm,$(BUILD_ARCH_NAME))) + + $(call PREPARE_PKG_SOURCE,compiler-rt,$(BUILD_DIR)) + + cd '$(BUILD_DIR)' && $(TARGET)-cmake '$(BUILD_DIR)/$(compiler-rt_SUBDIR)/lib/builtins' \ + -DCMAKE_AR='$(PREFIX)/$(TARGET)/bin/llvm-ar' \ + -DCMAKE_RANLIB='$(PREFIX)/$(TARGET)/bin/llvm-ranlib' \ + -DCMAKE_C_COMPILER_WORKS=TRUE \ + -DCMAKE_CXX_COMPILER_WORKS=TRUE \ + -DCMAKE_C_COMPILER_TARGET='$(BUILD_ARCH_NAME)-windows-gnu' \ + -DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE + $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' + + $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/clang/$($(PKG)_VERSION)/lib/windows' + cp '$(BUILD_DIR)/lib/windows/libclang_rt.builtins-$(BUILD_ARCH_NAME).a' \ + '$(PREFIX)/$(TARGET)/lib/clang/$($(PKG)_VERSION)/lib/windows/libclang_rt.builtins-$(LIB_ARCH_NAME).a' +endef diff --git a/8.9/plugins/llvm-mingw/compiler-rt-sanitizers.mk b/8.9/plugins/llvm-mingw/compiler-rt-sanitizers.mk new file mode 100644 index 00000000..f8e941dc --- /dev/null +++ b/8.9/plugins/llvm-mingw/compiler-rt-sanitizers.mk @@ -0,0 +1,39 @@ +# This file is part of MXE. See LICENSE.md for licensing information. + +PKG := compiler-rt-sanitizers +$(PKG)_WEBSITE := https://compiler-rt.llvm.org/ +$(PKG)_VERSION := 10.0.0 +$(PKG)_DEPS := llvm-mingw compiler-rt +$(PKG)_TYPE := meta + +# Note: Ubsan includes from the C++ headers, so +# this has to be built after libcxx. +define $(PKG)_BUILD + # i686 -> i386 + $(eval BUILD_ARCH_NAME := $(if $(findstring i686,$(PROCESSOR)),i386,$(PROCESSOR))) + + $(call PREPARE_PKG_SOURCE,compiler-rt,$(BUILD_DIR)) + + cd '$(BUILD_DIR)' && $(TARGET)-cmake '$(BUILD_DIR)/$(compiler-rt_SUBDIR)' \ + -DCMAKE_AR='$(PREFIX)/$(TARGET)/bin/llvm-ar' \ + -DCMAKE_RANLIB='$(PREFIX)/$(TARGET)/bin/llvm-ranlib' \ + -DCMAKE_C_COMPILER_WORKS=TRUE \ + -DCMAKE_CXX_COMPILER_WORKS=TRUE \ + -DCMAKE_C_COMPILER_TARGET='$(BUILD_ARCH_NAME)-windows-gnu' \ + -DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE \ + -DCOMPILER_RT_USE_BUILTINS_LIBRARY=TRUE + $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' + $(MAKE) -C '$(BUILD_DIR)' install-compiler-rt-headers -j 1 + + $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/clang/$($(PKG)_VERSION)/lib/windows' + + $(foreach FILE,asan-preinit asan asan_cxx asan_dll_thunk asan_dynamic_runtime_thunk ubsan_standalone ubsan_standalone_cxx, \ + cp '$(BUILD_DIR)/lib/windows/libclang_rt.$(FILE)-$(BUILD_ARCH_NAME).a' '$(PREFIX)/$(TARGET)/lib/clang/$($(PKG)_VERSION)/lib/windows';) + + cp '$(BUILD_DIR)/lib/windows/libclang_rt.asan_dynamic-$(BUILD_ARCH_NAME).dll.a' '$(PREFIX)/$(TARGET)/lib/clang/$($(PKG)_VERSION)/lib/windows' + cp '$(BUILD_DIR)/lib/windows/libclang_rt.asan_dynamic-$(BUILD_ARCH_NAME).dll' '$(PREFIX)/$(TARGET)/bin' +endef + +# Sanitizers on windows only support x86. +$(PKG)_BUILD_armv7-w64-mingw32 = +$(PKG)_BUILD_aarch64-w64-mingw32 = diff --git a/8.9/plugins/llvm-mingw/compiler-rt.mk b/8.9/plugins/llvm-mingw/compiler-rt.mk index 30221c0b..db87ce69 100644 --- a/8.9/plugins/llvm-mingw/compiler-rt.mk +++ b/8.9/plugins/llvm-mingw/compiler-rt.mk @@ -3,31 +3,10 @@ PKG := compiler-rt $(PKG)_WEBSITE := https://compiler-rt.llvm.org/ $(PKG)_IGNORE := -$(PKG)_VERSION := 9.0.1 -$(PKG)_CHECKSUM := c2bfab95c9986318318363d7f371a85a95e333bc0b34fbfa52edbd3f5e3a9077 +$(PKG)_VERSION := 10.0.0 +$(PKG)_CHECKSUM := 6a7da64d3a0a7320577b68b9ca4933bdcab676e898b759850e827333c3282c75 $(PKG)_PATCHES := $(realpath $(sort $(wildcard $(dir $(lastword $(MAKEFILE_LIST)))/patches/compiler-rt-[0-9]*.patch))) $(PKG)_GH_CONF := llvm/llvm-project/releases,llvmorg-,,,,.tar.xz $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION).src $(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).src.tar.xz -$(PKG)_DEPS := llvm-mingw - -define $(PKG)_BUILD - cd '$(BUILD_DIR)' && $(TARGET)-cmake '$(SOURCE_DIR)/lib/builtins' \ - -DCMAKE_AR='$(PREFIX)/$(TARGET)/bin/llvm-ar' \ - -DCMAKE_RANLIB='$(PREFIX)/$(TARGET)/bin/llvm-ranlib' \ - -DCMAKE_C_COMPILER_WORKS=TRUE \ - -DCMAKE_CXX_COMPILER_WORKS=TRUE \ - -DCMAKE_C_COMPILER_TARGET='$(if $(findstring i686,$(PROCESSOR)),i386,$(PROCESSOR))-windows-gnu' \ - -DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE - $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' - - mkdir -p '$(PREFIX)/$(TARGET)/lib/clang/$($(PKG)_VERSION)/lib/windows' - - # armv7 -> arm - $(if $(findstring armv7,$(PROCESSOR)),\ - cp '$(BUILD_DIR)/lib/windows/libclang_rt.builtins-armv7.a' \ - '$(PREFIX)/$(TARGET)/lib/clang/$($(PKG)_VERSION)/lib/windows/libclang_rt.builtins-arm.a' \ - $(else), \ - cp '$(BUILD_DIR)/lib/windows/libclang_rt.builtins-$(if $(findstring i686,$(PROCESSOR)),i386,$(PROCESSOR)).a' \ - '$(PREFIX)/$(TARGET)/lib/clang/$($(PKG)_VERSION)/lib/windows') -endef +$(PKG)_TYPE := source-only diff --git a/8.9/plugins/llvm-mingw/libcxx.mk b/8.9/plugins/llvm-mingw/libcxx.mk index 6ff931b1..fdd2a919 100644 --- a/8.9/plugins/llvm-mingw/libcxx.mk +++ b/8.9/plugins/llvm-mingw/libcxx.mk @@ -3,13 +3,13 @@ PKG := libcxx $(PKG)_WEBSITE := https://libcxx.llvm.org/ $(PKG)_IGNORE := -$(PKG)_VERSION := 9.0.1 -$(PKG)_CHECKSUM := 0981ff11b862f4f179a13576ab0a2f5530f46bd3b6b4a90f568ccc6a62914b34 +$(PKG)_VERSION := 10.0.0 +$(PKG)_CHECKSUM := 270f8a3f176f1981b0f6ab8aa556720988872ec2b48ed3b605d0ced8d09156c7 $(PKG)_PATCHES := $(realpath $(sort $(wildcard $(dir $(lastword $(MAKEFILE_LIST)))/patches/libcxx-[0-9]*.patch))) $(PKG)_GH_CONF := llvm/llvm-project/releases,llvmorg-,,,,.tar.xz $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION).src $(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).src.tar.xz -$(PKG)_DEPS := llvm-mingw compiler-rt libunwind libcxxabi +$(PKG)_DEPS := llvm-mingw compiler-rt-builtins libunwind libcxxabi define $(PKG)_BUILD $(call PREPARE_PKG_SOURCE,libcxxabi,$(BUILD_DIR)) @@ -65,7 +65,7 @@ define $(PKG)_BUILD $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' $(MAKE) -C '$(BUILD_DIR)' -j 1 install/strip - $(if $(BUILD_STATIC),\ + $(if $(BUILD_STATIC), \ $(TARGET)-ar qcsL \ '$(PREFIX)/$(TARGET)/lib/libc++.a' \ '$(PREFIX)/$(TARGET)/lib/libunwind.a' \ diff --git a/8.9/plugins/llvm-mingw/libcxxabi.mk b/8.9/plugins/llvm-mingw/libcxxabi.mk index afc5adfd..630ff4ca 100644 --- a/8.9/plugins/llvm-mingw/libcxxabi.mk +++ b/8.9/plugins/llvm-mingw/libcxxabi.mk @@ -3,8 +3,8 @@ PKG := libcxxabi $(PKG)_WEBSITE := https://libcxxabi.llvm.org/ $(PKG)_IGNORE := -$(PKG)_VERSION := 9.0.1 -$(PKG)_CHECKSUM := e8f978aa4cfae2d7a0b4d89275637078557cca74b35c31b7283d4786948a8aac +$(PKG)_VERSION := 10.0.0 +$(PKG)_CHECKSUM := e71bac75a88c9dde455ad3f2a2b449bf745eafd41d2d8432253b2964e0ca14e1 $(PKG)_PATCHES := $(realpath $(sort $(wildcard $(dir $(lastword $(MAKEFILE_LIST)))/patches/libcxxabi-[0-9]*.patch))) $(PKG)_GH_CONF := llvm/llvm-project/releases,llvmorg-,,,,.tar.xz $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION).src diff --git a/8.9/plugins/llvm-mingw/libunwind.mk b/8.9/plugins/llvm-mingw/libunwind.mk index 3e91e987..0738aaef 100644 --- a/8.9/plugins/llvm-mingw/libunwind.mk +++ b/8.9/plugins/llvm-mingw/libunwind.mk @@ -3,13 +3,13 @@ PKG := libunwind $(PKG)_WEBSITE := https://clang.llvm.org/docs/Toolchain.html $(PKG)_IGNORE := -$(PKG)_VERSION := 9.0.1 -$(PKG)_CHECKSUM := 535a106a700889274cc7b2f610b2dcb8fc4b0ea597c3208602d7d037141460f1 +$(PKG)_VERSION := 10.0.0 +$(PKG)_CHECKSUM := 09dc5ecc4714809ecf62908ae8fe8635ab476880455287036a2730966833c626 $(PKG)_PATCHES := $(realpath $(sort $(wildcard $(dir $(lastword $(MAKEFILE_LIST)))/patches/libunwind-[0-9]*.patch))) $(PKG)_GH_CONF := llvm/llvm-project/releases,llvmorg-,,,,.tar.xz $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION).src $(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).src.tar.xz -$(PKG)_DEPS := llvm-mingw compiler-rt +$(PKG)_DEPS := llvm-mingw compiler-rt-builtins define $(PKG)_BUILD cd '$(BUILD_DIR)' && $(TARGET)-cmake '$(SOURCE_DIR)' \ diff --git a/8.9/plugins/llvm-mingw/lld.mk b/8.9/plugins/llvm-mingw/lld.mk index 74595538..7c3ce255 100644 --- a/8.9/plugins/llvm-mingw/lld.mk +++ b/8.9/plugins/llvm-mingw/lld.mk @@ -3,8 +3,8 @@ PKG := lld $(PKG)_WEBSITE := https://lld.llvm.org/ $(PKG)_IGNORE := -$(PKG)_VERSION := 9.0.1 -$(PKG)_CHECKSUM := 86262bad3e2fd784ba8c5e2158d7aa36f12b85f2515e95bc81d65d75bb9b0c82 +$(PKG)_VERSION := 10.0.0 +$(PKG)_CHECKSUM := b9a0d7c576eeef05bc06d6e954938a01c5396cee1d1e985891e0b1cf16e3d708 $(PKG)_PATCHES := $(realpath $(sort $(wildcard $(dir $(lastword $(MAKEFILE_LIST)))/patches/lld-[0-9]*.patch))) $(PKG)_GH_CONF := llvm/llvm-project/releases,llvmorg-,,,,.tar.xz $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION).src diff --git a/8.9/plugins/llvm-mingw/lldb.mk b/8.9/plugins/llvm-mingw/lldb.mk new file mode 100644 index 00000000..06696993 --- /dev/null +++ b/8.9/plugins/llvm-mingw/lldb.mk @@ -0,0 +1,12 @@ +# This file is part of MXE. See LICENSE.md for licensing information. + +PKG := lldb +$(PKG)_WEBSITE := https://lldb.llvm.org/ +$(PKG)_IGNORE := +$(PKG)_VERSION := 10.0.0 +$(PKG)_CHECKSUM := dd1ffcb42ed033f5167089ec4c6ebe84fbca1db4a9eaebf5c614af09d89eb135 +$(PKG)_PATCHES := $(realpath $(sort $(wildcard $(dir $(lastword $(MAKEFILE_LIST)))/patches/lldb-[0-9]*.patch))) +$(PKG)_GH_CONF := llvm/llvm-project/releases,llvmorg-,,,,.tar.xz +$(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION).src +$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).src.tar.xz +$(PKG)_TYPE := source-only diff --git a/8.9/plugins/llvm-mingw/llvm-mingw.mk b/8.9/plugins/llvm-mingw/llvm-mingw.mk index 29e1e902..c0e5d803 100644 --- a/8.9/plugins/llvm-mingw/llvm-mingw.mk +++ b/8.9/plugins/llvm-mingw/llvm-mingw.mk @@ -4,9 +4,9 @@ PKG := llvm-mingw $(PKG)_WEBSITE := https://github.com/mstorsjo/llvm-mingw $(PKG)_DESCR := An LLVM/Clang/LLD based mingw-w64 toolchain $(PKG)_IGNORE := -# https://api.github.com/repos/mstorsjo/llvm-mingw/tarball/ee894b6f6365425ddafec6e8a01173be820f81bf -$(PKG)_VERSION := ee894b6 -$(PKG)_CHECKSUM := c23f741fff77cd4c588b700ce9995271c22ba0e550374dd9afc98378e6513fb0 +# https://api.github.com/repos/mstorsjo/llvm-mingw/tarball/ca303864baec8f7f9d86768a10f813395d049086 +$(PKG)_VERSION := ca30386 +$(PKG)_CHECKSUM := 48f3b9cd1322762a93b17efc61cfe895e21a0da36a75551d3e6e879fb5e013af $(PKG)_PATCHES := $(realpath $(sort $(wildcard $(dir $(lastword $(MAKEFILE_LIST)))/patches/llvm-mingw-[0-9]*.patch))) $(PKG)_GH_CONF := mstorsjo/llvm-mingw/branches/master $(PKG)_DEPS := llvm mingw-w64 @@ -16,15 +16,16 @@ $(PKG)_DEPS := llvm mingw-w64 # https://github.com/mstorsjo/llvm-mingw/commit/dcf34a9a35ee3d490a85bdec02999cf96615d406 # https://github.com/mstorsjo/llvm-mingw/blob/master/build-mingw-w64.sh#L5-L6 define $(PKG)_BUILD_mingw-w64 + # install the usual wrappers + $($(PKG)_PRE_BUILD) + # install mingw-w64 headers $(call PREPARE_PKG_SOURCE,mingw-w64,$(BUILD_DIR)) mkdir '$(BUILD_DIR).headers' cd '$(BUILD_DIR).headers' && '$(BUILD_DIR)/$(mingw-w64_SUBDIR)/mingw-w64-headers/configure' \ --host='$(TARGET)' \ --prefix='$(PREFIX)/$(TARGET)' \ - --enable-sdk=all \ --enable-idl \ - --enable-secure-api \ --with-default-msvcrt=ucrt \ --with-default-win32-winnt=0x601 \ $(mingw-w64-headers_CONFIGURE_OPTS) @@ -36,20 +37,12 @@ define $(PKG)_BUILD_mingw-w64 --host='$(TARGET)' \ --prefix='$(PREFIX)/$(TARGET)' \ --with-default-msvcrt=ucrt \ - @mingw-crt-config-opts@ \ - CC='$(PREFIX)/$(TARGET)/bin/clang' \ - STRIP='$(PREFIX)/$(TARGET)/bin/llvm-strip' \ - AR='$(PREFIX)/$(TARGET)/bin/llvm-ar' \ - RANLIB='$(PREFIX)/$(TARGET)/bin/llvm-ranlib' \ - DLLTOOL='$(PREFIX)/$(TARGET)/bin/llvm-dlltool' - $(MAKE) -C '$(BUILD_DIR).crt' -j '$(JOBS)' || $(MAKE) -C '$(BUILD_DIR).crt' -j '$(JOBS)' + @mingw-crt-config-opts@ + $(MAKE) -C '$(BUILD_DIR).crt' -j '$(JOBS)' $(MAKE) -C '$(BUILD_DIR).crt' -j 1 $(INSTALL_STRIP_TOOLCHAIN) - - # install the usual wrappers - $($(PKG)_POST_BUILD) endef -define $(PKG)_POST_BUILD +define $(PKG)_PRE_BUILD $(foreach EXEC, clang-target dlltool ld objdump, \ $(SED) -i -e 's|^DEFAULT_TARGET=.*|DEFAULT_TARGET=$(TARGET)|' \ -e 's|^DIR=.*|DIR="$(PREFIX)/$(TARGET)/bin"|' '$(SOURCE_DIR)/wrappers/$(EXEC)-wrapper.sh'; \ @@ -77,7 +70,7 @@ endef $(PKG)_BUILD_x86_64-w64-mingw32 = $(subst @mingw-crt-config-opts@,--disable-lib32 --enable-lib64,$($(PKG)_BUILD_mingw-w64)) $(PKG)_BUILD_i686-w64-mingw32 = $(subst @mingw-crt-config-opts@,--enable-lib32 --disable-lib64,$($(PKG)_BUILD_mingw-w64)) +$(PKG)_BUILD_armv7-w64-mingw32 = $(subst @mingw-crt-config-opts@,--disable-lib32 --disable-lib64 --enable-libarm32,$($(PKG)_BUILD_mingw-w64)) -# TODO: These targets needs to be tested -$(PKG)_BUILD_armv7-w64-mingw32 = $(subst @mingw-crt-config-opts@,--disable-lib32 --disable-lib64 --enable-libarm32,$($(PKG)_BUILD_mingw-w64)) -$(PKG)_BUILD_aarch64-w64-mingw32 = $(subst @mingw-crt-config-opts@,--disable-lib32 --disable-lib64 --enable-libarm64,$($(PKG)_BUILD_mingw-w64)) +# TODO: This target needs to be tested +$(PKG)_BUILD_aarch64-w64-mingw32 = $(subst @mingw-crt-config-opts@,--disable-lib32 --disable-lib64 --enable-libarm64,$($(PKG)_BUILD_mingw-w64)) diff --git a/8.9/plugins/llvm-mingw/llvm.mk b/8.9/plugins/llvm-mingw/llvm.mk index d2635621..7e6a6555 100644 --- a/8.9/plugins/llvm-mingw/llvm.mk +++ b/8.9/plugins/llvm-mingw/llvm.mk @@ -4,34 +4,37 @@ PKG := llvm $(PKG)_WEBSITE := https://llvm.org/ $(PKG)_DESCR := A collection of modular and reusable compiler and toolchain technologies $(PKG)_IGNORE := -# This version needs to be in-sync with the clang, lld, compiler-rt, libunwind, libcxx and libcxxabi packages -$(PKG)_VERSION := 9.0.1 -$(PKG)_CHECKSUM := 00a1ee1f389f81e9979f3a640a01c431b3021de0d42278f6508391a2f0b81c9a +# This version needs to be in-sync with the clang, lld, lldb, compiler-rt, libunwind, libcxx and libcxxabi packages +$(PKG)_VERSION := 10.0.0 +$(PKG)_CHECKSUM := df83a44b3a9a71029049ec101fb0077ecbbdf5fe41e395215025779099a98fdf $(PKG)_PATCHES := $(realpath $(sort $(wildcard $(dir $(lastword $(MAKEFILE_LIST)))/patches/llvm-[0-9]*.patch))) $(PKG)_GH_CONF := llvm/llvm-project/releases,llvmorg-,,,,.tar.xz $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION).src $(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).src.tar.xz # This is needed to properly override: https://github.com/mxe/mxe/blob/master/src/llvm.mk#L11 $(PKG)_URL := https://github.com/llvm/llvm-project/releases/download/llvmorg-$($(PKG)_VERSION)/$($(PKG)_FILE) -$(PKG)_DEPS := $(BUILD)~cmake clang lld +$(PKG)_DEPS := $(BUILD)~cmake clang lld lldb define $(PKG)_BUILD $(call PREPARE_PKG_SOURCE,clang,$(BUILD_DIR)) $(call PREPARE_PKG_SOURCE,lld,$(BUILD_DIR)) + $(call PREPARE_PKG_SOURCE,lldb,$(BUILD_DIR)) - # TODO: Do we need to build all four architectures (i686, x86_64, armv7 and arm64)? - # -DLLVM_TARGETS_TO_BUILD='ARM;AArch64;X86' cd '$(BUILD_DIR)' && cmake '$(SOURCE_DIR)' \ -DCMAKE_INSTALL_PREFIX='$(PREFIX)/$(TARGET)' \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=OFF \ - -DLLVM_TARGETS_TO_BUILD='X86' \ + -DLLVM_TARGETS_TO_BUILD=$(strip \ + $(if $(findstring armv7,$(PROCESSOR)),ARM, \ + $(if $(findstring aarch64,$(PROCESSOR)),AArch64, \ + X86))) \ -DLLVM_TARGET_ARCH='$(PROCESSOR)' \ -DLLVM_DEFAULT_TARGET_TRIPLE='$(TARGET)' \ -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \ -DLLVM_TOOLCHAIN_TOOLS='llvm-ar;llvm-ranlib;llvm-objdump;llvm-rc;llvm-cvtres;llvm-nm;llvm-strings;llvm-readobj;llvm-dlltool;llvm-pdbutil;llvm-objcopy;llvm-strip;llvm-cov;llvm-profdata;llvm-addr2line;llvm-symbolizer' \ -DLLVM_EXTERNAL_CLANG_SOURCE_DIR='$(BUILD_DIR)/$(clang_SUBDIR)' \ -DLLVM_EXTERNAL_LLD_SOURCE_DIR='$(BUILD_DIR)/$(lld_SUBDIR)' \ + -DLLVM_EXTERNAL_LLDB_SOURCE_DIR='$(BUILD_DIR)/$(lldb_SUBDIR)' \ -DLLVM_BUILD_DOCS=OFF \ -DLLVM_BUILD_EXAMPLES=OFF \ -DLLVM_BUILD_TESTS=OFF \ @@ -44,7 +47,12 @@ define $(PKG)_BUILD -DLLVM_INCLUDE_EXAMPLES=OFF \ -DLLVM_INCLUDE_GO_TESTS=OFF \ -DLLVM_INCLUDE_TESTS=OFF \ - -DLLVM_INCLUDE_UTILS=OFF + -DLLVM_INCLUDE_UTILS=OFF \ + -DLLDB_ENABLE_LIBEDIT=OFF \ + -DLLDB_ENABLE_PYTHON=OFF \ + -DLLDB_ENABLE_CURSES=OFF \ + -DLLDB_ENABLE_LUA=OFF \ + -DLLDB_INCLUDE_TESTS=OFF $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' $(MAKE) -C '$(BUILD_DIR)' -j 1 install/strip endef diff --git a/8.9/plugins/llvm-mingw/overrides.mk b/8.9/plugins/llvm-mingw/overrides.mk index 09ad5702..28936fe6 100644 --- a/8.9/plugins/llvm-mingw/overrides.mk +++ b/8.9/plugins/llvm-mingw/overrides.mk @@ -1,15 +1,28 @@ $(PLUGIN_HEADER) +IS_LLVM := $(true) + # Override sub-dependencies cc_DEPS := llvm-mingw libcxx -# Update MinGW-w64 to 7.0.0 -mingw-w64_VERSION := 7.0.0 -mingw-w64_CHECKSUM := aa20dfff3596f08a7f427aab74315a6cb80c2b086b4a107ed35af02f9496b628 +# TODO: The armv7-pc-windows-gnu and aarch64-pc-windows-gnu Rust targets are not yet supported. +librsvg_BUILD_armv7-w64-mingw32 = +librsvg_BUILD_aarch64-w64-mingw32 = +rust_BUILD_armv7-w64-mingw32 = +rust_BUILD_aarch64-w64-mingw32 = + +# GCC does not support Windows on ARM +gcc_BUILD_armv7-w64-mingw32 = +gcc_BUILD_aarch64-w64-mingw32 = + +# Update MinGW-w64 to df36f5d +# https://github.com/mirror/mingw-w64/commit/df36f5deda23192d0ee99ffd661ea36df924e667 +mingw-w64_VERSION := df36f5d +mingw-w64_CHECKSUM := 15c40d0d22b7dc813b5f0efd0969dc1b3aab708554cd3a45b834e3029c8ce2d0 mingw-w64_PATCHES := $(realpath $(sort $(wildcard $(dir $(lastword $(MAKEFILE_LIST)))/patches/mingw-w64-[0-9]*.patch))) -mingw-w64_SUBDIR := mingw-w64-v$(mingw-w64_VERSION) -mingw-w64_FILE := mingw-w64-v$(mingw-w64_VERSION).tar.bz2 -mingw-w64_URL := https://$(SOURCEFORGE_MIRROR)/project/mingw-w64/mingw-w64/mingw-w64-release/$(mingw-w64_FILE) +mingw-w64_SUBDIR := mirror-mingw-w64-$(mingw-w64_VERSION) +mingw-w64_FILE := mingw-w64-$(mingw-w64_VERSION).tar.gz +mingw-w64_URL := https://github.com/mirror/mingw-w64/tarball/$(mingw-w64_VERSION)/$($(PKG)_FILE) # Do not build pthreads define pthreads_BUILD diff --git a/8.9/plugins/llvm-mingw/patches/llvm-mingw-9-fixes.patch b/8.9/plugins/llvm-mingw/patches/llvm-mingw-9-fixes.patch index 6dfb370a..09889f84 100644 --- a/8.9/plugins/llvm-mingw/patches/llvm-mingw-9-fixes.patch +++ b/8.9/plugins/llvm-mingw/patches/llvm-mingw-9-fixes.patch @@ -13,7 +13,7 @@ diff --git a/wrappers/native-wrapper.h b/wrappers/native-wrapper.h index 1111111..2222222 100644 --- a/wrappers/native-wrapper.h +++ b/wrappers/native-wrapper.h -@@ -136,9 +136,6 @@ static void split_argv(const TCHAR *argv0, const TCHAR **dir_ptr, const TCHAR ** +@@ -145,9 +145,6 @@ static void split_argv(const TCHAR *argv0, const TCHAR **dir_ptr, const TCHAR ** } #endif basename = _tcsdup(basename); @@ -35,7 +35,7 @@ diff --git a/wrappers/windres-wrapper.c b/wrappers/windres-wrapper.c index 1111111..2222222 100644 --- a/wrappers/windres-wrapper.c +++ b/wrappers/windres-wrapper.c -@@ -29,6 +29,18 @@ +@@ -19,6 +19,18 @@ #include "native-wrapper.h" @@ -54,7 +54,7 @@ index 1111111..2222222 100644 #ifndef DEFAULT_TARGET #define DEFAULT_TARGET "x86_64-w64-mingw32" #endif -@@ -266,7 +278,12 @@ int _tmain(int argc, TCHAR* argv[]) { +@@ -262,7 +274,12 @@ int _tmain(int argc, TCHAR* argv[]) { else if (!_tcscmp(arch, _T("aarch64"))) machine = _T("ARM64"); @@ -68,16 +68,16 @@ index 1111111..2222222 100644 const TCHAR **rc_options = malloc(2 * argc * sizeof(*cpp_options)); int nb_rc_options = 0; -@@ -297,7 +314,7 @@ int _tmain(int argc, TCHAR* argv[]) { +@@ -293,7 +310,7 @@ int _tmain(int argc, TCHAR* argv[]) { int arg = 0; - if (!_tcscmp(input_format, _T("rc"))) { + if (!_tcsicmp(input_format, _T("rc"))) { - exec_argv[arg++] = concat(dir, CC); + exec_argv[arg++] = resolved_CC; exec_argv[arg++] = _T("-E"); for (int i = 0; i < nb_cpp_options; i++) exec_argv[arg++] = cpp_options[i]; -@@ -322,7 +339,7 @@ int _tmain(int argc, TCHAR* argv[]) { +@@ -318,7 +335,7 @@ int _tmain(int argc, TCHAR* argv[]) { } arg = 0; @@ -86,19 +86,19 @@ index 1111111..2222222 100644 for (int i = 0; i < nb_rc_options; i++) exec_argv[arg++] = rc_options[i]; exec_argv[arg++] = _T("-I"); -@@ -356,7 +373,7 @@ int _tmain(int argc, TCHAR* argv[]) { +@@ -352,7 +369,7 @@ int _tmain(int argc, TCHAR* argv[]) { // All done - } else if (!_tcscmp(output_format, _T("coff"))) { + } else if (!_tcsicmp(output_format, _T("coff"))) { arg = 0; - exec_argv[arg++] = concat(dir, _T("llvm-cvtres")); + exec_argv[arg++] = resolved_LLVM_CVTRES; exec_argv[arg++] = res; exec_argv[arg++] = concat(_T("-machine:"), machine); exec_argv[arg++] = concat(_T("-out:"), output); -@@ -379,7 +396,7 @@ int _tmain(int argc, TCHAR* argv[]) { +@@ -375,7 +392,7 @@ int _tmain(int argc, TCHAR* argv[]) { error(basename, _T("invalid output format: `"TS"'"), output_format); } - } else if (!_tcscmp(input_format, _T("res"))) { + } else if (!_tcsicmp(input_format, _T("res"))) { - exec_argv[arg++] = concat(dir, _T("llvm-cvtres")); + exec_argv[arg++] = resolved_LLVM_CVTRES; exec_argv[arg++] = input; diff --git a/8.9/plugins/llvm-mingw/patches/mxe-fixes.patch b/8.9/plugins/llvm-mingw/patches/mxe-fixes.patch new file mode 100644 index 00000000..f1f210b3 --- /dev/null +++ b/8.9/plugins/llvm-mingw/patches/mxe-fixes.patch @@ -0,0 +1,108 @@ +This file is part of MXE. See LICENSE.md for licensing information. + +Contains ad hoc patches for cross building. + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kleis Auke Wolthuizen +Date: Fri, 14 Feb 2020 15:20:00 +0100 +Subject: [PATCH 1/1] Add support for targeting ARM/ARM64 + +See: mxe/mxe#2330 + +diff --git a/Makefile b/Makefile +index 1111111..2222222 100644 +--- a/Makefile ++++ b/Makefile +@@ -8,7 +8,8 @@ EXT_DIR := $(TOP_DIR)/ext + # See docs/gmsl.html for further information + include $(EXT_DIR)/gmsl + +-MXE_TRIPLETS := i686-w64-mingw32 x86_64-w64-mingw32 ++MXE_TRIPLETS := i686-w64-mingw32 x86_64-w64-mingw32 \ ++ armv7-w64-mingw32 aarch64-w64-mingw32 + MXE_LIB_TYPES := static shared + MXE_TARGET_LIST := $(strip $(foreach TRIPLET,$(MXE_TRIPLETS),\ + $(addprefix $(TRIPLET).,$(MXE_LIB_TYPES)))) +@@ -774,8 +775,10 @@ build-only-$(1)_$(3): BUILD_$(if $(findstring shared,$(3)),SHARED,STATIC) = TRUE + build-only-$(1)_$(3): BUILD_$(if $(call seq,$(TARGET),$(BUILD)),NATIVE,CROSS) = TRUE + build-only-$(1)_$(3): $(if $(findstring win32,$(TARGET)),WIN32,POSIX)_THREADS = TRUE + build-only-$(1)_$(3): LIB_SUFFIX = $(if $(findstring shared,$(3)),dll,a) +-build-only-$(1)_$(3): BITS = $(if $(findstring x86_64,$(3)),64,32) ++build-only-$(1)_$(3): BITS = $(if $(or $(findstring x86_64,$(3)),$(findstring aarch64,$(3))),64,32) + build-only-$(1)_$(3): PROCESSOR = $(firstword $(call split,-,$(3))) ++build-only-$(1)_$(3): IS_X86 = $(or $(findstring x86_64,$(3)),$(findstring i686,$(3))) ++build-only-$(1)_$(3): IS_ARM = $(or $(findstring armv7,$(3)),$(findstring aarch64,$(3))) + build-only-$(1)_$(3): BUILD_TYPE = $(if $(findstring debug,$(3) $($(1)_CONFIGURE_OPTS)),debug,release) + build-only-$(1)_$(3): BUILD_TYPE_SUFFIX = $(if $(findstring debug,$(3) $($(1)_CONFIGURE_OPTS)),d) + build-only-$(1)_$(3): INSTALL_STRIP_TOOLCHAIN = install$(if $(STRIP_TOOLCHAIN),-strip) +diff --git a/plugins/meson-wrapper/meson-wrapper.mk b/plugins/meson-wrapper/meson-wrapper.mk +index 1111111..2222222 100644 +--- a/plugins/meson-wrapper/meson-wrapper.mk ++++ b/plugins/meson-wrapper/meson-wrapper.mk +@@ -16,11 +16,10 @@ define $(PKG)_BUILD + -DTARGET=$(TARGET) \ + -DBUILD=$(BUILD) \ + -DCPU_FAMILY=$(strip \ +- $(if $(findstring x86_64,$(TARGET)),x86_64,\ +- $(if $(findstring i686,$(TARGET)),x86))) \ +- -DCPU=$(strip \ +- $(if $(findstring x86_64,$(TARGET)),x86_64,\ +- $(if $(findstring i686,$(TARGET)),i686))) \ ++ $(if $(findstring armv7,$(PROCESSOR)),arm, \ ++ $(if $(findstring i686,$(PROCESSOR)),x86, \ ++ $(PROCESSOR)))) \ ++ -DCPU=$(PROCESSOR) \ + -DINPUT='$(PWD)/plugins/meson-wrapper/conf/mxe-crossfile.meson.in' \ + -DOUTPUT='$(PREFIX)/$(TARGET)/share/meson/mxe-crossfile.meson' + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kleis Auke Wolthuizen +Date: Tue, 3 Mar 2020 15:00:00 +0100 +Subject: [PATCH 2/2] Update libffi test + +See: +http://www.chiark.greenend.org.uk/doc/libffi-dev/html/Simple-Example.html#Simple-Example + +diff --git a/src/libffi-test.c b/src/libffi-test.c +index 1111111..2222222 100644 +--- a/src/libffi-test.c ++++ b/src/libffi-test.c +@@ -5,26 +5,30 @@ + #include + #include + +-int main(int argc, char *argv[]) ++int main() + { + ffi_cif cif; + ffi_type *args[1]; + void *values[1]; + char *s; +- int rc; +- +- (void)argc; +- (void)argv; ++ ffi_arg rc; + ++ /* Initialize the argument info vectors */ + args[0] = &ffi_type_pointer; + values[0] = &s; + +- if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, +- &ffi_type_uint, args) == FFI_OK) ++ /* Initialize the cif */ ++ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, ++ &ffi_type_sint, args) == FFI_OK) + { + s = "Hello World!"; + ffi_call(&cif, FFI_FN(puts), &rc, values); +- s = "Goodbye!"; ++ /* rc now holds the result of the call to puts */ ++ ++ /* values holds a pointer to the function's arg, so to ++ call puts() again all we need to do is change the ++ value of s */ ++ s = "This is cool!"; + ffi_call(&cif, FFI_FN(puts), &rc, values); + } + diff --git a/8.9/plugins/llvm-mingw/test-llvm-mingw.mk b/8.9/plugins/llvm-mingw/test-llvm-mingw.mk new file mode 100644 index 00000000..6c1bc3e9 --- /dev/null +++ b/8.9/plugins/llvm-mingw/test-llvm-mingw.mk @@ -0,0 +1,101 @@ +# This file is part of MXE. See LICENSE.md for licensing information. + +PKG := test-llvm-mingw +$(PKG)_WEBSITE := https://github.com/mstorsjo/llvm-mingw/tree/master/test +$(PKG)_DESCR := Tests for llvm-mingw +$(PKG)_VERSION := 1 +$(PKG)_DEPS := llvm-mingw libcxx compiler-rt-sanitizers +$(PKG)_TYPE := meta + +$(PKG)_TESTS_C := hello hello-tls crt-test setjmp +$(PKG)_TESTS_C_DLL := autoimport-lib +$(PKG)_TESTS_C_LINK_DLL := autoimport-main +$(PKG)_TESTS_C_NO_BUILTIN := crt-test +$(PKG)_TESTS_C_ANSI_STDIO := crt-test +$(PKG)_TESTS_CPP := hello-cpp +$(PKG)_TESTS_CPP_LOAD_DLL := tlstest-main +$(PKG)_TESTS_CPP_EXCEPTIONS := hello-exception exception-locale exception-reduced +$(PKG)_TESTS_CPP_DLL := tlstest-lib +$(PKG)_TESTS_SSP := stacksmash +$(PKG)_TESTS_ASAN := stacksmash +$(PKG)_TESTS_UBSAN := ubsan + +define $(PKG)_BUILD + # i686 -> i386 + $(eval COMPILER_RT_ARCH := $(if $(findstring i686,$(PROCESSOR)),i386,$(PROCESSOR))) + + $(call PREPARE_PKG_SOURCE,llvm-mingw,$(BUILD_DIR)) + + $(INSTALL) -d '$(PREFIX)/$(TARGET)/bin/$(PKG)' + $(foreach TEST, $($(PKG)_TESTS_C), \ + '$(TARGET)-clang' \ + $(CFLAGS) \ + '$(BUILD_DIR)/$(llvm-mingw_SUBDIR)/test/$(TEST).c' -o '$(PREFIX)/$(TARGET)/bin/$(PKG)/$(TEST).exe';) + + $(foreach TEST, $($(PKG)_TESTS_C_DLL), \ + '$(TARGET)-clang' \ + $(CFLAGS) -shared \ + '$(BUILD_DIR)/$(llvm-mingw_SUBDIR)/test/$(TEST).c' -o '$(PREFIX)/$(TARGET)/bin/$(PKG)/$(TEST).dll' \ + -Wl,--out-implib,'$(PREFIX)/$(TARGET)/bin/$(PKG)/lib$(TEST).dll.a';) + + $(foreach TEST, $($(PKG)_TESTS_C_LINK_DLL), \ + '$(TARGET)-clang' \ + $(CFLAGS) \ + '$(BUILD_DIR)/$(llvm-mingw_SUBDIR)/test/$(TEST).c' -o '$(PREFIX)/$(TARGET)/bin/$(PKG)/$(TEST).exe' \ + -L'$(PREFIX)/$(TARGET)/bin/$(PKG)' -l$(subst -main,,$(TEST))-lib;) + + $(foreach TEST, $($(PKG)_TESTS_C_NO_BUILTIN), \ + '$(TARGET)-clang' \ + $(CFLAGS) \ + '$(BUILD_DIR)/$(llvm-mingw_SUBDIR)/test/$(TEST).c' -o '$(PREFIX)/$(TARGET)/bin/$(PKG)/$(TEST)-no-builtin.exe' \ + -fno-builtin;) + + $(foreach TEST, $($(PKG)_TESTS_C_ANSI_STDIO), \ + '$(TARGET)-clang' \ + $(CFLAGS) \ + '$(BUILD_DIR)/$(llvm-mingw_SUBDIR)/test/$(TEST).c' -o '$(PREFIX)/$(TARGET)/bin/$(PKG)/$(TEST)-ansi-stdio.exe' \ + -D__USE_MINGW_ANSI_STDIO=1;) + + $(foreach TEST, $($(PKG)_TESTS_CPP) $($(PKG)_TESTS_CPP_EXCEPTIONS) $($(PKG)_TESTS_CPP_LOAD_DLL), \ + '$(TARGET)-clang++' \ + $(CFLAGS) \ + '$(BUILD_DIR)/$(llvm-mingw_SUBDIR)/test/$(TEST).cpp' -o '$(PREFIX)/$(TARGET)/bin/$(PKG)/$(TEST).exe';) + + $(foreach TEST, $($(PKG)_TESTS_CPP_DLL), \ + '$(TARGET)-clang++' \ + $(CFLAGS) -shared \ + '$(BUILD_DIR)/$(llvm-mingw_SUBDIR)/test/$(TEST).cpp' -o '$(PREFIX)/$(TARGET)/bin/$(PKG)/$(TEST).dll';) + + # We're not building libssp, so disable this test for now. + # $(foreach TEST, $($(PKG)_TESTS_SSP), \ + # '$(TARGET)-clang' \ + # $(CFLAGS) \ + # '$(BUILD_DIR)/$(llvm-mingw_SUBDIR)/test/$(TEST).c' -o '$(PREFIX)/$(TARGET)/bin/$(PKG)/$(TEST).exe' \ + # -fstack-protector-strong;) + + # Sanitizers on windows only support x86. + # Ubsan might not require anything too x86 specific, but we don't + # build any of the sanitizer libs for anything else than x86. + $(if $(IS_X86), + $(foreach TEST, $($(PKG)_TESTS_ASAN), \ + '$(TARGET)-clang' \ + $(CFLAGS) \ + '$(BUILD_DIR)/$(llvm-mingw_SUBDIR)/test/$(TEST).c' -o '$(PREFIX)/$(TARGET)/bin/$(PKG)/$(TEST)-asan.exe' \ + -fsanitize=address -g -gcodeview -Wl,-pdb,'$(PREFIX)/$(TARGET)/bin/$(PKG)/$(TEST)-asan.pdb';) + + $(foreach TEST, $($(PKG)_TESTS_UBSAN), \ + '$(TARGET)-clang' \ + $(CFLAGS) \ + '$(BUILD_DIR)/$(llvm-mingw_SUBDIR)/test/$(TEST).c' -o '$(PREFIX)/$(TARGET)/bin/$(PKG)/$(TEST).exe' \ + -fsanitize=undefined;) + ) + + $(if $(BUILD_SHARED), + # Copy needed dependencies to test directory + $(foreach FILE, libc++ libunwind $(if $(IS_X86),libclang_rt.asan_dynamic-$(COMPILER_RT_ARCH),), \ + cp '$(PREFIX)/$(TARGET)/bin/$(FILE).dll' '$(PREFIX)/$(TARGET)/bin/$(PKG)';) + ) + + # Bundle tests + cd '$(PREFIX)/$(TARGET)/bin' && 7za a -tzip $(PKG).zip $(PKG) +endef diff --git a/8.9/rust-std-aarch64.mk b/8.9/rust-std-aarch64.mk new file mode 100644 index 00000000..39012027 --- /dev/null +++ b/8.9/rust-std-aarch64.mk @@ -0,0 +1,8 @@ +# TODO: The aarch64-pc-windows-gnu Rust target is not yet supported. + +PKG := rust-std-aarch64 +$(PKG)_WEBSITE := https://www.rust-lang.org/ +$(PKG)_DESCR := A systems programming language focused on safety, speed and concurrency. +$(PKG)_IGNORE := +$(PKG)_VERSION := 1.42.0 +$(PKG)_TYPE := meta diff --git a/8.9/rust-std-armv7.mk b/8.9/rust-std-armv7.mk new file mode 100644 index 00000000..c0259be1 --- /dev/null +++ b/8.9/rust-std-armv7.mk @@ -0,0 +1,8 @@ +# TODO: The armv7-pc-windows-gnu Rust target is not yet supported. + +PKG := rust-std-armv7 +$(PKG)_WEBSITE := https://www.rust-lang.org/ +$(PKG)_DESCR := A systems programming language focused on safety, speed and concurrency. +$(PKG)_IGNORE := +$(PKG)_VERSION := 1.42.0 +$(PKG)_TYPE := meta diff --git a/8.9/rust-std-i686.mk b/8.9/rust-std-i686.mk new file mode 100644 index 00000000..4cd2661d --- /dev/null +++ b/8.9/rust-std-i686.mk @@ -0,0 +1,10 @@ +PKG := rust-std-i686 +$(PKG)_WEBSITE := https://www.rust-lang.org/ +$(PKG)_DESCR := A systems programming language focused on safety, speed and concurrency. +$(PKG)_IGNORE := +$(PKG)_VERSION := 1.42.0 +$(PKG)_CHECKSUM := 4f82487b879762f56ac6d9dfde41f3e6f265ab47975ff646cf73537d086041e0 +$(PKG)_SUBDIR := rust-$($(PKG)_VERSION)-i686-pc-windows-gnu/rust-std-i686-pc-windows-gnu +$(PKG)_FILE := rust-$($(PKG)_VERSION)-i686-pc-windows-gnu.tar.gz +$(PKG)_URL := https://static.rust-lang.org/dist/$($(PKG)_FILE) +$(PKG)_TYPE := source-only diff --git a/8.9/rust-std-x86_64.mk b/8.9/rust-std-x86_64.mk new file mode 100644 index 00000000..82c86355 --- /dev/null +++ b/8.9/rust-std-x86_64.mk @@ -0,0 +1,10 @@ +PKG := rust-std-x86_64 +$(PKG)_WEBSITE := https://www.rust-lang.org/ +$(PKG)_DESCR := A systems programming language focused on safety, speed and concurrency. +$(PKG)_IGNORE := +$(PKG)_VERSION := 1.42.0 +$(PKG)_CHECKSUM := c3c469253fbac0733899c54e94d25b6437f2fd52a46fb54448f7da8f0985f352 +$(PKG)_SUBDIR := rust-$($(PKG)_VERSION)-x86_64-pc-windows-gnu/rust-std-x86_64-pc-windows-gnu +$(PKG)_FILE := rust-$($(PKG)_VERSION)-x86_64-pc-windows-gnu.tar.gz +$(PKG)_URL := https://static.rust-lang.org/dist/$($(PKG)_FILE) +$(PKG)_TYPE := source-only diff --git a/8.9/rust.mk b/8.9/rust.mk new file mode 100644 index 00000000..aeb9ec66 --- /dev/null +++ b/8.9/rust.mk @@ -0,0 +1,37 @@ +PKG := rust +$(PKG)_WEBSITE := https://www.rust-lang.org/ +$(PKG)_DESCR := A systems programming language focused on safety, speed and concurrency. +$(PKG)_IGNORE := +$(PKG)_VERSION := 1.42.0 +$(PKG)_CHECKSUM := 7d1e07ad9c8a33d8d039def7c0a131c5917aa3ea0af3d0cc399c6faf7b789052 +$(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION)-x86_64-unknown-linux-gnu +$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION)-x86_64-unknown-linux-gnu.tar.gz +$(PKG)_URL := https://static.rust-lang.org/dist/$($(PKG)_FILE) +$(PKG)_DEPS := $(foreach TARGET,$(MXE_TARGETS),rust-std-$(firstword $(call split,-,$(TARGET)))) + +define $(PKG)_BUILD + $(call PREPARE_PKG_SOURCE,rust-std-$(PROCESSOR),$(BUILD_DIR)) + mv '$(BUILD_DIR)/$(rust-std-$(PROCESSOR)_SUBDIR)' '$(SOURCE_DIR)' + echo 'rust-std-$(PROCESSOR)-pc-windows-gnu' >> '$(SOURCE_DIR)/components' + + cd '$(BUILD_DIR)' && $(SOURCE_DIR)/install.sh \ + --prefix='$(PREFIX)/$(TARGET)' \ + --components='rustc,cargo,rust-std-x86_64-unknown-linux-gnu,rust-std-$(PROCESSOR)-pc-windows-gnu' + + # install prefixed wrappers + $(INSTALL) -d '$(PREFIX)/$(TARGET)/.cargo' + (echo '#!/usr/bin/env bash'; \ + echo 'CARGO_HOME="$(PREFIX)/$(TARGET)/.cargo" \'; \ + echo 'RUSTC="$(PREFIX)/bin/$(TARGET)-rustc" \'; \ + echo 'exec $(PREFIX)/$(TARGET)/bin/cargo \'; \ + echo '"$$@"';) \ + > '$(PREFIX)/bin/$(TARGET)-cargo' + chmod 0755 '$(PREFIX)/bin/$(TARGET)-cargo' + + ln -sf '$(PREFIX)/$(TARGET)/bin/rustc' '$(PREFIX)/bin/$(TARGET)-rustc' + + # Prefer the {,dll}crt2.o libraries from our + # mingw-w64 to avoid any compatibility issues. + $(foreach FILE, crt2.o dllcrt2.o, \ + cp -f '$(PREFIX)/$(TARGET)/lib/$(FILE)' '$(PREFIX)/$(TARGET)/lib/rustlib/$(PROCESSOR)-pc-windows-gnu/lib';) +endef diff --git a/8.9/settings/gcc.mk b/8.9/settings/gcc.mk index 7b71ddc1..6520dccb 100644 --- a/8.9/settings/gcc.mk +++ b/8.9/settings/gcc.mk @@ -9,20 +9,12 @@ # use https://github.com/rainers/cv2pdb as workaround. # Special flags for compiler. -export CFLAGS := -s -O3 -ffast-math -fdata-sections -ffunction-sections \ - -fPIC -export CXXFLAGS := -s -O3 -ffast-math -fdata-sections -ffunction-sections \ - -fPIC +export CFLAGS := -s -O3 -fdata-sections -ffunction-sections -fPIC +export CXXFLAGS := -s -O3 -fdata-sections -ffunction-sections -fPIC export LDFLAGS := -Wl,--gc-sections -Wl,--strip-all -Wl,--as-needed -# Environment variables needed by Rust. -#export RUSTUP_HOME := /home/kleisauke/.rustup -#export CARGO_HOME := /home/kleisauke/.cargo -#export PATH := /home/kleisauke/.cargo/bin:$(PATH) -export RUSTUP_HOME := /usr/local/rustup -export RUSTFLAGS := -C opt-level=s -C lto=on -C codegen-units=1 -C incremental=false -C panic=abort -export CARGO_HOME := /usr/local/cargo -export PATH := /usr/local/cargo/bin:$(PATH) +# Special flags for Rust. +export RUSTFLAGS := -Copt-level=s -Clto=on -Ccodegen-units=1 -Cincremental=false -Cpanic=abort # We don't need debugging symbols. # For e.g. this commit: diff --git a/8.9/settings/llvm.mk b/8.9/settings/llvm.mk index 518edaf3..48d4f5db 100644 --- a/8.9/settings/llvm.mk +++ b/8.9/settings/llvm.mk @@ -13,18 +13,12 @@ # (see: https://github.com/mstorsjo/llvm-mingw/blob/master/README.md#pdb-support) # Special flags for compiler. -export CFLAGS := -s -O3 -ffast-math -export CXXFLAGS := -s -O3 -ffast-math +export CFLAGS := -s -O3 +export CXXFLAGS := -s -O3 export LDFLAGS := -Wl,-s -# Environment variables needed by Rust. -#export RUSTUP_HOME := /home/kleisauke/.rustup -#export CARGO_HOME := /home/kleisauke/.cargo -#export PATH := /home/kleisauke/.cargo/bin:$(PATH) -export RUSTUP_HOME := /usr/local/rustup -export RUSTFLAGS := -C opt-level=s -C lto=on -C codegen-units=1 -C incremental=false -C panic=abort -export CARGO_HOME := /usr/local/cargo -export PATH := /usr/local/cargo/bin:$(PATH) +# Special flags for Rust. +export RUSTFLAGS := -Copt-level=s -Clto=on -Ccodegen-units=1 -Cincremental=false -Cpanic=abort # We don't need debugging symbols. # For e.g. this commit: @@ -32,5 +26,5 @@ export PATH := /usr/local/cargo/bin:$(PATH) # adds ~26 MB to the librsvg DLL if we don't install-strip it. STRIP_LIB := $(true) -# Disable ccache, it won't work with llvm-mingw +# Disable ccache MXE_USE_CCACHE := $(false) diff --git a/8.9/vips-all.mk b/8.9/vips-all.mk index bef0064b..feba1d71 100644 --- a/8.9/vips-all.mk +++ b/8.9/vips-all.mk @@ -71,11 +71,11 @@ define $(PKG)_BUILD --without-pdfium \ --without-imagequant \ --disable-introspection \ - $(if $(findstring posix,$(TARGET)), CXXFLAGS="$(CXXFLAGS) -Wno-incompatible-ms-struct") + $(if $(IS_LLVM), CXXFLAGS="$(CXXFLAGS) -Wno-incompatible-ms-struct") # remove -nostdlib from linker commandline options # https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27866 - $(if $(findstring posix,$(TARGET)), \ + $(if $(IS_LLVM), \ $(SED) -i '/^archive_cmds=/s/\-nostdlib//g' '$(BUILD_DIR)/libtool') $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' diff --git a/8.9/vips-web.mk b/8.9/vips-web.mk index cdc9d6a7..3c07ebbb 100644 --- a/8.9/vips-web.mk +++ b/8.9/vips-web.mk @@ -75,7 +75,7 @@ define $(PKG)_BUILD --without-radiance \ --without-imagequant \ --disable-introspection \ - $(if $(findstring posix,$(TARGET)), CXXFLAGS="$(CXXFLAGS) -Wno-incompatible-ms-struct") \ + $(if $(IS_LLVM), CXXFLAGS="$(CXXFLAGS) -Wno-incompatible-ms-struct") \ $(if $(BUILD_STATIC), lt_cv_deplibs_check_method="pass_all") # libtool should automatically generate a list @@ -84,9 +84,10 @@ define $(PKG)_BUILD $(SED) -i 's/^always_export_symbols=no/always_export_symbols=yes/g' '$(BUILD_DIR)/libtool') # remove -nostdlib from linker commandline options + # (i.e. archive_cmds and archive_expsym_cmds) # https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27866 - $(if $(findstring posix,$(TARGET)), \ - $(SED) -i '/^archive_cmds=/s/\-nostdlib//g' '$(BUILD_DIR)/libtool') + $(if $(IS_LLVM), \ + $(SED) -i 's/\-shared \-nostdlib/\-shared/g' '$(BUILD_DIR)/libtool') $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' $(MAKE) -C '$(BUILD_DIR)' -j 1 install diff --git a/TODO.md b/TODO.md index bfe80614..8802ab66 100644 --- a/TODO.md +++ b/TODO.md @@ -3,9 +3,13 @@ - [ ] Wait for: [mxe/mxe#2021](https://github.com/mxe/mxe/issues/2021). - [ ] Incorporate all new dependencies and patches into [MXE](https://github.com/mxe/mxe). - [ ] Should we also add libvips-web? - - [ ] Not sure about `librsvg`, because v2.42.0+ requires the Rust toolchain. + - [x] Not sure about `librsvg`, because v2.42.0+ requires the Rust toolchain. - [ ] Try to test the binaries with the Python test suite on Wine. - [ ] Incorporate the llvm-mingw toolchain plugin into MXE (see [mxe/mxe#2330](https://github.com/mxe/mxe/issues/2330)). - - [ ] Test the `armv7-w64-mingw32` and `aarch64-w64-mingw32` targets. Perhaps there's a VM to test these architectures? - - [ ] Build LLVM for the target architecture (`-DLLVM_TARGETS_TO_BUILD=`) instead of constantly building all four architectures (i686, x86_64, armv7 and arm64). - - [ ] [`libffi`](8.9/libffi-3-fixes.patch), [`openslide`](8.9/openslide-3-fixes.patch) ([mstorsjo/llvm-mingw#67](https://github.com/mstorsjo/llvm-mingw/issues/67)), [`hdf5`](8.9/hdf5-1-fixes.patch) and [`glib`](8.9/glib-2-fixes.patch) needs llvm-mingw specific patches. Fix them upstream or within LLVM. + - [x] Test the `armv7-w64-mingw32` target on a Raspberry Pi 3 with Windows 10 IoT. + - [x] Compiling with `-O3 -ffast-math` throws a stack overflow exception (`0xC00000FD`) at runtime. Removing the `-ffast-math` flag seems to resolve this. + - [ ] Test the `aarch64-w64-mingw32` target. Perhaps there's a VM to test this architecture? + - [ ] The VIPS test suite should be able to run successfully on ARM/ARM64. + - [x] Build LLVM for the target architecture (`-DLLVM_TARGETS_TO_BUILD=`) instead of constantly building all four architectures (i686, x86_64, armv7 and arm64). + - [ ] [`libffi`](8.9/patches/libffi-3-fixes.patch), [`openslide`](8.9/patches/openslide-3-fixes.patch) ([mstorsjo/llvm-mingw#67](https://github.com/mstorsjo/llvm-mingw/issues/67)), [`hdf5`](8.9/patches/hdf5-1-fixes.patch) and [`glib`](8.9/patches/glib-2-fixes.patch) needs llvm-mingw specific patches. Fix them upstream or within LLVM. + - [ ] The Rust MinGW-w64 ARM/ARM64 targets are not yet supported, is there an alternative way to build librsvg for these architectures? diff --git a/build.sh b/build.sh index b1cf8a6c..b7b201e5 100755 --- a/build.sh +++ b/build.sh @@ -39,6 +39,11 @@ if [[ "$*" == *--with-llvm* ]]; then # threading API. threads="posix" with_llvm=true +elif [ "$arch" = "aarch64" ] || [ "$arch" = "armv7" ]; then + # Force the LLVM toolchain for the ARM/ARM64 targets, + # GCC does not support Windows on ARM. + threads="posix" + with_llvm=true else # Use native Win32 threading functions when compiling with # GCC because POSIX threads functionality is significantly @@ -59,12 +64,11 @@ if ! type docker > /dev/null; then exit 1 fi -# Ensure latest Debian stable base image, inherit from -# the Rust toolchain because librsvg needs it. -docker pull rust:buster +# Ensure latest Debian stable base image. +docker pull buildpack-deps:buster # Create a machine image with all the required build tools pre-installed. -docker build --build-arg ARCH=$arch -t libvips-build-win-mxe container +docker build -t libvips-build-win-mxe container # Run build scripts inside container # - inheriting the current uid and gid diff --git a/container/Dockerfile b/container/Dockerfile index 184c12a5..c026efdd 100644 --- a/container/Dockerfile +++ b/container/Dockerfile @@ -1,5 +1,4 @@ -# Rust toolchain is needed for librsvg -FROM rust:buster +FROM buildpack-deps:buster RUN apt-get update \ && apt-get install -y \ @@ -10,19 +9,17 @@ RUN apt-get update \ # needed when building libvips from git gobject-introspection gtk-doc-tools \ # needed for Meson - ninja-build python3-pip - -# Install Ninja and Meson -RUN pip3 install meson + ninja-build python3-pip \ + # install Meson + && pip3 install meson # TODO: This patch needs to be incorporated upstream RUN cd $(dirname `python3 -c "import mesonbuild as _; print(_.__path__[0])"`) \ && curl -L https://gist.github.com/kleisauke/a2370bf67d1d8813cf8257c039488a79/raw/31a930cc40fd17b7a69fb551668d7205313aee55/meson-llvm-mingw.patch | git apply -v -ARG ARCH=x86_64 - -# Add Windows target for cross-compilation -RUN rustup target add $ARCH-pc-windows-gnu +# gas-preprocessor.pl is required for the ARM/ARM64 builds of libjpeg-turbo +RUN curl -L https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl -o /usr/bin/gas-preprocessor.pl \ + && chmod +x /usr/bin/gas-preprocessor.pl # The versioned build dir is mounted at /data, so this runs the build script # in that