core/pkgs/by-name/gc/gcc/packages.nix

442 lines
11 KiB
Nix
Raw Normal View History

2024-05-02 00:46:19 +00:00
{ noSysDirs, ... }:
res: pkgs: super:
2024-06-30 08:16:52 +00:00
with pkgs; {
default-gcc-version = if (with stdenv.targetPlatform; isVc4 || libc == "relibc") then 6 else 13;
2024-05-02 00:46:19 +00:00
gcc = pkgs.${"gcc${toString default-gcc-version}"};
gccFun = callPackage ./.;
gcc-unwrapped = gcc.cc;
gccStdenv =
2024-06-30 08:16:52 +00:00
if stdenv.cc.isGNU then
stdenv
2024-05-02 00:46:19 +00:00
else
stdenv.override {
cc = buildPackages.gcc;
allowedRequisites = null;
# Remove libcxx/libcxxabi, and add clang for AS if on darwin (it uses
# clang's internal assembler).
extraBuildInputs = lib.optional stdenv.hostPlatform.isDarwin clang.cc;
};
gcc49Stdenv = overrideCC gccStdenv buildPackages.gcc49;
gcc6Stdenv = overrideCC gccStdenv buildPackages.gcc6;
gcc7Stdenv = overrideCC gccStdenv buildPackages.gcc7;
gcc8Stdenv = overrideCC gccStdenv buildPackages.gcc8;
gcc9Stdenv = overrideCC gccStdenv buildPackages.gcc9;
gcc10Stdenv = overrideCC gccStdenv buildPackages.gcc10;
gcc11Stdenv = overrideCC gccStdenv buildPackages.gcc11;
gcc12Stdenv = overrideCC gccStdenv buildPackages.gcc12;
gcc13Stdenv = overrideCC gccStdenv buildPackages.gcc13;
# This is not intended for use in nixpkgs but for providing a faster-running
# compiler to nixpkgs users by building gcc with reproducibility-breaking
# profile-guided optimizations
fastStdenv = overrideCC gccStdenv (wrapNonDeterministicGcc gccStdenv buildPackages.gcc_latest);
2024-06-30 08:16:52 +00:00
wrapCCMulti =
cc:
2024-05-02 00:46:19 +00:00
if stdenv.targetPlatform.system == "x86_64-linux" then
let
# Binutils with glibc multi
2024-06-30 08:16:52 +00:00
bintools = cc.bintools.override { libc = glibc_multi; };
2024-05-02 00:46:19 +00:00
in
lowPrio (wrapCCWith {
cc = cc.cc.override {
stdenv = overrideCC stdenv (wrapCCWith {
cc = cc.cc;
inherit bintools;
libc = glibc_multi;
});
profiledCompiler = false;
enableMultilib = true;
};
libc = glibc_multi;
inherit bintools;
extraBuildCommands = ''
echo "dontMoveLib64=1" >> $out/nix-support/setup-hook
'';
2024-06-30 08:16:52 +00:00
})
else
throw "Multilib ${cc.name} not supported for ${stdenv.targetPlatform.system}";
2024-05-02 00:46:19 +00:00
gcc_multi = wrapCCMulti gcc;
gccMultiStdenv = overrideCC stdenv buildPackages.gcc_multi;
2024-06-30 08:16:52 +00:00
gcc_debug = lowPrio (wrapCC (gcc.cc.overrideAttrs { dontStrip = true; }));
2024-05-02 00:46:19 +00:00
gccCrossLibcStdenv = overrideCC stdenv buildPackages.gccWithoutTargetLibc;
# The GCC used to build libc for the target platform. Normal gccs will be
# built with, and use, that cross-compiled libc.
2024-06-30 08:16:52 +00:00
gccWithoutTargetLibc =
assert stdenv.targetPlatform != stdenv.hostPlatform;
let
libcCross1 = binutilsNoLibc.libc;
in
wrapCCWith {
cc = gccFun {
# copy-pasted
inherit noSysDirs;
majorMinorVersion = toString default-gcc-version;
reproducibleBuild = true;
profiledCompiler = false;
isl = if !stdenv.isDarwin then isl_0_20 else null;
withoutTargetLibc = true;
langCC = false;
libcCross = libcCross1;
targetPackages.stdenv.cc.bintools = binutilsNoLibc;
enableShared =
stdenv.targetPlatform.hasSharedLibraries
# temporarily disabled due to breakage;
# see https://github.com/NixOS/nixpkgs/pull/243249
&& !stdenv.targetPlatform.isWindows
&& !(stdenv.targetPlatform.useLLVM or false);
};
bintools = binutilsNoLibc;
libc = libcCross1;
extraPackages = [ ];
2024-05-02 00:46:19 +00:00
};
inherit (callPackage ./all.nix { inherit noSysDirs; })
2024-06-30 08:16:52 +00:00
gcc48
gcc49
gcc6
gcc7
gcc8
gcc9
gcc10
gcc11
gcc12
gcc13
;
2024-05-02 00:46:19 +00:00
gcc_latest = gcc13;
libgcc = stdenv.cc.cc.libgcc or null;
# This is for e.g. LLVM libraries on linux.
gccForLibs =
2024-06-30 08:16:52 +00:00
if
stdenv.targetPlatform == stdenv.hostPlatform && targetPackages.stdenv.cc.isGNU
2024-05-02 00:46:19 +00:00
# Can only do this is in the native case, otherwise we might get infinite
# recursion if `targetPackages.stdenv.cc.cc` itself uses `gccForLibs`.
2024-06-30 08:16:52 +00:00
then
targetPackages.stdenv.cc.cc
else
gcc.cc;
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
wrapNonDeterministicGcc =
stdenv: ccWrapper:
2024-05-02 00:46:19 +00:00
if ccWrapper.isGNU then
2024-06-30 08:16:52 +00:00
ccWrapper.overrideAttrs (old: {
env = old.env // {
cc = old.env.cc.override {
reproducibleBuild = false;
profiledCompiler = with stdenv; (!isDarwin && hostPlatform.isx86);
2024-05-02 00:46:19 +00:00
};
2024-06-30 08:16:52 +00:00
};
})
else
ccWrapper;
2024-05-02 00:46:19 +00:00
# Use the same GCC version as the one from stdenv by default
2024-06-30 08:16:52 +00:00
gfortran = wrapCC (
gcc.cc.override {
name = "gfortran";
langFortran = true;
langCC = false;
langC = false;
profiledCompiler = false;
}
);
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
gfortran48 = wrapCC (
gcc48.cc.override {
name = "gfortran";
langFortran = true;
langCC = false;
langC = false;
profiledCompiler = false;
}
);
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
gfortran49 = wrapCC (
gcc49.cc.override {
name = "gfortran";
langFortran = true;
langCC = false;
langC = false;
profiledCompiler = false;
}
);
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
gfortran6 = wrapCC (
gcc6.cc.override {
name = "gfortran";
langFortran = true;
langCC = false;
langC = false;
profiledCompiler = false;
}
);
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
gfortran7 = wrapCC (
gcc7.cc.override {
name = "gfortran";
langFortran = true;
langCC = false;
langC = false;
profiledCompiler = false;
}
);
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
gfortran8 = wrapCC (
gcc8.cc.override {
name = "gfortran";
langFortran = true;
langCC = false;
langC = false;
profiledCompiler = false;
}
);
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
gfortran9 = wrapCC (
gcc9.cc.override {
name = "gfortran";
langFortran = true;
langCC = false;
langC = false;
profiledCompiler = false;
}
);
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
gfortran10 = wrapCC (
gcc10.cc.override {
name = "gfortran";
langFortran = true;
langCC = false;
langC = false;
profiledCompiler = false;
}
);
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
gfortran11 = wrapCC (
gcc11.cc.override {
name = "gfortran";
langFortran = true;
langCC = false;
langC = false;
profiledCompiler = false;
}
);
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
gfortran12 = wrapCC (
gcc12.cc.override {
name = "gfortran";
langFortran = true;
langCC = false;
langC = false;
profiledCompiler = false;
}
);
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
gfortran13 = wrapCC (
gcc13.cc.override {
name = "gfortran";
langFortran = true;
langCC = false;
langC = false;
profiledCompiler = false;
}
);
2024-05-02 00:46:19 +00:00
libgccjit = gcc.cc.override {
name = "libgccjit";
langFortran = false;
langCC = false;
langC = false;
profiledCompiler = false;
langJit = true;
enableLTO = false;
};
gcj = gcj6;
2024-06-30 08:16:52 +00:00
gcj6 = wrapCC (
gcc6.cc.override {
name = "gcj";
langJava = true;
langFortran = false;
langCC = false;
langC = false;
profiledCompiler = false;
inherit
zip
unzip
zlib
boehmgc
gettext
pkg-config
perl
;
inherit (gnome2) libart_lgpl;
}
);
2024-05-02 00:46:19 +00:00
gnat = gnat12; # When changing this, update also gnatPackages
2024-06-30 08:16:52 +00:00
gnat11 = wrapCC (
gcc11.cc.override {
name = "gnat";
langC = true;
langCC = false;
langAda = true;
profiledCompiler = false;
# As per upstream instructions building a cross compiler
# should be done with a (native) compiler of the same version.
# If we are cross-compiling GNAT, we may as well do the same.
gnat-bootstrap =
if stdenv.hostPlatform == stdenv.targetPlatform && stdenv.buildPlatform == stdenv.hostPlatform then
buildPackages.gnat-bootstrap11
else
buildPackages.gnat11;
}
);
gnat12 = wrapCC (
gcc12.cc.override {
name = "gnat";
langC = true;
langCC = false;
langAda = true;
profiledCompiler = false;
# As per upstream instructions building a cross compiler
# should be done with a (native) compiler of the same version.
# If we are cross-compiling GNAT, we may as well do the same.
gnat-bootstrap =
if stdenv.hostPlatform == stdenv.targetPlatform && stdenv.buildPlatform == stdenv.hostPlatform then
buildPackages.gnat-bootstrap12
else
buildPackages.gnat12;
stdenv =
if
stdenv.hostPlatform == stdenv.targetPlatform
&& stdenv.buildPlatform == stdenv.hostPlatform
&& stdenv.buildPlatform.isDarwin
&& stdenv.buildPlatform.isx86_64
then
overrideCC stdenv gnat-bootstrap12
else
stdenv;
}
);
gnat13 = wrapCC (
gcc13.cc.override {
name = "gnat";
langC = true;
langCC = false;
langAda = true;
profiledCompiler = false;
# As per upstream instructions building a cross compiler
# should be done with a (native) compiler of the same version.
# If we are cross-compiling GNAT, we may as well do the same.
gnat-bootstrap =
if stdenv.hostPlatform == stdenv.targetPlatform && stdenv.buildPlatform == stdenv.hostPlatform then
buildPackages.gnat-bootstrap12
else
buildPackages.gnat13;
stdenv =
if
stdenv.hostPlatform == stdenv.targetPlatform
&& stdenv.buildPlatform == stdenv.hostPlatform
&& stdenv.buildPlatform.isDarwin
&& stdenv.buildPlatform.isx86_64
then
overrideCC stdenv gnat-bootstrap12
else
stdenv;
}
);
2024-05-02 00:46:19 +00:00
gnat-bootstrap = gnat-bootstrap12;
2024-06-30 08:16:52 +00:00
gnat-bootstrap11 = wrapCC (
callPackage ../development/compilers/gnat-bootstrap { majorVersion = "11"; }
);
gnat-bootstrap12 = wrapCCWith (
{
cc = callPackage ../development/compilers/gnat-bootstrap { majorVersion = "12"; };
}
// lib.optionalAttrs (stdenv.hostPlatform.isDarwin) { bintools = bintoolsDualAs; }
);
2024-05-02 00:46:19 +00:00
gnat12Packages = recurseIntoAttrs (callPackage ./ada-packages.nix { gnat = buildPackages.gnat12; });
gnat13Packages = recurseIntoAttrs (callPackage ./ada-packages.nix { gnat = buildPackages.gnat13; });
gnatPackages = gnat12Packages;
2024-06-30 08:16:52 +00:00
inherit (gnatPackages) gprbuild gnatprove;
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
gccgo = wrapCC (
gcc.cc.override {
2024-05-02 00:46:19 +00:00
name = "gccgo";
2024-06-30 08:16:52 +00:00
langCC = true; # required for go.
2024-05-02 00:46:19 +00:00
langC = true;
langGo = true;
langJit = true;
profiledCompiler = false;
2024-06-30 08:16:52 +00:00
}
// {
# not supported on darwin: https://github.com/golang/go/issues/463
meta.broken = stdenv.hostPlatform.isDarwin;
}
);
gccgo12 = wrapCC (
gcc12.cc.override {
2024-05-02 00:46:19 +00:00
name = "gccgo";
2024-06-30 08:16:52 +00:00
langCC = true; # required for go.
2024-05-02 00:46:19 +00:00
langC = true;
langGo = true;
langJit = true;
profiledCompiler = false;
2024-06-30 08:16:52 +00:00
}
// {
# not supported on darwin: https://github.com/golang/go/issues/463
meta.broken = stdenv.hostPlatform.isDarwin;
}
);
gccgo13 = wrapCC (
gcc13.cc.override {
2024-05-02 00:46:19 +00:00
name = "gccgo";
2024-06-30 08:16:52 +00:00
langCC = true; # required for go.
2024-05-02 00:46:19 +00:00
langC = true;
langGo = true;
langJit = true;
profiledCompiler = false;
2024-06-30 08:16:52 +00:00
}
// {
# not supported on darwin: https://github.com/golang/go/issues/463
meta.broken = stdenv.hostPlatform.isDarwin;
}
);
2024-05-02 00:46:19 +00:00
# It would be better to match the default gcc so that there are no linking errors
# when using C/C++ libraries in D packages, but right now versions >= 12 are broken.
gdc = gdc11;
2024-06-30 08:16:52 +00:00
gdc11 = wrapCC (
gcc11.cc.override {
name = "gdc";
langCC = false;
langC = false;
langD = true;
profiledCompiler = false;
}
);
2024-05-02 00:46:19 +00:00
}