cross: Allow Windows toolchains to use ucrt as libc.

main
Shea Levy 2 years ago
parent 4447d4071b
commit 504d38ae7b
No known key found for this signature in database
GPG Key ID: 5C0BD6957D86FE27
  1. 4
      pkgs/development/compilers/gcc/10/default.nix
  2. 4
      pkgs/development/compilers/gcc/11/default.nix
  3. 4
      pkgs/development/compilers/gcc/4.8/default.nix
  4. 4
      pkgs/development/compilers/gcc/4.9/default.nix
  5. 4
      pkgs/development/compilers/gcc/6/default.nix
  6. 4
      pkgs/development/compilers/gcc/7/default.nix
  7. 4
      pkgs/development/compilers/gcc/8/default.nix
  8. 4
      pkgs/development/compilers/gcc/9/default.nix
  9. 2
      pkgs/development/compilers/gcc/common/configure-flags.nix
  10. 6
      pkgs/development/libraries/boost/generic.nix
  11. 2
      pkgs/development/libraries/libiconv/default.nix
  12. 2
      pkgs/development/libraries/libjpeg-turbo/default.nix
  13. 2
      pkgs/development/libraries/libxml2/default.nix
  14. 8
      pkgs/development/libraries/zlib/default.nix
  15. 3
      pkgs/os-specific/windows/mingw-w64/default.nix
  16. 10
      pkgs/os-specific/windows/mingw-w64/headers.nix
  17. 4
      pkgs/top-level/all-packages.nix

