push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
{
lib,
fetchurl ? null,
fetchgit ? null,
release_version ? null,
gitRelease ? null,
officialRelease ? null,
monorepoSrc' ? null,
version ? null,
}@args:
rec {
gcc_meta = {
license = with lib.licenses; [ gpl3Plus ];
teams = [ lib.teams.gcc ];
};
releaseInfo =
if gitRelease != null then
rec {
original = gitRelease;
release_version = args.version or original.version;
version = gitRelease.rev-version;
}
else
rec {
original = officialRelease;
release_version = args.version or original.version;
version =
if original ? candidate then "${release_version}-${original.candidate}" else release_version;
};
monorepoSrc =
if monorepoSrc' != null then
monorepoSrc'
else if gitRelease != null then
fetchgit {
url = "https://gcc.gnu.org/git/gcc.git";
inherit (gitRelease) rev;
hash = releaseInfo.original.sha256;
}
else
fetchurl {
url = "mirror://gcc/releases/gcc-${releaseInfo.version}/gcc-${releaseInfo.version}.tar.xz";
hash = releaseInfo.original.sha256;
};
}

View File

@@ -0,0 +1,235 @@
{
lib,
newScope,
stdenv,
overrideCC,
fetchgit,
fetchurl,
gitRelease ? null,
officialRelease ? null,
monorepoSrc ? null,
version ? null,
patchesFn ? lib.id,
wrapCCWith,
binutilsNoLibc,
binutils,
buildGccPackages,
targetGccPackages,
makeScopeWithSplicing',
otherSplices,
...
}@args:
assert lib.assertMsg (lib.xor (gitRelease != null) (officialRelease != null)) (
"must specify `gitRelease` or `officialRelease`"
+ (lib.optionalString (gitRelease != null) " not both")
);
let
monorepoSrc' = monorepoSrc;
metadata = rec {
inherit
(import ./common-let.nix {
inherit (args)
lib
gitRelease
officialRelease
version
;
})
releaseInfo
;
inherit (releaseInfo) release_version version;
inherit
(import ./common-let.nix {
inherit
lib
fetchgit
fetchurl
release_version
gitRelease
officialRelease
monorepoSrc'
version
;
})
gcc_meta
monorepoSrc
;
src = monorepoSrc;
versionDir =
(toString ../.) + "/${if (gitRelease != null) then "git" else lib.versions.major release_version}";
getVersionFile =
p:
builtins.path {
name = baseNameOf p;
path =
let
patches = args.patchesFn (import ./patches.nix);
constraints = patches."${p}" or null;
matchConstraint =
{
before ? null,
after ? null,
path,
}:
let
check = fn: value: if value == null then true else fn release_version value;
matchBefore = check lib.versionOlder before;
matchAfter = check lib.versionAtLeast after;
in
matchBefore && matchAfter;
patchDir =
toString
(
if constraints == null then
{ path = metadata.versionDir; }
else
(lib.findFirst matchConstraint { path = metadata.versionDir; } constraints)
).path;
in
"${patchDir}/${p}";
};
};
in
makeScopeWithSplicing' {
inherit otherSplices;
f =
gccPackages:
let
callPackage = gccPackages.newScope (args // metadata);
in
{
stdenv = overrideCC stdenv gccPackages.gcc;
gcc-unwrapped = callPackage ./gcc {
bintools = binutils;
};
libbacktrace = callPackage ./libbacktrace { };
libiberty = callPackage ./libiberty { };
libsanitizer = callPackage ./libsanitizer { };
libquadmath = callPackage ./libquadmath { };
gfortran-unwrapped = gccPackages.gcc-unwrapped.override {
stdenv = overrideCC stdenv buildGccPackages.gcc;
langFortran = true;
};
gfortran = wrapCCWith {
cc = gccPackages.gfortran-unwrapped;
libcxx = targetGccPackages.libstdcxx;
bintools = binutils;
extraPackages = [
targetGccPackages.libgcc
];
nixSupport.cc-cflags = [
"-B${targetGccPackages.libgcc}/lib"
"-B${targetGccPackages.libssp}/lib"
"-B${targetGccPackages.libatomic}/lib"
"-B${targetGccPackages.libgfortran}/lib/"
];
};
gfortranNoLibgfortran = wrapCCWith {
cc = gccPackages.gfortran-unwrapped;
libcxx = targetGccPackages.libstdcxx;
bintools = binutils;
extraPackages = [
targetGccPackages.libgcc
];
nixSupport.cc-cflags = [
"-B${targetGccPackages.libgcc}/lib"
"-B${targetGccPackages.libssp}/lib"
"-B${targetGccPackages.libatomic}/lib"
];
};
gcc = wrapCCWith {
cc = gccPackages.gcc-unwrapped;
libcxx = targetGccPackages.libstdcxx;
bintools = binutils;
extraPackages = [
targetGccPackages.libgcc
];
nixSupport.cc-cflags = [
"-B${targetGccPackages.libgcc}/lib"
"-B${targetGccPackages.libssp}/lib"
"-B${targetGccPackages.libatomic}/lib"
];
};
gccNoLibgcc = wrapCCWith {
cc = gccPackages.gcc-unwrapped;
libcxx = null;
bintools = binutilsNoLibc;
extraPackages = [ ];
nixSupport.cc-cflags = [
"-nostartfiles"
];
};
libgcc = callPackage ./libgcc {
stdenv = overrideCC stdenv buildGccPackages.gccNoLibgcc;
};
gccWithLibc = wrapCCWith {
cc = gccPackages.gcc-unwrapped;
libcxx = null;
bintools = binutils;
extraPackages = [
targetGccPackages.libgcc
];
nixSupport.cc-cflags = [
"-B${targetGccPackages.libgcc}/lib"
];
};
libssp = callPackage ./libssp {
stdenv = overrideCC stdenv buildGccPackages.gccWithLibc;
};
gccWithLibssp = wrapCCWith {
cc = gccPackages.gcc-unwrapped;
libcxx = null;
bintools = binutils;
extraPackages = [
targetGccPackages.libgcc
];
nixSupport.cc-cflags = [
"-B${targetGccPackages.libgcc}/lib"
"-B${targetGccPackages.libssp}/lib"
];
};
libatomic = callPackage ./libatomic {
stdenv = overrideCC stdenv buildGccPackages.gccWithLibssp;
};
gccWithLibatomic = wrapCCWith {
cc = gccPackages.gcc-unwrapped;
libcxx = null;
bintools = binutils;
extraPackages = [
targetGccPackages.libgcc
];
nixSupport.cc-cflags = [
"-B${targetGccPackages.libgcc}/lib"
"-B${targetGccPackages.libssp}/lib"
"-B${targetGccPackages.libatomic}/lib"
];
};
libgfortran = callPackage ./libgfortran {
stdenv = overrideCC stdenv buildGccPackages.gcc;
gfortran = buildGccPackages.gfortranNoLibgfortran;
};
libstdcxx = callPackage ./libstdcxx {
stdenv = overrideCC stdenv buildGccPackages.gccWithLibatomic;
};
};
}

