# HG changeset patch # User Markus Mützel # Date 1637243366 -3600 # Node ID 7c0066684448ea8d4f1cc9bc5d75785fca7664bc # Parent 49b3f6c6d25525aa4e48f3845d61d86e01d28a90 Add support for building with UCRT on Windows. * configure.ac: Add new configure switch "--with-windows-msvcrt". It can be set to "msvcrt" (default) or "ucrt". * Makefile.in: Make configure result of new switch available in makefile rules. * src/mingw-w64.mk, src/build-gcc.mk: Select CRT when installing system headers and when compiling system runtime. See also: https://octave.discourse.group/t/1821 diff -r 49b3f6c6d255 -r 7c0066684448 Makefile.in --- a/Makefile.in Sun Nov 21 12:29:36 2021 +0100 +++ b/Makefile.in Thu Nov 18 14:49:26 2021 +0100 @@ -80,6 +80,9 @@ # Set to "yes" to use msys2 USE_MSYS2 := @USE_MSYS2@ +# Set to "ucrt" or "msvcrt" +HOST_MSVCRT := @HOST_MSVCRT@ + # Should match what config.guess prints for your system. # If cross compiling, you must set it manually (defaults are set by configure). ifeq ($(MXE_NATIVE_BUILD),yes) diff -r 49b3f6c6d255 -r 7c0066684448 configure.ac --- a/configure.ac Sun Nov 21 12:29:36 2021 +0100 +++ b/configure.ac Thu Nov 18 14:49:26 2021 +0100 @@ -99,6 +99,16 @@ esac], [USE_MSYS2=yes]) AC_SUBST(USE_MSYS2) +# Use "msvcrt" or "ucrt" on Windows +AC_ARG_WITH([windows-msvcrt], + [AS_HELP_STRING([--with-windows-msvcrt=msvcrt], [select C runtime for windows distribution (default: msvcrt)])], + [case $withval in + no) AC_MSG_ERROR([A runtime for Windows is required for --with-windows-msvcrt]) ;; + yes | "") HOST_MSVCRT=msvcrt ;; + *) HOST_MSVCRT="$withval" ;; + esac], [HOST_MSVCRT=msvcrt]) +AC_SUBST(HOST_MSVCRT) + # try find pkg-config build paths BUILD_PKG_CONFIG_PATH=auto AC_ARG_WITH([build-pkg-config-path], @@ -130,6 +140,10 @@ *) AC_MSG_ERROR([bad value "$enableval" for --enable-windows-64]) ;; esac], [ENABLE_WINDOWS_64=yes]) +if test "$ENABLE_WINDOWS_64" = "no" && test "$HOST_MSVCRT" = "ucrt"; then + AC_MSG_NOTICE([UCRT is only supported with --enable-windows-64]) +fi + AC_ARG_ENABLE([64], [AS_HELP_STRING([--enable-64], [use 64-bit integers for array dimensions and indexing])], diff -r 49b3f6c6d255 -r 7c0066684448 src/build-gcc.mk --- a/src/build-gcc.mk Sun Nov 21 12:29:36 2021 +0100 +++ b/src/build-gcc.mk Thu Nov 18 14:49:26 2021 +0100 @@ -54,6 +54,12 @@ $(PKG)_WINAPI_VERSION_FLAGS := --with-default-win32-winnt=0x0601 endif + ifneq ($(HOST_MSVCRT),ucrt) + $(PKG)_DEFAULT_MSVCRT := --with-default-msvcrt=msvcrt + else + $(PKG)_DEFAULT_MSVCRT := --with-default-msvcrt=ucrt + endif + define $(PKG)_INSTALL_SYSTEM_HEADERS $($(PKG)_PRE_BUILD) # install mingw-w64 headers @@ -66,6 +72,7 @@ --enable-idl \ --enable-secure-api \ $($(PKG)_WINAPI_VERSION_FLAGS) \ + $($(PKG)_DEFAULT_MSVCRT) \ $(mingw-w64-headers_CONFIGURE_OPTS) $(MAKE) -C '$(1).headers' install endef @@ -80,7 +87,8 @@ --host='$(TARGET)' \ --prefix='$(HOST_PREFIX)' \ $(if $(filter $(TARGET), x86_64-w64-mingw32),--disable-lib32) \ - --with-sysroot='$(HOST_PREFIX)' + --with-sysroot='$(HOST_PREFIX)' \ + $($(PKG)_DEFAULT_MSVCRT) $(MAKE) -C '$(1).crt-build' -j '$(JOBS)' || $(MAKE) -C '$(1).crt-build' -j '$(JOBS)' $(MAKE) -C '$(1).crt-build' -j 1 install diff -r 49b3f6c6d255 -r 7c0066684448 src/mingw-w64.mk --- a/src/mingw-w64.mk Sun Nov 21 12:29:36 2021 +0100 +++ b/src/mingw-w64.mk Thu Nov 18 14:49:26 2021 +0100 @@ -22,6 +22,12 @@ $(PKG)_WINAPI_VERSION_FLAGS := --with-default-win32-winnt=0x0601 endif +ifneq ($(HOST_MSVCRT),ucrt) + $(PKG)_DEFAULT_MSVCRT := --with-default-msvcrt=msvcrt +else + $(PKG)_DEFAULT_MSVCRT := --with-default-msvcrt=ucrt +endif + define $(PKG)_BUILD mkdir '$(1).headers-build' cd '$(1).headers-build' && '$(1)/mingw-w64-headers/configure' \ @@ -30,7 +36,8 @@ --enable-sdk=all \ --enable-idl \ --enable-secure-api \ - $($(PKG)_WINAPI_VERSION_FLAGS) + $($(PKG)_WINAPI_VERSION_FLAGS) \ + $($(PKG)_DEFAULT_MSVCRT) $(MAKE) -C '$(1).headers-build' install endef