@ -79,7 +79,7 @@ let majorVersion = "10";
}); });
/* Cross-gcc settings (build == host != target) */ /* 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"; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; 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" ]; makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc"; installTargets = "install-gcc install-target-libgcc";
} }

@ -82,7 +82,7 @@ let majorVersion = "11";
++ optional (!crossStageStatic && targetPlatform.isMinGW) ./Added-mcf-thread-model-support-from-mcfgthread.patch; ++ optional (!crossStageStatic && targetPlatform.isMinGW) ./Added-mcf-thread-model-support-from-mcfgthread.patch;
/* Cross-gcc settings (build == host != target) */ /* 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"; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; 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" ]; makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc"; installTargets = "install-gcc install-target-libgcc";
} }

@ -114,7 +114,7 @@ let majorVersion = "4";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Cross-gcc settings (build == host != target) */ /* 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"; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; 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" ]; makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc"; installTargets = "install-gcc install-target-libgcc";
} }

@ -130,7 +130,7 @@ let majorVersion = "4";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Cross-gcc settings (build == host != target) */ /* 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"; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; 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" ]; makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc"; installTargets = "install-gcc install-target-libgcc";
} }

@ -111,7 +111,7 @@ let majorVersion = "6";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Cross-gcc settings (build == host != target) */ /* 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"; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; 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" ]; makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc"; installTargets = "install-gcc install-target-libgcc";
} }

@ -87,7 +87,7 @@ let majorVersion = "7";
++ [ ../libsanitizer-no-cyclades-9.patch ]; ++ [ ../libsanitizer-no-cyclades-9.patch ];
/* Cross-gcc settings (build == host != target) */ /* 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"; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; 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" ]; makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc"; installTargets = "install-gcc install-target-libgcc";
} }

@ -71,7 +71,7 @@ let majorVersion = "8";
++ [ ../libsanitizer-no-cyclades-9.patch ]; ++ [ ../libsanitizer-no-cyclades-9.patch ];
/* Cross-gcc settings (build == host != target) */ /* 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"; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; 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" ]; makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc"; installTargets = "install-gcc install-target-libgcc";
} }

@ -98,7 +98,7 @@ let majorVersion = "9";
++ [ ../libsanitizer-no-cyclades-9.patch ]; ++ [ ../libsanitizer-no-cyclades-9.patch ];
/* Cross-gcc settings (build == host != target) */ /* 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"; stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; 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" ]; makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc"; installTargets = "install-gcc install-target-libgcc";
} }

@ -41,7 +41,7 @@ let
inherit (stdenv) inherit (stdenv)
buildPlatform hostPlatform targetPlatform; buildPlatform hostPlatform targetPlatform;
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW;
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)

@ -9,7 +9,7 @@
, enableDebug ? false , enableDebug ? false
, enableSingleThreaded ? false , enableSingleThreaded ? false
, enableMultiThreaded ? true , enableMultiThreaded ? true
, enableShared ? !(with stdenv.hostPlatform; isStatic || libc == "msvcrt") # problems for now , enableShared ? !(with stdenv.hostPlatform; isStatic || isMinGW) # problems for now
, enableStatic ? !enableShared , enableStatic ? !enableShared
, enablePython ? false , enablePython ? false
, enableNumpy ? false , enableNumpy ? false
@ -102,7 +102,7 @@ let
++ optional (toolset != null) "toolset=${toolset}" ++ optional (toolset != null) "toolset=${toolset}"
++ optional (!enablePython) "--without-python" ++ optional (!enablePython) "--without-python"
++ optional needUserConfig "--user-config=user-config.jam" ++ optional needUserConfig "--user-config=user-config.jam"
++ optionals (stdenv.hostPlatform.libc == "msvcrt") [ ++ optionals (stdenv.hostPlatform.isMinGW) [
"threadapi=win32" "threadapi=win32"
] ++ extraB2Args ] ++ extraB2Args
); );
@ -252,7 +252,7 @@ stdenv.mkDerivation {
# Make boost header paths relative so that they are not runtime dependencies # Make boost header paths relative so that they are not runtime dependencies
cd "$dev" && find include \( -name '*.hpp' -or -name '*.h' -or -name '*.ipp' \) \ cd "$dev" && find include \( -name '*.hpp' -or -name '*.h' -or -name '*.ipp' \) \
-exec sed '1s/^\xef\xbb\xbf//;1i#line 1 "{}"' -i '{}' \; -exec sed '1s/^\xef\xbb\xbf//;1i#line 1 "{}"' -i '{}' \;
'' + optionalString (stdenv.hostPlatform.libc == "msvcrt") '' '' + optionalString (stdenv.hostPlatform.isMinGW) ''
$RANLIB "$out/lib/"*.a $RANLIB "$out/lib/"*.a
''; '';

@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
]; ];
postPatch = 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 sed '/^_GL_WARN_ON_USE (gets/d' -i srclib/stdio.in.h
'' ''

@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
# This is needed by freeimage # This is needed by freeimage
patches = [ ./0001-Compile-transupp.c-as-part-of-the-library.patch ] 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; ./mingw-boolean.patch;
outputs = [ "bin" "dev" "dev_private" "out" "man" "doc" ]; outputs = [ "bin" "dev" "dev_private" "out" "man" "doc" ];

@ -14,7 +14,7 @@
, pythonSupport ? enableShared && stdenv.buildPlatform == stdenv.hostPlatform , pythonSupport ? enableShared && stdenv.buildPlatform == stdenv.hostPlatform
, icuSupport ? false , icuSupport ? false
, icu , icu
, enableShared ? stdenv.hostPlatform.libc != "msvcrt" && !stdenv.hostPlatform.isStatic , enableShared ? !stdenv.hostPlatform.isMinGW && !stdenv.hostPlatform.isStatic
, enableStatic ? !enableShared , enableStatic ? !enableShared
, gnome , gnome
}: }:

@ -88,7 +88,7 @@ stdenv.mkDerivation (rec {
'' ''
# Non-typical naming confuses libtool which then refuses to use zlib's DLL # Non-typical naming confuses libtool which then refuses to use zlib's DLL
# in some cases, e.g. when compiling libpng. # 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 ln -s zlib1.dll $out/bin/libz.dll
''; '';
@ -101,7 +101,7 @@ stdenv.mkDerivation (rec {
dontStrip = stdenv.hostPlatform != stdenv.buildPlatform && static; dontStrip = stdenv.hostPlatform != stdenv.buildPlatform && static;
configurePlatforms = []; configurePlatforms = [];
installFlags = lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [ installFlags = lib.optionals (stdenv.hostPlatform.isMinGW) [
"BINARY_PATH=$(out)/bin" "BINARY_PATH=$(out)/bin"
"INCLUDE_PATH=$(dev)/include" "INCLUDE_PATH=$(dev)/include"
"LIBRARY_PATH=$(out)/lib" "LIBRARY_PATH=$(out)/lib"
@ -112,7 +112,7 @@ stdenv.mkDerivation (rec {
makeFlags = [ makeFlags = [
"PREFIX=${stdenv.cc.targetPrefix}" "PREFIX=${stdenv.cc.targetPrefix}"
] ++ lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [ ] ++ lib.optionals (stdenv.hostPlatform.isMinGW) [
"-f" "win32/Makefile.gcc" "-f" "win32/Makefile.gcc"
] ++ lib.optionals shared [ ] ++ lib.optionals shared [
# Note that as of writing (zlib 1.2.11), this flag only has an effect # Note that as of writing (zlib 1.2.11), this flag only has an effect
@ -134,6 +134,6 @@ stdenv.mkDerivation (rec {
preConfigure = '' preConfigure = ''
export CHOST=${stdenv.hostPlatform.config} export CHOST=${stdenv.hostPlatform.config}
''; '';
} // lib.optionalAttrs (stdenv.hostPlatform.libc == "msvcrt") { } // lib.optionalAttrs (stdenv.hostPlatform.isMinGW) {
dontConfigure = true; dontConfigure = true;
}) })

@ -19,6 +19,7 @@ let
then [] # maybe autoconf will save us then [] # maybe autoconf will save us
else map (arch: lib.enableFeature (arch == enabledArch) "lib${arch}") knownArches; else map (arch: lib.enableFeature (arch == enabledArch) "lib${arch}") knownArches;
crt = stdenv.hostPlatform.libc;
in stdenv.mkDerivation { in stdenv.mkDerivation {
pname = "mingw-w64"; pname = "mingw-w64";
inherit version; inherit version;
@ -33,6 +34,7 @@ in stdenv.mkDerivation {
configureFlags = [ configureFlags = [
"--enable-idl" "--enable-idl"
"--enable-secure-api" "--enable-secure-api"
"--with-default-msvcrt=${crt}"
] ++ archFlags; ] ++ archFlags;
enableParallelBuilding = true; enableParallelBuilding = true;
@ -43,5 +45,6 @@ in stdenv.mkDerivation {
meta = { meta = {
platforms = lib.platforms.windows; platforms = lib.platforms.windows;
broken = !(lib.elem crt [ "msvcrt" "ucrt" ]);
}; };
} }

@ -1,6 +1,8 @@
{ stdenvNoCC, mingw_w64 }: { stdenvNoCC, mingw_w64 }:
stdenvNoCC.mkDerivation { let
crt = stdenvNoCC.hostPlatform.libc;
in stdenvNoCC.mkDerivation {
name = "${mingw_w64.name}-headers"; name = "${mingw_w64.name}-headers";
inherit (mingw_w64) src meta; inherit (mingw_w64) src meta;
@ -8,4 +10,10 @@ stdenvNoCC.mkDerivation {
cd mingw-w64-headers cd mingw-w64-headers
''; '';
configureFlags = [
"--enable-idl"
"--enable-secure-api"
"--with-default-msvcrt=${crt}"
];
} }

@ -17415,7 +17415,7 @@ with pkgs;
# These are used when buiding compiler-rt / libgcc, prior to building libc. # These are used when buiding compiler-rt / libgcc, prior to building libc.
preLibcCrossHeaders = let preLibcCrossHeaders = let
inherit (stdenv.targetPlatform) libc; 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 == "nblibc" then targetPackages.netbsdCross.headers or netbsdCross.headers
else if libc == "libSystem" && stdenv.targetPlatform.isAarch64 then targetPackages.darwin.LibsystemCross or darwin.LibsystemCross else if libc == "libSystem" && stdenv.targetPlatform.isAarch64 then targetPackages.darwin.LibsystemCross or darwin.LibsystemCross
else null; else null;
@ -17434,7 +17434,7 @@ with pkgs;
else if name == "newlib" then targetPackages.newlibCross or newlibCross else if name == "newlib" then targetPackages.newlibCross or newlibCross
else if name == "newlib-nano" then targetPackages.newlib-nanoCross or newlib-nanoCross else if name == "newlib-nano" then targetPackages.newlib-nanoCross or newlib-nanoCross
else if name == "musl" then targetPackages.muslCross or muslCross 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 else if name == "libSystem" then
if stdenv.targetPlatform.useiOSPrebuilt if stdenv.targetPlatform.useiOSPrebuilt
then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries

Loading…
Cancel
Save