diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix index 88d4831812f..187d43b5091 100644 --- a/pkgs/development/compilers/gcc/10/default.nix +++ b/pkgs/development/compilers/gcc/10/default.nix @@ -79,7 +79,7 @@ let majorVersion = "10"; }); /* Cross-gcc settings (build == host != target) */ - crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final"; crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; @@ -292,7 +292,7 @@ stdenv.mkDerivation ({ }; } -// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.isMinGW && crossStageStatic) { makeFlags = [ "all-gcc" "all-target-libgcc" ]; installTargets = "install-gcc install-target-libgcc"; } diff --git a/pkgs/development/compilers/gcc/11/default.nix b/pkgs/development/compilers/gcc/11/default.nix index ba4b10cf73e..adb441888d8 100644 --- a/pkgs/development/compilers/gcc/11/default.nix +++ b/pkgs/development/compilers/gcc/11/default.nix @@ -82,7 +82,7 @@ let majorVersion = "11"; ++ optional (!crossStageStatic && targetPlatform.isMinGW) ./Added-mcf-thread-model-support-from-mcfgthread.patch; /* Cross-gcc settings (build == host != target) */ - crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final"; crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; @@ -296,7 +296,7 @@ stdenv.mkDerivation ({ }; } -// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.isMinGW && crossStageStatic) { makeFlags = [ "all-gcc" "all-target-libgcc" ]; installTargets = "install-gcc install-target-libgcc"; } diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 8cd0d3c9ce8..03646c65220 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -114,7 +114,7 @@ let majorVersion = "4"; javaAwtGtk = langJava && x11Support; /* Cross-gcc settings (build == host != target) */ - crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final"; crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; @@ -316,7 +316,7 @@ stdenv.mkDerivation ({ }; } -// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.isMinGW && crossStageStatic) { makeFlags = [ "all-gcc" "all-target-libgcc" ]; installTargets = "install-gcc install-target-libgcc"; } diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index b3d0f8d5d50..d3bd1b70641 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -130,7 +130,7 @@ let majorVersion = "4"; javaAwtGtk = langJava && x11Support; /* Cross-gcc settings (build == host != target) */ - crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final"; crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; @@ -332,7 +332,7 @@ stdenv.mkDerivation ({ }; } -// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.isMinGW && crossStageStatic) { makeFlags = [ "all-gcc" "all-target-libgcc" ]; installTargets = "install-gcc install-target-libgcc"; } diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 62b46df1ab0..d3007f17063 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -111,7 +111,7 @@ let majorVersion = "6"; javaAwtGtk = langJava && x11Support; /* Cross-gcc settings (build == host != target) */ - crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final"; crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; @@ -345,7 +345,7 @@ stdenv.mkDerivation ({ }; } -// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.isMinGW && crossStageStatic) { makeFlags = [ "all-gcc" "all-target-libgcc" ]; installTargets = "install-gcc install-target-libgcc"; } diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 1abf14c8a8c..1eb23061f64 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -87,7 +87,7 @@ let majorVersion = "7"; ++ [ ../libsanitizer-no-cyclades-9.patch ]; /* Cross-gcc settings (build == host != target) */ - crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final"; crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; @@ -301,7 +301,7 @@ stdenv.mkDerivation ({ }; } -// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.isMinGW && crossStageStatic) { makeFlags = [ "all-gcc" "all-target-libgcc" ]; installTargets = "install-gcc install-target-libgcc"; } diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix index 2dd265b648c..b6c37c77dd0 100644 --- a/pkgs/development/compilers/gcc/8/default.nix +++ b/pkgs/development/compilers/gcc/8/default.nix @@ -71,7 +71,7 @@ let majorVersion = "8"; ++ [ ../libsanitizer-no-cyclades-9.patch ]; /* Cross-gcc settings (build == host != target) */ - crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final"; crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; @@ -280,7 +280,7 @@ stdenv.mkDerivation ({ }; } -// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.isMinGW && crossStageStatic) { makeFlags = [ "all-gcc" "all-target-libgcc" ]; installTargets = "install-gcc install-target-libgcc"; } diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix index 2ecfa1bb1cf..09e4ef3fdff 100644 --- a/pkgs/development/compilers/gcc/9/default.nix +++ b/pkgs/development/compilers/gcc/9/default.nix @@ -98,7 +98,7 @@ let majorVersion = "9"; ++ [ ../libsanitizer-no-cyclades-9.patch ]; /* Cross-gcc settings (build == host != target) */ - crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final"; crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; @@ -311,7 +311,7 @@ stdenv.mkDerivation ({ }; } -// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.isMinGW && crossStageStatic) { makeFlags = [ "all-gcc" "all-target-libgcc" ]; installTargets = "install-gcc install-target-libgcc"; } diff --git a/pkgs/development/compilers/gcc/common/configure-flags.nix b/pkgs/development/compilers/gcc/common/configure-flags.nix index bebf91114d7..100d172403a 100644 --- a/pkgs/development/compilers/gcc/common/configure-flags.nix +++ b/pkgs/development/compilers/gcc/common/configure-flags.nix @@ -41,7 +41,7 @@ let inherit (stdenv) buildPlatform hostPlatform targetPlatform; - crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) diff --git a/pkgs/development/libraries/boost/generic.nix b/pkgs/development/libraries/boost/generic.nix index 34ab5554e74..27b45a85299 100644 --- a/pkgs/development/libraries/boost/generic.nix +++ b/pkgs/development/libraries/boost/generic.nix @@ -9,7 +9,7 @@ , enableDebug ? false , enableSingleThreaded ? false , enableMultiThreaded ? true -, enableShared ? !(with stdenv.hostPlatform; isStatic || libc == "msvcrt") # problems for now +, enableShared ? !(with stdenv.hostPlatform; isStatic || isMinGW) # problems for now , enableStatic ? !enableShared , enablePython ? false , enableNumpy ? false @@ -102,7 +102,7 @@ let ++ optional (toolset != null) "toolset=${toolset}" ++ optional (!enablePython) "--without-python" ++ optional needUserConfig "--user-config=user-config.jam" - ++ optionals (stdenv.hostPlatform.libc == "msvcrt") [ + ++ optionals (stdenv.hostPlatform.isMinGW) [ "threadapi=win32" ] ++ extraB2Args ); @@ -252,7 +252,7 @@ stdenv.mkDerivation { # Make boost header paths relative so that they are not runtime dependencies cd "$dev" && find include \( -name '*.hpp' -or -name '*.h' -or -name '*.ipp' \) \ -exec sed '1s/^\xef\xbb\xbf//;1i#line 1 "{}"' -i '{}' \; - '' + optionalString (stdenv.hostPlatform.libc == "msvcrt") '' + '' + optionalString (stdenv.hostPlatform.isMinGW) '' $RANLIB "$out/lib/"*.a ''; diff --git a/pkgs/development/libraries/libiconv/default.nix b/pkgs/development/libraries/libiconv/default.nix index 5be5ecfd82e..8051cf319e9 100644 --- a/pkgs/development/libraries/libiconv/default.nix +++ b/pkgs/development/libraries/libiconv/default.nix @@ -20,7 +20,7 @@ stdenv.mkDerivation rec { ]; postPatch = - lib.optionalString ((stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.libc == "msvcrt") || stdenv.cc.nativeLibc) + lib.optionalString ((stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.isMinGW) || stdenv.cc.nativeLibc) '' sed '/^_GL_WARN_ON_USE (gets/d' -i srclib/stdio.in.h '' diff --git a/pkgs/development/libraries/libjpeg-turbo/default.nix b/pkgs/development/libraries/libjpeg-turbo/default.nix index 75ec20545ca..2e400f9a31c 100644 --- a/pkgs/development/libraries/libjpeg-turbo/default.nix +++ b/pkgs/development/libraries/libjpeg-turbo/default.nix @@ -27,7 +27,7 @@ stdenv.mkDerivation rec { # This is needed by freeimage patches = [ ./0001-Compile-transupp.c-as-part-of-the-library.patch ] - ++ lib.optional (stdenv.hostPlatform.libc or null == "msvcrt") + ++ lib.optional (stdenv.hostPlatform.isMinGW) ./mingw-boolean.patch; outputs = [ "bin" "dev" "dev_private" "out" "man" "doc" ]; diff --git a/pkgs/development/libraries/libxml2/default.nix b/pkgs/development/libraries/libxml2/default.nix index 06c073c718a..494e9042101 100644 --- a/pkgs/development/libraries/libxml2/default.nix +++ b/pkgs/development/libraries/libxml2/default.nix @@ -14,7 +14,7 @@ , pythonSupport ? enableShared && stdenv.buildPlatform == stdenv.hostPlatform , icuSupport ? false , icu -, enableShared ? stdenv.hostPlatform.libc != "msvcrt" && !stdenv.hostPlatform.isStatic +, enableShared ? !stdenv.hostPlatform.isMinGW && !stdenv.hostPlatform.isStatic , enableStatic ? !enableShared , gnome }: diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix index 9b9938746ca..ed7ff17dc3d 100644 --- a/pkgs/development/libraries/zlib/default.nix +++ b/pkgs/development/libraries/zlib/default.nix @@ -88,7 +88,7 @@ stdenv.mkDerivation (rec { '' # Non-typical naming confuses libtool which then refuses to use zlib's DLL # in some cases, e.g. when compiling libpng. - + lib.optionalString (stdenv.hostPlatform.libc == "msvcrt" && shared) '' + + lib.optionalString (stdenv.hostPlatform.isMinGW && shared) '' ln -s zlib1.dll $out/bin/libz.dll ''; @@ -101,7 +101,7 @@ stdenv.mkDerivation (rec { dontStrip = stdenv.hostPlatform != stdenv.buildPlatform && static; configurePlatforms = []; - installFlags = lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [ + installFlags = lib.optionals (stdenv.hostPlatform.isMinGW) [ "BINARY_PATH=$(out)/bin" "INCLUDE_PATH=$(dev)/include" "LIBRARY_PATH=$(out)/lib" @@ -112,7 +112,7 @@ stdenv.mkDerivation (rec { makeFlags = [ "PREFIX=${stdenv.cc.targetPrefix}" - ] ++ lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [ + ] ++ lib.optionals (stdenv.hostPlatform.isMinGW) [ "-f" "win32/Makefile.gcc" ] ++ lib.optionals shared [ # Note that as of writing (zlib 1.2.11), this flag only has an effect @@ -134,6 +134,6 @@ stdenv.mkDerivation (rec { preConfigure = '' export CHOST=${stdenv.hostPlatform.config} ''; -} // lib.optionalAttrs (stdenv.hostPlatform.libc == "msvcrt") { +} // lib.optionalAttrs (stdenv.hostPlatform.isMinGW) { dontConfigure = true; }) diff --git a/pkgs/os-specific/windows/mingw-w64/default.nix b/pkgs/os-specific/windows/mingw-w64/default.nix index 85527157eea..02cfd7b04a7 100644 --- a/pkgs/os-specific/windows/mingw-w64/default.nix +++ b/pkgs/os-specific/windows/mingw-w64/default.nix @@ -19,6 +19,7 @@ let then [] # maybe autoconf will save us else map (arch: lib.enableFeature (arch == enabledArch) "lib${arch}") knownArches; + crt = stdenv.hostPlatform.libc; in stdenv.mkDerivation { pname = "mingw-w64"; inherit version; @@ -33,6 +34,7 @@ in stdenv.mkDerivation { configureFlags = [ "--enable-idl" "--enable-secure-api" + "--with-default-msvcrt=${crt}" ] ++ archFlags; enableParallelBuilding = true; @@ -43,5 +45,6 @@ in stdenv.mkDerivation { meta = { platforms = lib.platforms.windows; + broken = !(lib.elem crt [ "msvcrt" "ucrt" ]); }; } diff --git a/pkgs/os-specific/windows/mingw-w64/headers.nix b/pkgs/os-specific/windows/mingw-w64/headers.nix index 1fd27a8c457..13ba330ef2a 100644 --- a/pkgs/os-specific/windows/mingw-w64/headers.nix +++ b/pkgs/os-specific/windows/mingw-w64/headers.nix @@ -1,6 +1,8 @@ { stdenvNoCC, mingw_w64 }: -stdenvNoCC.mkDerivation { +let + crt = stdenvNoCC.hostPlatform.libc; +in stdenvNoCC.mkDerivation { name = "${mingw_w64.name}-headers"; inherit (mingw_w64) src meta; @@ -8,4 +10,10 @@ stdenvNoCC.mkDerivation { cd mingw-w64-headers ''; + configureFlags = [ + "--enable-idl" + "--enable-secure-api" + "--with-default-msvcrt=${crt}" + ]; + } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6d259511e79..80ee2dc3ea0 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17415,7 +17415,7 @@ with pkgs; # These are used when buiding compiler-rt / libgcc, prior to building libc. preLibcCrossHeaders = let inherit (stdenv.targetPlatform) libc; - in if libc == "msvcrt" then targetPackages.windows.mingw_w64_headers or windows.mingw_w64_headers + in if libc == "msvcrt" || libc == "ucrt" then targetPackages.windows.mingw_w64_headers or windows.mingw_w64_headers else if libc == "nblibc" then targetPackages.netbsdCross.headers or netbsdCross.headers else if libc == "libSystem" && stdenv.targetPlatform.isAarch64 then targetPackages.darwin.LibsystemCross or darwin.LibsystemCross else null; @@ -17434,7 +17434,7 @@ with pkgs; else if name == "newlib" then targetPackages.newlibCross or newlibCross else if name == "newlib-nano" then targetPackages.newlib-nanoCross or newlib-nanoCross else if name == "musl" then targetPackages.muslCross or muslCross - else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64 + else if name == "msvcrt" || name == "ucrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64 else if name == "libSystem" then if stdenv.targetPlatform.useiOSPrebuilt then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries