From c6132dcf238b8ddc01174290fe31ed5001a58c01 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Wed, 7 Jun 2023 23:43:37 +0100 Subject: pkgsCross.mingwW64.windows.mcfgthreads: add gcc13 compatible version Upstream `gcc-13` merged `mcfgthreads` support with a caveat: it's headers interface is not compatible with the patch `nixpkgs` was carrying in `gcc-12` and before. To keep both new (`gcc13`) and old (`_pre_gcc13`) version I held back previous `windows.mcfgthreads` attribute as `windows.mcfgthreads_pre_gcc_13`. It is used for `gcc` before 13. The change fixes the build of `pkgsCross.mingwW64.stdenv` itself and example program: $ nix build --impure --expr 'with import ./. {}; pkgsCross.mingwW64.re2c.override { stdenv = pkgsCross.mingwW64.gcc11Stdenv; }' --- pkgs/misc/dxvk/default.nix | 4 +-- pkgs/os-specific/windows/default.nix | 4 +++ pkgs/os-specific/windows/mcfgthreads/default.nix | 11 +++----- .../os-specific/windows/mcfgthreads/pre_gcc_13.nix | 24 +++++++++++++++++ pkgs/top-level/all-packages.nix | 31 +++++++++++++++------- 5 files changed, 54 insertions(+), 20 deletions(-) create mode 100644 pkgs/os-specific/windows/mcfgthreads/pre_gcc_13.nix diff --git a/pkgs/misc/dxvk/default.nix b/pkgs/misc/dxvk/default.nix index e553d9b365c..49b6c4d0beb 100644 --- a/pkgs/misc/dxvk/default.nix +++ b/pkgs/misc/dxvk/default.nix @@ -27,8 +27,8 @@ stdenvNoCC.mkDerivation (finalAttrs: --subst-var-by bash ${bash} \ --subst-var-by dxvk32 ${dxvk32} \ --subst-var-by dxvk64 ${dxvk64} \ - --subst-var-by mcfgthreads32 "${pkgsCross.mingw32.windows.mcfgthreads}" \ - --subst-var-by mcfgthreads64 "${pkgsCross.mingwW64.windows.mcfgthreads}" + --subst-var-by mcfgthreads32 "${pkgsCross.mingw32.windows.mcfgthreads_pre_gcc_13}" \ + --subst-var-by mcfgthreads64 "${pkgsCross.mingwW64.windows.mcfgthreads_pre_gcc_13}" chmod a+x $out/bin/setup_dxvk.sh declare -A dxvks=( [x32]=${dxvk32} [x64]=${dxvk64} ) for arch in "''${!dxvks[@]}"; do diff --git a/pkgs/os-specific/windows/default.nix b/pkgs/os-specific/windows/default.nix index c34f97a17db..8d6dd50548e 100644 --- a/pkgs/os-specific/windows/default.nix +++ b/pkgs/os-specific/windows/default.nix @@ -33,6 +33,10 @@ lib.makeScope newScope (self: with self; { stdenv = crossThreadsStdenv; }; + mcfgthreads_pre_gcc_13 = callPackage ./mcfgthreads/pre_gcc_13.nix { + stdenv = crossThreadsStdenv; + }; + mcfgthreads = callPackage ./mcfgthreads { stdenv = crossThreadsStdenv; }; diff --git a/pkgs/os-specific/windows/mcfgthreads/default.nix b/pkgs/os-specific/windows/mcfgthreads/default.nix index 45c80ab8979..e0635efd0a5 100644 --- a/pkgs/os-specific/windows/mcfgthreads/default.nix +++ b/pkgs/os-specific/windows/mcfgthreads/default.nix @@ -2,22 +2,17 @@ stdenv.mkDerivation { pname = "mcfgthreads"; - version = "git"; + version = "unstable-2023-06-06"; src = fetchFromGitHub { owner = "lhmouse"; repo = "mcfgthread"; - rev = "c446cf4fcdc262fc899a188a4bb7136284c34222"; - sha256 = "1ib90lrd4dz8irq4yvzwhxqa86i5vxl2q2z3z04sf1i8hw427p2f"; + rev = "f0a335ce926906d634c787249a89220045bf0f7e"; + hash = "sha256-PLGIyoLdWgWvkHgRe0vHLIvnCxFpmHtbjS8xRhNM9Xw="; }; outputs = [ "out" "dev" ]; - # Don't want prebuilt binaries sneaking in. - postUnpack = '' - rm -r "$sourceRoot/debug" "$sourceRoot/release" - ''; - nativeBuildInputs = [ autoreconfHook ]; diff --git a/pkgs/os-specific/windows/mcfgthreads/pre_gcc_13.nix b/pkgs/os-specific/windows/mcfgthreads/pre_gcc_13.nix new file mode 100644 index 00000000000..6be64814c93 --- /dev/null +++ b/pkgs/os-specific/windows/mcfgthreads/pre_gcc_13.nix @@ -0,0 +1,24 @@ +{ stdenv, fetchFromGitHub, autoreconfHook }: + +stdenv.mkDerivation { + pname = "mcfgthreads"; + version = "git"; # unstable-2021-03-12, not in any branch + + src = fetchFromGitHub { + owner = "lhmouse"; + repo = "mcfgthread"; + rev = "c446cf4fcdc262fc899a188a4bb7136284c34222"; + sha256 = "1ib90lrd4dz8irq4yvzwhxqa86i5vxl2q2z3z04sf1i8hw427p2f"; + }; + + outputs = [ "out" "dev" ]; + + # Don't want prebuilt binaries sneaking in. + postUnpack = '' + rm -r "$sourceRoot/debug" "$sourceRoot/release" + ''; + + nativeBuildInputs = [ + autoreconfHook + ]; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 177d3eeea3e..f3dcbc5d368 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15097,7 +15097,7 @@ with pkgs; profiledCompiler = false; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else { }; + threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross_pre_gcc_13 else { }; isl = if !stdenv.isDarwin then isl_0_14 else null; cloog = if !stdenv.isDarwin then cloog else null; @@ -15111,7 +15111,7 @@ with pkgs; profiledCompiler = false; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else { }; + threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross_pre_gcc_13 else { }; isl = if !stdenv.isDarwin then isl_0_11 else null; @@ -15128,7 +15128,7 @@ with pkgs; profiledCompiler = false; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else { }; + threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross_pre_gcc_13 else { }; # gcc 10 is too strict to cross compile gcc <= 8 stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; @@ -15147,7 +15147,7 @@ with pkgs; profiledCompiler = false; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else { }; + threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross_pre_gcc_13 else { }; # gcc 10 is too strict to cross compile gcc <= 8 stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; @@ -15162,7 +15162,7 @@ with pkgs; profiledCompiler = false; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else { }; + threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross_pre_gcc_13 else { }; # gcc 10 is too strict to cross compile gcc <= 8 stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; @@ -15177,7 +15177,7 @@ with pkgs; profiledCompiler = false; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else { }; + threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross_pre_gcc_13 else { }; isl = if !stdenv.isDarwin then isl_0_20 else null; })); @@ -15189,7 +15189,7 @@ with pkgs; profiledCompiler = false; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else { }; + threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross_pre_gcc_13 else { }; isl = if !stdenv.isDarwin then isl_0_20 else null; })); @@ -15201,7 +15201,7 @@ with pkgs; profiledCompiler = false; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else { }; + threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross_pre_gcc_13 else { }; isl = if !stdenv.isDarwin then isl_0_20 else null; })); @@ -15213,7 +15213,7 @@ with pkgs; profiledCompiler = false; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else { }; + threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross_pre_gcc_13 else { }; isl = if !stdenv.isDarwin then isl_0_20 else null; })); @@ -16819,7 +16819,10 @@ with pkgs; # want the C++ library to be explicitly chosen by the caller, and null by # default. libcxx ? null - , extraPackages ? lib.optional (cc.isGNU or false && stdenv.targetPlatform.isMinGW) threadsCross.package + , extraPackages ? lib.optional (cc.isGNU or false && stdenv.targetPlatform.isMinGW) + (if lib.versionAtLeast cc.version "13" + then threadsCross.package + else threadsCross_pre_gcc_13.package) , nixSupport ? {} , ... } @ extraArgs: @@ -20803,6 +20806,14 @@ with pkgs; libcCross = assert stdenv.targetPlatform != stdenv.buildPlatform; libcCrossChooser stdenv.targetPlatform.libc; + threadsCross_pre_gcc_13 = if stdenv.targetPlatform.isMinGW && !(stdenv.targetPlatform.useLLVM or false) + then { + # other possible values: win32 or posix + model = "mcf"; + # For win32 or posix set this to null + package = targetPackages.windows.mcfgthreads_pre_gcc_13 or windows.mcfgthreads_pre_gcc_13; + } else { }; + threadsCross = if stdenv.targetPlatform.isMinGW && !(stdenv.targetPlatform.useLLVM or false) then { # other possible values: win32 or posix -- cgit 1.4.1