treewide: replace libc == "msvcrt" with isMinGW

msvcrt is only one of the libcs in MinGW. We therefore
replace explictly testing for msvcrt with the isMinGW
predicate. This lays the foundation for ucrt64 support.
This commit is contained in:
Moritz Angermann 2023-09-08 14:29:39 +08:00
parent 127ddbae4a
commit a81e3dcd75
9 changed files with 14 additions and 14 deletions

View File

@ -47,7 +47,7 @@ let
# See https://github.com/NixOS/nixpkgs/pull/209870#issuecomment-1500550903
disableBootstrap' = disableBootstrap && !langFortran && !langGo;
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW;
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)

View File

@ -19,7 +19,7 @@ drv: lib.pipe drv
(pkg: pkg.overrideAttrs (previousAttrs:
lib.optionalAttrs (
targetPlatform != hostPlatform &&
(enableShared || targetPlatform.libc == "msvcrt") &&
(enableShared || targetPlatform.isMinGW) &&
withoutTargetLibc
) {
makeFlags = [ "all-gcc" "all-target-libgcc" ];

View File

@ -115,7 +115,7 @@ let inherit version;
patches = callFile ./patches {};
/* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW;
stageNameAddon = if withoutTargetLibc then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-";

View File

@ -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
@ -91,7 +91,7 @@ let
++ lib.optional (!enablePython) "--without-python"
++ lib.optional needUserConfig "--user-config=user-config.jam"
++ lib.optional (stdenv.buildPlatform.isDarwin && stdenv.hostPlatform.isLinux) "pch=off"
++ lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [
++ lib.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 '{}' \;
'' + lib.optionalString (stdenv.hostPlatform.libc == "msvcrt") ''
'' + lib.optionalString stdenv.hostPlatform.isMinGW ''
$RANLIB "$out/lib/"*.a
'';

View File

@ -23,7 +23,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
''

View File

@ -42,7 +42,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" ];

View File

@ -17,7 +17,7 @@
(stdenv.hostPlatform == stdenv.buildPlatform || stdenv.hostPlatform.isCygwin || stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isWasi)
, icuSupport ? false
, icu
, enableShared ? stdenv.hostPlatform.libc != "msvcrt" && !stdenv.hostPlatform.isStatic
, enableShared ? !stdenv.hostPlatform.isMinGW && !stdenv.hostPlatform.isStatic
, enableStatic ? !enableShared
, gnome
}:

View File

@ -51,7 +51,7 @@ stdenv.mkDerivation (finalAttrs: {
setOutputFlags = false;
outputDoc = "dev"; # single tiny man3 page
dontConfigure = stdenv.hostPlatform.libc == "msvcrt";
dontConfigure = stdenv.hostPlatform.isMinGW;
preConfigure = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
export CHOST=${stdenv.hostPlatform.config}
@ -96,7 +96,7 @@ stdenv.mkDerivation (finalAttrs: {
''
# 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
'';
@ -109,7 +109,7 @@ stdenv.mkDerivation (finalAttrs: {
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"
@ -120,7 +120,7 @@ stdenv.mkDerivation (finalAttrs: {
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

View File

@ -21741,7 +21741,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 stdenv.targetPlatform.isMinGW 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;