diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index c972f29289d3..49f0c6b3ec3a 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -69,6 +69,10 @@ in || (stdenv.hostPlatform != stdenv.targetPlatform) ), + # Enable NUMA support in RTS + enableNuma ? lib.meta.availableOn stdenv.targetPlatform numactl, + numactl, + # What flavour to build. An empty string indicates no # specific flavour and falls back to ghc default values. ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) ( @@ -265,7 +269,7 @@ let basePackageSet = if hostPlatform != targetPlatform then targetPackages else pkgsHostTarget; in { - inherit (basePackageSet) gmp ncurses; + inherit (basePackageSet) gmp ncurses numactl; # dynamic inherits are not possible in Nix libffi = basePackageSet.${libffi_name}; }; @@ -513,6 +517,11 @@ stdenv.mkDerivation ( ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" ] + ++ lib.optionals enableNuma [ + "--enable-numa" + "--with-libnuma-includes=${lib.getDev targetLibs.numactl}/include" + "--with-libnuma-libraries=${lib.getLib targetLibs.numactl}/lib" + ] ++ lib.optionals enableUnregisterised [ "--enable-unregisterised" ]; @@ -565,8 +574,13 @@ stdenv.mkDerivation ( buildInputs = [ bash ] ++ (libDeps hostPlatform); - depsTargetTarget = map lib.getDev (libDeps targetPlatform); - depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); + # stage1 GHC doesn't need to link against libnuma, so it's target specific + depsTargetTarget = map lib.getDev ( + libDeps targetPlatform ++ lib.optionals enableNuma [ targetLibs.numactl ] + ); + depsTargetTargetPropagated = map (lib.getOutput "out") ( + libDeps targetPlatform ++ lib.optionals enableNuma [ targetLibs.numactl ] + ); # required, because otherwise all symbols from HSffi.o are stripped, and # that in turn causes GHCi to abort diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index acdb2d5bd884..1240dc3e158a 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -91,6 +91,10 @@ && !stdenv.hostPlatform.isStatic, elfutils, + # Enable NUMA support in RTS + enableNuma ? lib.meta.availableOn stdenv.targetPlatform numactl, + numactl, + # What flavour to build. Flavour string may contain a flavour and flavour # transformers as accepted by hadrian. ghcFlavour ? @@ -479,6 +483,7 @@ let gmp libffi ncurses + numactl ; }; @@ -664,6 +669,11 @@ stdenv.mkDerivation ( "--with-libdw-includes=${lib.getDev targetLibs.elfutils}/include" "--with-libdw-libraries=${lib.getLib targetLibs.elfutils}/lib" ] + ++ lib.optionals enableNuma [ + "--enable-numa" + "--with-libnuma-includes=${lib.getDev targetLibs.numactl}/include" + "--with-libnuma-libraries=${lib.getLib targetLibs.numactl}/lib" + ] ++ lib.optionals targetPlatform.isDarwin [ # Darwin uses llvm-ar. GHC will try to use `-L` with `ar` when it is `llvm-ar` # but it doesn’t currently work because Cabal never uses `-L` on Darwin. See: @@ -731,8 +741,13 @@ stdenv.mkDerivation ( buildInputs = [ bash ] ++ (libDeps hostPlatform); - depsTargetTarget = map lib.getDev (libDeps targetPlatform); - depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); + # stage0:ghc (i.e. stage1) doesn't need to link against libnuma, so it's target specific + depsTargetTarget = map lib.getDev ( + libDeps targetPlatform ++ lib.optionals enableNuma [ targetLibs.numactl ] + ); + depsTargetTargetPropagated = map (lib.getOutput "out") ( + libDeps targetPlatform ++ lib.optionals enableNuma [ targetLibs.numactl ] + ); hadrianFlags = [ diff --git a/pkgs/development/compilers/ghc/common-make-native-bignum.nix b/pkgs/development/compilers/ghc/common-make-native-bignum.nix index 9c42c41cd1da..924934937e98 100644 --- a/pkgs/development/compilers/ghc/common-make-native-bignum.nix +++ b/pkgs/development/compilers/ghc/common-make-native-bignum.nix @@ -68,6 +68,10 @@ || (stdenv.hostPlatform != stdenv.targetPlatform) ), + # Enable NUMA support in RTS + enableNuma ? lib.meta.availableOn stdenv.targetPlatform numactl, + numactl, + # What flavour to build. An empty string indicates no # specific flavour and falls back to ghc default values. ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) ( @@ -261,6 +265,7 @@ let gmp libffi ncurses + numactl ; }; @@ -565,6 +570,11 @@ stdenv.mkDerivation ( ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" ] + ++ lib.optionals enableNuma [ + "--enable-numa" + "--with-libnuma-includes=${lib.getDev targetLibs.numactl}/include" + "--with-libnuma-libraries=${lib.getLib targetLibs.numactl}/lib" + ] ++ lib.optionals enableUnregisterised [ "--enable-unregisterised" ]; @@ -621,8 +631,13 @@ stdenv.mkDerivation ( buildInputs = [ bash ] ++ (libDeps hostPlatform); - depsTargetTarget = map lib.getDev (libDeps targetPlatform); - depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); + # stage1 GHC doesn't need to link against libnuma, so it's target specific + depsTargetTarget = map lib.getDev ( + libDeps targetPlatform ++ lib.optionals enableNuma [ targetLibs.numactl ] + ); + depsTargetTargetPropagated = map (lib.getOutput "out") ( + libDeps targetPlatform ++ lib.optionals enableNuma [ targetLibs.numactl ] + ); # required, because otherwise all symbols from HSffi.o are stripped, and # that in turn causes GHCi to abort