View File

@@ -0,0 +1,256 @@
{
lib,
stdenv,
gcc_meta,
release_version,
version,
monorepoSrc ? null,
fetchpatch,
langAda ? false,
langC ? true,
langCC ? true,
langFortran ? false,
langGo ? false,
langJava ? false,
langObjC ? stdenv.targetPlatform.isDarwin,
langObjCpp ? stdenv.targetPlatform.isDarwin,
langJit ? false,
enablePlugin ? lib.systems.equals stdenv.hostPlatform stdenv.buildPlatform,
runCommand,
buildPackages,
isl,
zlib,
gmp,
libmpc,
mpfr,
perl,
texinfo,
which,
gettext,
getVersionFile,
buildGccPackages,
targetPackages,
libc,
bintools,
}:
let
inherit (stdenv) targetPlatform hostPlatform;
targetPrefix = lib.optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
in
stdenv.mkDerivation (finalAttrs: {
pname = "${targetPrefix}${if langFortran then "gfortran" else "gcc"}";
inherit version;
src = monorepoSrc;
outputs = [
"out"
"man"
"info"
];
patches = [
(fetchpatch {
name = "for_each_path-functional-programming.patch";
url = "https://github.com/gcc-mirror/gcc/commit/f23bac62f46fc296a4d0526ef54824d406c3756c.diff";
hash = "sha256-J7SrypmVSbvYUzxWWvK2EwEbRsfGGLg4vNZuLEe6Xe0=";
})
(fetchpatch {
name = "find_a_program-separate-from-find_a_file.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250822234120.1988059-1-git@JohnEricson.me/raw";
hash = "sha256-0gaWaeFZq+a8q7Bcr3eILNjHh1LfzL/Lz4F+W+H6XIU=";
})
(fetchpatch {
name = "simplify-find_a_program-and-find_a_file.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250822234120.1988059-2-git@JohnEricson.me/raw";
hash = "sha256-ojdyszxLGL+njHK4eAaeBkxAhFTDI57j6lGuAf0A+N0=";
})
(fetchpatch {
name = "for_each_path-pass-machine-specific.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250822234120.1988059-3-git@JohnEricson.me/raw";
hash = "sha256-C5jUSyNchmZcE8RTXc2dHfCqNKuBHeiouLruK9UooSM=";
})
(fetchpatch {
name = "find_a_program-search-with-machine-prefix.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250822234120.1988059-4-git@JohnEricson.me/raw";
hash = "sha256-MwcO4OXPlcdaSYivsh5ru+Cfq6qybeAtgCgTEPGYg40=";
})
(getVersionFile "gcc/fix-collect2-paths.diff")
];
enableParallelBuilding = true;
hardeningDisable = [
"format" # Some macro-indirect formatting in e.g. libcpp
];
strictDeps = true;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [
texinfo
which
gettext
]
++ lib.optional (perl != null) perl;
buildInputs = [
gmp
libmpc
mpfr
]
++ lib.optional (isl != null) isl
++ lib.optional (zlib != null) zlib;
postUnpack = ''
mkdir -p ./build
buildRoot=$(readlink -e "./build")
'';
postPatch = ''
configureScripts=$(find . -name configure)
for configureScript in $configureScripts; do
patchShebangs $configureScript
done
patchShebangs libbacktrace/install-debuginfo-for-buildid.sh
patchShebangs runtest
''
# This should kill all the stdinc frameworks that gcc and friends like to
# insert into default search paths.
+ lib.optionalString hostPlatform.isDarwin ''
substituteInPlace gcc/config/darwin-c.c \
--replace 'if (stdinc)' 'if (0)'
'';
preConfigure =
# Don't built target libraries, because we want to build separately
''
substituteInPlace configure \
--replace 'noconfigdirs=""' 'noconfigdirs="$noconfigdirs $target_libraries"'
''
# HACK: if host and target config are the same, but the platforms are
# actually different we need to convince the configure script that it
# is in fact building a cross compiler although it doesn't believe it.
+
lib.optionalString (targetPlatform.config == hostPlatform.config && targetPlatform != hostPlatform)
''
substituteInPlace configure --replace is_cross_compiler=no is_cross_compiler=yes
''
# Cannot configure from src dir
+ ''
cd "$buildRoot"
mkdir -p "$buildRoot/libbacktrace/.libs"
cp ${buildGccPackages.libbacktrace}/lib/libbacktrace.a "$buildRoot/libbacktrace/.libs/libbacktrace.a"
cp -r ${buildGccPackages.libbacktrace}/lib/*.la "$buildRoot/libbacktrace"
cp -r ${buildGccPackages.libbacktrace.dev}/include/*.h "$buildRoot/libbacktrace"
mkdir -p "$buildRoot/libiberty/pic"
cp ${buildGccPackages.libiberty}/lib/libiberty.a "$buildRoot/libiberty"
cp ${buildGccPackages.libiberty}/lib/libiberty_pic.a "$buildRoot/libiberty/pic/libiberty.a"
touch "$buildRoot/libiberty/stamp-noasandir"
touch "$buildRoot/libiberty/stamp-h"
touch "$buildRoot/libiberty/stamp-picdir"
mkdir -p "$buildRoot/build-${stdenv.hostPlatform.config}"
cp -r "$buildRoot/libiberty" "$buildRoot/build-${stdenv.hostPlatform.config}/libiberty"
configureScript=../$sourceRoot/configure
'';
# Don't store the configure flags in the resulting executables.
postConfigure = ''
sed -e '/TOPLEVEL_CONFIGURE_ARGUMENTS=/d' -i Makefile
'';
dontDisableStatic = true;
configurePlatforms = [
"build"
"host"
"target"
];
configureFlags = [
# Force target prefix. The behavior if `--target` and `--host` are
# specified is inconsistent: Sometimes specifying `--target` always causes
# a prefix to be generated, sometimes it's only added if the `--host` and
# `--target` differ. This means that sometimes there may be a prefix even
# though nixpkgs doesn't expect one and sometimes there may be none even
# though nixpkgs expects one (since not all information is serialized into
# the config attribute). The easiest way out of these problems is to always
# set the program prefix, so gcc will conform to our expectations.
"--program-prefix=${targetPrefix}"
"--disable-dependency-tracking"
"--enable-fast-install"
"--disable-serial-configure"
"--disable-bootstrap"
"--disable-decimal-float"
"--disable-install-libiberty"
"--disable-multilib"
"--disable-nls"
"--disable-shared"
"--enable-default-pie"
"--enable-languages=${
lib.concatStrings (
lib.intersperse "," (
lib.optional langC "c"
++ lib.optional langCC "c++"
++ lib.optional langFortran "fortran"
++ lib.optional langJava "java"
++ lib.optional langAda "ada"
++ lib.optional langGo "go"
++ lib.optional langObjC "objc"
++ lib.optional langObjCpp "obj-c++"
++ lib.optional langJit "jit"
)
)
}"
(lib.withFeature (isl != null) "isl")
"--without-headers"
"--with-gnu-as"
"--with-gnu-ld"
"--with-as=${lib.getExe' bintools "${bintools.targetPrefix}as"}"
"--with-system-zlib"
"--without-included-gettext"
"--enable-linker-build-id"
"--with-sysroot=${lib.getDev (targetPackages.libc or libc)}"
"--with-native-system-header-dir=/include"
]
++ lib.optionals enablePlugin [
"--enable-plugin"
"--enable-plugins"
]
++
# Only pass when the arch supports it.
# Exclude RISC-V because GCC likes to fail when the string is empty on RISC-V.
lib.optionals (targetPlatform.isAarch || targetPlatform.isAvr || targetPlatform.isx86_64) [
"--with-multilib-list="
];
doCheck = false;
postInstall = ''
moveToOutput "lib/gcc/${targetPlatform.config}/${version}/plugin/include" "''${!outputDev}"
'';
passthru = {
inherit
langC
langCC
langObjC
langObjCpp
langAda
langFortran
langGo
;
isGNU = true;
};
meta = gcc_meta // {
homepage = "https://gcc.gnu.org/";
};
})

View File

@@ -0,0 +1,94 @@
{
lib,
stdenv,
gcc_meta,
release_version,
version,
getVersionFile,
monorepoSrc ? null,
fetchpatch,
autoreconfHook269,
runCommand,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libatomic";
inherit version;
src = runCommand "libatomic-src-${version}" { src = monorepoSrc; } ''
runPhase unpackPhase
mkdir -p "$out/gcc"
cp gcc/BASE-VER "$out/gcc"
cp gcc/DATESTAMP "$out/gcc"
cp -r libatomic "$out"
cp -r config "$out"
cp -r multilib.am "$out"
cp -r libtool.m4 "$out"
cp config.guess "$out"
cp config.rpath "$out"
cp config.sub "$out"
cp config-ml.in "$out"
cp ltmain.sh "$out"
cp install-sh "$out"
cp mkinstalldirs "$out"
[[ -f MD5SUMS ]]; cp MD5SUMS "$out"
'';
patches = [
(fetchpatch {
name = "custom-threading-model.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250716204545.1063669-1-git@JohnEricson.me/raw";
hash = "sha256-kxNntY2r4i/+XHQSpf9bYV2Jg+FD/pD5TiMn5hd4ckk=";
includes = [
"config/*"
"libatomic/*"
];
})
];
postUnpack = ''
mkdir -p ./build
buildRoot=$(readlink -e "./build")
'';
preAutoreconf = ''
sourceRoot=$(readlink -e "./libatomic")
cd $sourceRoot
'';
enableParallelBuilding = true;
nativeBuildInputs = [
autoreconfHook269
];
configurePlatforms = [
"build"
"host"
];
configureFlags = [
"--disable-dependency-tracking"
"cross_compiling=true"
"--disable-multilib"
];
preConfigure = ''
cd "$buildRoot"
configureScript=$sourceRoot/configure
'';
doCheck = true;
passthru = {
isGNU = true;
};
meta = gcc_meta // {
homepage = "https://gcc.gnu.org/";
};
})

View File

@@ -0,0 +1,74 @@
{
lib,
stdenv,
gcc_meta,
release_version,
version,
monorepoSrc ? null,
runCommand,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libbacktrace";
inherit version;
src = runCommand "libbacktrace-src-${version}" { src = monorepoSrc; } ''
runPhase unpackPhase
mkdir -p "$out/gcc"
cp gcc/BASE-VER "$out/gcc"
cp gcc/DATESTAMP "$out/gcc"
cp -r include "$out"
cp -r libbacktrace "$out"
cp config.guess "$out"
cp config.rpath "$out"
cp config.sub "$out"
cp config-ml.in "$out"
cp ltmain.sh "$out"
cp install-sh "$out"
cp move-if-change "$out"
cp mkinstalldirs "$out"
cp test-driver "$out"
[[ -f MD5SUMS ]]; cp MD5SUMS "$out"
'';
outputs = [
"out"
"dev"
];
enableParallelBuilding = true;
sourceRoot = "${finalAttrs.src.name}/libbacktrace";
preConfigure = ''
mkdir ../../build
cd ../../build
configureScript=../$sourceRoot/configure
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/lib"
cp .libs/*.a "$out/lib"
cp libbacktrace*.la "$out/lib"
mkdir -p "$dev/include"
cp backtrace-supported.h "$dev/include"
runHook postInstall
'';
doCheck = true;
passthru = {
isGNU = true;
};
meta = gcc_meta // {
homepage = "https://gcc.gnu.org/";
};
})

View File

@@ -0,0 +1,224 @@
{
lib,
stdenv,
gcc_meta,
release_version,
version,
getVersionFile,
monorepoSrc ? null,
fetchpatch,
autoreconfHook269,
buildGccPackages,
buildPackages,
which,
python3,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libgcc";
inherit version;
src = monorepoSrc;
outputs = [
"out"
"dev"
];
strictDeps = true;
depsBuildBuild = [
buildPackages.stdenv.cc
buildGccPackages.libiberty
];
nativeBuildInputs = [
autoreconfHook269
which
python3
];
patches = [
(fetchpatch {
name = "delete-MACHMODE_H.patch";
url = "https://github.com/gcc-mirror/gcc/commit/493aae4b034d62054d5e7e54dc06cd9a8be54e29.diff";
hash = "sha256-oEk0lnI96RlpALWpb7J+GnrtgQsFVqDO57I/zjiqqTk=";
})
(fetchpatch {
name = "custom-threading-model.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250716204545.1063669-1-git@JohnEricson.me/raw";
hash = "sha256-NgiC4cFeFInXXg27me1XpSeImPaL0WHs50Tf1YHz4ps=";
})
(fetchpatch {
name = "libgcc.mvars-less-0.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250716234028.1153560-1-John.Ericson@Obsidian.Systems/raw";
hash = "sha256-NEcieDCsy+7IRU3qQKVD3i57OuwGZKB/rmNF8X2I1n0=";
})
(fetchpatch {
name = "libgcc.mvars-less-1.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250716234028.1153560-2-John.Ericson@Obsidian.Systems/raw";
hash = "sha256-nfRC4f6m3kHDro4+6E4y1ZPs+prxBQmn0H2rzIjaMWM=";
})
(fetchpatch {
name = "regular-libdir-includedir.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250717174911.1536129-1-git@JohnEricson.me/raw";
hash = "sha256-Cn7rvg1FI7H/26GzSe4pv5VW/gvwbwGqivAqEeawkwk=";
})
(getVersionFile "libgcc/force-regular-dirs.patch")
];
autoreconfFlags = "--install --force --verbose . libgcc";
postUnpack = ''
mkdir -p ./build
buildRoot=$(readlink -e "./build")
'';
postPatch = ''
sourceRoot=$(readlink -e "./libgcc")
'';
enableParallelBuilding = true;
preConfigure = ''
cd "$buildRoot"
mkdir -p build-${stdenv.buildPlatform.config}/libiberty/
cd build-${stdenv.buildPlatform.config}/libiberty/
ln -s ${buildGccPackages.libiberty}/lib/libiberty.a ./
mkdir -p "$buildRoot/gcc"
cd "$buildRoot/gcc"
(
export AS_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$(basename $AS_FOR_BUILD)"}
export CC_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$(basename $CC_FOR_BUILD)"}
export CPP_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$(basename $CPP_FOR_BUILD)"}
export CXX_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$(basename $CXX_FOR_BUILD)"}
export LD_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc.bintools "$(basename $LD_FOR_BUILD)"}
export AS=$AS_FOR_BUILD
export CC=$CC_FOR_BUILD
export CPP=$CPP_FOR_BUILD
export CXX=$CXX_FOR_BUILD
export LD=$LD_FOR_BUILD
export AS_FOR_TARGET=${lib.getExe' stdenv.cc "$(basename $AS)"}
export CC_FOR_TARGET=${lib.getExe' stdenv.cc "$(basename $CC)"}
export CPP_FOR_TARGET=${lib.getExe' stdenv.cc "$(basename $CPP)"}
export LD_FOR_TARGET=${lib.getExe' stdenv.cc.bintools "$(basename $LD)"}
export NIX_CFLAGS_COMPILE_FOR_BUILD+=' -DGENERATOR_FILE=1'
"$sourceRoot/../gcc/configure" $topLevelConfigureFlags
sed -e 's,libgcc.mvars:.*$,libgcc.mvars:,' -i Makefile
make \
config.h \
libgcc.mvars \
tconfig.h \
tm.h \
options.h \
insn-constants.h \
version.h
)
mkdir -p "$buildRoot/gcc/include"
mkdir -p "$buildRoot/gcc/${stdenv.hostPlatform.config}/libgcc"
cd "$buildRoot/gcc/${stdenv.hostPlatform.config}/libgcc"
configureScript=$sourceRoot/configure
chmod +x "$configureScript"
export AS_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$(basename $AS_FOR_BUILD)"}
export CC_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$(basename $CC_FOR_BUILD)"}
export CPP_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$(basename $CPP_FOR_BUILD)"}
export CXX_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$(basename $CXX_FOR_BUILD)"}
export LD_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc.bintools "$(basename $LD_FOR_BUILD)"}
export AS=${lib.getExe' stdenv.cc "$(basename $AS)"}
export CC=${lib.getExe' stdenv.cc "$(basename $CC)"}
export CPP=${lib.getExe' stdenv.cc "$(basename $CPP)"}
export CXX=${lib.getExe' stdenv.cc "$(basename $CXX)"}
export LD=${lib.getExe' stdenv.cc.bintools "$(basename $LD)"}
export AS_FOR_TARGET=${lib.getExe' stdenv.cc "$(basename $AS_FOR_TARGET)"}
export CC_FOR_TARGET=${lib.getExe' stdenv.cc "$(basename $CC_FOR_TARGET)"}
export CPP_FOR_TARGET=${lib.getExe' stdenv.cc "$(basename $CPP_FOR_TARGET)"}
export LD_FOR_TARGET=${lib.getExe' stdenv.cc.bintools "$(basename $LD_FOR_TARGET)"}
''
+ lib.optionalString stdenv.hostPlatform.isMusl ''
NIX_CFLAGS_COMPILE_OLD=$NIX_CFLAGS_COMPILE
NIX_CFLAGS_COMPILE+=' -isystem ${stdenv.cc.cc}/lib/gcc/${stdenv.hostPlatform.config}/${version}/include-fixed'
'';
topLevelConfigureFlags = [
"--build=${stdenv.buildPlatform.config}"
"--host=${stdenv.buildPlatform.config}"
"--target=${stdenv.hostPlatform.config}"
"--disable-bootstrap"
"--disable-multilib"
"--enable-languages=c"
"--disable-fixincludes"
"--disable-intl"
"--disable-lto"
"--disable-libatomic"
"--disable-libbacktrace"
"--disable-libcpp"
"--disable-libssp"
"--disable-libquadmath"
"--disable-libgomp"
"--disable-libvtv"
"--disable-vtable-verify"
"--with-system-zlib"
]
++
lib.optional (!stdenv.hostPlatform.isRiscV)
# RISC-V does not like it being empty
"--with-multilib-list="
++
lib.optional (stdenv.hostPlatform.libc == "glibc")
# Cheat and use previous stage's glibc to avoid infinite recursion. As
# of GCC 11, libgcc only cares if the version is greater than 2.19,
# which is quite ancient, so this little lie should be fine.
"--with-glibc-version=${buildPackages.glibc.version}";
configurePlatforms = [
"build"
"host"
];
configureFlags = [
"--disable-dependency-tracking"
"gcc_cv_target_thread_file=single"
# $CC cannot link binaries, let alone run then
"cross_compiling=true"
# Do not have dynamic linker without libc
"--enable-static"
"--disable-shared"
];
# Set the variable back the way it was, see corresponding code in
# `preConfigure`.
postConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
NIX_CFLAGS_COMPILE=$NIX_CFLAGS_COMPILE_OLD
'';
makeFlags = [ "MULTIBUILDTOP:=../" ];
postInstall = ''
install -c -m 644 gthr-default.h "$dev/include"
'';
doCheck = true;
passthru = {
isGNU = true;
};
meta = gcc_meta // {
homepage = "https://gcc.gnu.org/";
};
})

View File

@@ -0,0 +1,188 @@
{
lib,
stdenv,
gfortran,
gcc_meta,
release_version,
version,
getVersionFile,
monorepoSrc ? null,
autoreconfHook269,
libiberty,
buildPackages,
libgcc,
libbacktrace,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libgfortran";
inherit version;
src = monorepoSrc;
outputs = [
"out"
"dev"
];
strictDeps = true;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [
autoreconfHook269
libiberty
gfortran
];
patches = [
(getVersionFile "libgfortran/force-regular-dirs.patch")
];
autoreconfFlags = "--install --force --verbose . libgfortran";
postUnpack = ''
mkdir -p ./build
buildRoot=$(readlink -e "./build")
'';
postPatch = ''
sourceRoot=$(readlink -e "./libgfortran")
'';
enableParallelBuilding = true;
preConfigure = ''
cd "$buildRoot"
mkdir -p build-${stdenv.buildPlatform.config}/libiberty/
cd build-${stdenv.buildPlatform.config}/libiberty/
ln -s ${libiberty}/lib/libiberty.a ./
mkdir -p "$buildRoot/gcc"
cd "$buildRoot/gcc"
(
export AS_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$AS_FOR_BUILD"}
export CC_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$CC_FOR_BUILD"}
export CPP_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$CPP_FOR_BUILD"}
export CXX_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$CXX_FOR_BUILD"}
export LD_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc.bintools "$LD_FOR_BUILD"}
export AS=$AS_FOR_BUILD
export CC=$CC_FOR_BUILD
export CPP=$CPP_FOR_BUILD
export CXX=$CXX_FOR_BUILD
export LD=$LD_FOR_BUILD
export AS_FOR_TARGET=${lib.getExe' stdenv.cc "$AS"}
export CC_FOR_TARGET=${lib.getExe' stdenv.cc "$CC"}
export CPP_FOR_TARGET=${lib.getExe' stdenv.cc "$CPP"}
export LD_FOR_TARGET=${lib.getExe' stdenv.cc.bintools "$LD"}
export NIX_CFLAGS_COMPILE_FOR_BUILD+=' -DGENERATOR_FILE=1'
"$sourceRoot/../gcc/configure" $topLevelConfigureFlags
make \
config.h
)
mkdir -p "$buildRoot/gcc/include"
mkdir -p "$buildRoot/gcc/libbacktrace/.libs"
cp ${libbacktrace}/lib/libbacktrace.a "$buildRoot/gcc/libbacktrace/.libs/libbacktrace.a"
cp -r ${libbacktrace}/lib/*.la "$buildRoot/gcc/libbacktrace"
cp -r ${libbacktrace.dev}/include/*.h "$buildRoot/gcc/libbacktrace"
mkdir -p "$buildRoot/gcc/libgcc"
ln -s "${libgcc.dev}/include/gthr-default.h" "$buildRoot/gcc/libgcc"
mkdir -p "$buildRoot/gcc/${stdenv.hostPlatform.config}/libgfortran"
ln -s "$buildRoot/gcc/libbacktrace" "$buildRoot/gcc/${stdenv.buildPlatform.config}/libbacktrace"
ln -s "$buildRoot/gcc/libgcc" "$buildRoot/gcc/${stdenv.buildPlatform.config}/libgcc"
cd "$buildRoot/gcc/${stdenv.hostPlatform.config}/libgfortran"
configureScript=$sourceRoot/configure
chmod +x "$configureScript"
export AS_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$AS_FOR_BUILD"}
export CC_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$CC_FOR_BUILD"}
export CPP_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$CPP_FOR_BUILD"}
export CXX_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc "$CXX_FOR_BUILD"}
export LD_FOR_BUILD=${lib.getExe' buildPackages.stdenv.cc.bintools "$LD_FOR_BUILD"}
export AS=${lib.getExe' stdenv.cc "$AS"}
export CC=${lib.getExe' stdenv.cc "$CC"}
export CPP=${lib.getExe' stdenv.cc "$CPP"}
export CXX=${lib.getExe' stdenv.cc "$CXX"}
export LD=${lib.getExe' stdenv.cc.bintools "$LD"}
export AS_FOR_TARGET=${lib.getExe' stdenv.cc "$AS_FOR_TARGET"}
export CC_FOR_TARGET=${lib.getExe' stdenv.cc "$CC_FOR_TARGET"}
export CPP_FOR_TARGET=${lib.getExe' stdenv.cc "$CPP_FOR_TARGET"}
export LD_FOR_TARGET=${lib.getExe' stdenv.cc.bintools "$LD_FOR_TARGET"}
''
+ lib.optionalString stdenv.hostPlatform.isMusl ''
NIX_CFLAGS_COMPILE_OLD=$NIX_CFLAGS_COMPILE
NIX_CFLAGS_COMPILE+=' -isystem ${stdenv.cc.cc}/lib/gcc/${stdenv.hostPlatform.config}/${version}/include-fixed'
'';
topLevelConfigureFlags = [
"--build=${stdenv.buildPlatform.config}"
"--host=${stdenv.buildPlatform.config}"
"--target=${stdenv.hostPlatform.config}"
"--disable-bootstrap"
"--disable-multilib"
"--with-multilib-list="
"--enable-languages=fortran"
"--disable-fixincludes"
"--disable-intl"
"--disable-lto"
"--disable-libatomic"
"--disable-libbacktrace"
"--disable-libcpp"
"--disable-libssp"
"--disable-libquadmath"
"--disable-libgomp"
"--disable-libvtv"
"--disable-vtable-verify"
"--with-system-zlib"
]
++
lib.optional (stdenv.hostPlatform.libc == "glibc")
# Cheat and use previous stage's glibc to avoid infinite recursion. As
# of GCC 11, libgcc only cares if the version is greater than 2.19,
# which is quite ancient, so this little lie should be fine.
"--with-glibc-version=${buildPackages.glibc.version}";
configurePlatforms = [
"build"
"host"
];
configureFlags = [
"--disable-dependency-tracking"
"gcc_cv_target_thread_file=single"
# $CC cannot link binaries, let alone run then
"cross_compiling=true"
"--with-toolexeclibdir=${placeholder "dev"}/lib"
];
# Set the variable back the way it was, see corresponding code in
# `preConfigure`.
postConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
NIX_CFLAGS_COMPILE=$NIX_CFLAGS_COMPILE_OLD
'';
makeFlags = [ "MULTIBUILDTOP:=../" ];
doCheck = true;
passthru = {
isGNU = true;
};
meta = gcc_meta // {
homepage = "https://gcc.gnu.org/";
};
})

View File

@@ -0,0 +1,68 @@
{
lib,
stdenv,
gcc_meta,
release_version,
version,
monorepoSrc ? null,
runCommand,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libiberty";
inherit version;
src = runCommand "libiberty-src-${version}" { src = monorepoSrc; } ''
runPhase unpackPhase
mkdir -p "$out/gcc"
cp gcc/BASE-VER "$out/gcc"
cp gcc/DATESTAMP "$out/gcc"
cp -r include "$out"
cp -r libiberty "$out"
cp config.guess "$out"
cp config.rpath "$out"
cp config.sub "$out"
cp config-ml.in "$out"
cp ltmain.sh "$out"
cp install-sh "$out"
cp mkinstalldirs "$out"
[[ -f MD5SUMS ]]; cp MD5SUMS "$out"
'';
outputs = [
"out"
"dev"
];
enableParallelBuilding = true;
sourceRoot = "${finalAttrs.src.name}/libiberty";
preConfigure = ''
mkdir ../../build
cd ../../build
configureScript=../$sourceRoot/configure
'';
configureFlags = [
"--enable-install-libiberty"
]
++ lib.optional (!stdenv.hostPlatform.isStatic) "--enable-shared";
postInstall = ''
cp pic/libiberty.a $out/lib/libiberty_pic.a
'';
doCheck = true;
passthru = {
isGNU = true;
};
meta = gcc_meta // {
homepage = "https://gcc.gnu.org/";
};
})

View File

@@ -0,0 +1,51 @@
{
lib,
stdenv,
gcc_meta,
release_version,
version,
monorepoSrc ? null,
runCommand,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libquadmath";
inherit version;
src = runCommand "libquadmath-src-${version}" { src = monorepoSrc; } ''
runPhase unpackPhase
mkdir -p "$out/gcc"
cp gcc/BASE-VER "$out/gcc"
cp gcc/DATESTAMP "$out/gcc"
cp -r libquadmath "$out"
cp config.guess "$out"
cp config.rpath "$out"
cp config.sub "$out"
cp config-ml.in "$out"
cp ltmain.sh "$out"
cp install-sh "$out"
cp mkinstalldirs "$out"
[[ -f MD5SUMS ]]; cp MD5SUMS "$out"
'';
sourceRoot = "${finalAttrs.src.name}/libquadmath";
preConfigure = ''
mkdir ../../build
cd ../../build
configureScript=../$sourceRoot/configure
'';
doCheck = true;
passthru = {
isGNU = true;
};
meta = gcc_meta // {
homepage = "https://gcc.gnu.org/";
};
})

View File

@@ -0,0 +1,57 @@
{
lib,
stdenv,
libstdcxx,
gcc_meta,
release_version,
version,
monorepoSrc ? null,
runCommand,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libsanitizer";
inherit version;
src = runCommand "libsanitizer-src-${version}" { src = monorepoSrc; } ''
runPhase unpackPhase
mkdir -p "$out/gcc"
cp gcc/BASE-VER "$out/gcc"
cp gcc/DATESTAMP "$out/gcc"
cp -r libsanitizer "$out"
cp config.guess "$out"
cp config.rpath "$out"
cp config.sub "$out"
cp config-ml.in "$out"
cp ltmain.sh "$out"
cp install-sh "$out"
cp mkinstalldirs "$out"
[[ -f MD5SUMS ]]; cp MD5SUMS "$out"
'';
sourceRoot = "${finalAttrs.src.name}/libsanitizer";
postUnpack = ''
mkdir -p libstdc++-v3/src/
ln -s ${libstdcxx}/lib/libstdc++.la libstdc++-v3/src/libstdc++.la
'';
preConfigure = ''
mkdir ../../build
cd ../../build
configureScript=../$sourceRoot/configure
'';
doCheck = true;
passthru = {
isGNU = true;
};
meta = gcc_meta // {
homepage = "https://gcc.gnu.org/";
};
})

View File

@@ -0,0 +1,101 @@
{
lib,
stdenv,
gcc_meta,
release_version,
version,
getVersionFile,
monorepoSrc ? null,
fetchpatch,
autoreconfHook269,
runCommand,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libssp";
inherit version;
src = runCommand "libssp-src-${version}" { src = monorepoSrc; } ''
runPhase unpackPhase
mkdir -p "$out/gcc"
cp gcc/BASE-VER "$out/gcc"
cp gcc/DATESTAMP "$out/gcc"
cp -r libssp "$out"
cp -r config "$out"
cp -r multilib.am "$out"
cp config.guess "$out"
cp config.rpath "$out"
cp config.sub "$out"
cp config-ml.in "$out"
cp ltmain.sh "$out"
cp install-sh "$out"
cp mkinstalldirs "$out"
[[ -f MD5SUMS ]]; cp MD5SUMS "$out"
'';
outputs = [
"out"
"dev"
];
patches = [
(fetchpatch {
name = "regular-libdir-includedir.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250720172933.2404828-1-git@JohnEricson.me/raw";
hash = "sha256-W7dcy1Tm3O2reK7kx83DRv8W97qUfaqDbKLiLXIegRw=";
})
(getVersionFile "libssp/force-regular-dirs.patch")
];
postUnpack = ''
mkdir -p ./build
buildRoot=$(readlink -e "./build")
'';
preAutoreconf = ''
sourceRoot=$(readlink -e "./libssp")
cd $sourceRoot
'';
enableParallelBuilding = true;
nativeBuildInputs = [
autoreconfHook269
];
configurePlatforms = [
"build"
"host"
];
configureFlags = [
"--disable-dependency-tracking"
"cross_compiling=true"
"--disable-multilib"
];
preConfigure = ''
cd "$buildRoot"
configureScript=$sourceRoot/configure
'';
hardeningDisable = [
"fortify"
# Because we are building it!
"stackprotector"
];
doCheck = true;
passthru = {
isGNU = true;
};
meta = gcc_meta // {
homepage = "https://gcc.gnu.org/";
};
})

View File

@@ -0,0 +1,127 @@
{
lib,
stdenv,
gcc_meta,
release_version,
version,
getVersionFile,
monorepoSrc ? null,
fetchpatch,
autoreconfHook269,
runCommand,
gettext,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libstdcxx";
inherit version;
src = runCommand "libstdcxx-src-${version}" { src = monorepoSrc; } ''
runPhase unpackPhase
mkdir -p "$out/gcc"
cp gcc/BASE-VER "$out/gcc"
cp gcc/DATESTAMP "$out/gcc"
mkdir -p "$out/libgcc"
cp libgcc/gthr*.h "$out/libgcc"
cp libgcc/unwind-pe.h "$out/libgcc"
cp -r libstdc++-v3 "$out"
cp -r libiberty "$out"
cp -r include "$out"
cp -r contrib "$out"
cp -r config "$out"
cp -r multilib.am "$out"
cp config.guess "$out"
cp config.rpath "$out"
cp config.sub "$out"
cp config-ml.in "$out"
cp ltmain.sh "$out"
cp install-sh "$out"
cp mkinstalldirs "$out"
[[ -f MD5SUMS ]]; cp MD5SUMS "$out"
'';
outputs = [
"out"
"dev"
];
patches = [
(fetchpatch {
name = "custom-threading-model.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250716204545.1063669-1-git@JohnEricson.me/raw";
hash = "sha256-jPP0+MoPLtCwWcW6doO6KHCppwAYK40qNVyriLXcGOg=";
includes = [
"config/*"
"libstdc++-v3/*"
];
})
(getVersionFile "libstdcxx/force-regular-dirs.patch")
];
postUnpack = ''
mkdir -p ./build
buildRoot=$(readlink -e "./build")
'';
preAutoreconf = ''
sourceRoot=$(readlink -e "./libstdc++-v3")
cd $sourceRoot
'';
enableParallelBuilding = true;
nativeBuildInputs = [
autoreconfHook269
gettext
];
preConfigure = ''
cd "$buildRoot"
configureScript=$sourceRoot/configure
chmod +x "$configureScript"
'';
configurePlatforms = [
"build"
"host"
];
configureFlags = [
"--disable-dependency-tracking"
"gcc_cv_target_thread_file=posix"
"cross_compiling=true"
"--disable-multilib"
"--enable-clocale=gnu"
"--disable-libstdcxx-pch"
"--disable-vtable-verify"
"--enable-libstdcxx-visibility"
"--with-default-libstdcxx-abi=new"
];
hardeningDisable = [
# PATH_MAX
"fortify"
];
postInstall = ''
moveToOutput lib/libstdc++.modules.json "$dev"
'';
doCheck = true;
passthru = {
isGNU = true;
};
meta = gcc_meta // {
homepage = "https://gcc.gnu.org/onlinedocs/libstdc++";
description = "GNU C++ Library";
};
})

View File

@@ -0,0 +1,38 @@
{
# TODO: fix up and send to upstream
"gcc/fix-collect2-paths.diff" = [
{
after = "15";
path = ../15;
}
];
# In Git: https://github.com/Ericson2314/gcc/tree/regular-dirs-in-libgcc-15
"libgcc/force-regular-dirs.patch" = [
{
after = "15";
path = ../15;
}
];
# In Git: https://github.com/Ericson2314/gcc/tree/regular-dirs-in-libssp-15
"libssp/force-regular-dirs.patch" = [
{
after = "15";
path = ../15;
}
];
# In Git: https://github.com/Ericson2314/gcc/tree/libstdcxx-force-regular-dirs-15
"libstdcxx/force-regular-dirs.patch" = [
{
after = "15";
path = ../15;
}
];
# In Git: https://github.com/Ericson2314/gcc/tree/libgfortran-force-regular-dirs-15
"libgfortran/force-regular-dirs.patch" = [
{
after = "15";
path = ../15;
}
];
}