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,315 @@
diff --git a/gcc/collect2.cc b/gcc/collect2.cc
index 268ac378b9c..8a5c606075a 100644
--- a/gcc/collect2.cc
+++ b/gcc/collect2.cc
@@ -327,7 +327,7 @@ static void write_aix_file (FILE *, struct id *);
static char *resolve_lib_name (const char *);
#endif
static char *extract_string (const char **);
-static void post_ld_pass (bool);
+static void post_ld_pass (bool, bool);
static void process_args (int *argcp, char **argv);
/* Enumerations describing which pass this is for scanning the
@@ -513,12 +513,10 @@ is_ctor_dtor (const char *s)
static struct path_prefix cpath, path;
-#ifdef CROSS_DIRECTORY_STRUCTURE
/* This is the name of the target machine. We use it to form the name
of the files to execute. */
static const char *const target_machine = TARGET_MACHINE;
-#endif
/* Search for NAME using prefix list PPREFIX. We only look for executable
files.
@@ -577,7 +575,7 @@ add_lto_object (struct lto_object_list *list, const char *name)
static void
maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst,
- const char **object, bool force)
+ const char **object, bool force, bool is_cross_compiler)
{
const char **object_file = CONST_CAST2 (const char **, char **, object_lst);
@@ -722,7 +720,7 @@ maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst,
"ld_args");
/* We assume that temp files were created, and therefore we need to take
that into account (maybe run dsymutil). */
- post_ld_pass (/*temp_file*/true);
+ post_ld_pass (/*temp_file*/true, is_cross_compiler);
free (lto_ld_argv);
maybe_unlink_list (lto_o_files);
@@ -734,10 +732,10 @@ maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst,
fork_execute ("ld", lto_ld_argv, HAVE_GNU_LD && at_file_supplied,
"ld_args");
/* No LTO objects were found, so no new temp file. */
- post_ld_pass (/*temp_file*/false);
+ post_ld_pass (/*temp_file*/false, is_cross_compiler);
}
else
- post_ld_pass (false); /* No LTO objects were found, no temp file. */
+ post_ld_pass (false, is_cross_compiler); /* No LTO objects were found, no temp file. */
}
/* Entry point for linker invoation. Called from main in collect2.cc.
LD_ARGV is an array of arguments for the linker. */
@@ -799,33 +797,14 @@ main (int argc, char **argv)
static const char *const gstrip_suffix = "gstrip";
const char *full_ld_suffixes[USE_LD_MAX];
-#ifdef CROSS_DIRECTORY_STRUCTURE
- /* If we look for a program in the compiler directories, we just use
- the short name, since these directories are already system-specific.
- But it we look for a program in the system directories, we need to
- qualify the program name with the target machine. */
-
- const char *const full_nm_suffix =
- concat (target_machine, "-", nm_suffix, NULL);
- const char *const full_gnm_suffix =
- concat (target_machine, "-", gnm_suffix, NULL);
-#ifdef LDD_SUFFIX
- const char *const full_ldd_suffix =
- concat (target_machine, "-", ldd_suffix, NULL);
-#endif
- const char *const full_strip_suffix =
- concat (target_machine, "-", strip_suffix, NULL);
- const char *const full_gstrip_suffix =
- concat (target_machine, "-", gstrip_suffix, NULL);
-#else
+ const char *full_nm_suffix;
+ const char *full_gnm_suffix;
+ const char *full_strip_suffix;
+ const char *full_gstrip_suffix;
+
#ifdef LDD_SUFFIX
- const char *const full_ldd_suffix = ldd_suffix;
+ const char *full_ldd_suffix;
#endif
- const char *const full_nm_suffix = nm_suffix;
- const char *const full_gnm_suffix = gnm_suffix;
- const char *const full_strip_suffix = strip_suffix;
- const char *const full_gstrip_suffix = gstrip_suffix;
-#endif /* CROSS_DIRECTORY_STRUCTURE */
const char *arg;
FILE *outf;
@@ -840,6 +819,7 @@ main (int argc, char **argv)
const char **ld1;
bool use_plugin = false;
bool use_collect_ld = false;
+ bool is_cross_compiler = false;
/* The kinds of symbols we will have to consider when scanning the
outcome of a first pass link. This is ALL to start with, then might
@@ -864,17 +844,6 @@ main (int argc, char **argv)
#endif
int i;
- for (i = 0; i < USE_LD_MAX; i++)
-#ifdef CROSS_DIRECTORY_STRUCTURE
- /* lld and mold are platform-agnostic and not prefixed with target
- triple. */
- if (!(i == USE_LLD_LD || i == USE_MOLD_LD))
- full_ld_suffixes[i] = concat (target_machine, "-", ld_suffixes[i],
- NULL);
- else
-#endif
- full_ld_suffixes[i] = ld_suffixes[i];
-
p = argv[0] + strlen (argv[0]);
while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
--p;
@@ -1050,6 +1019,65 @@ main (int argc, char **argv)
prefix_from_env ("COMPILER_PATH", &cpath);
prefix_from_env ("PATH", &path);
+ /* Determine the full path name of the C compiler to use. */
+ c_file_name = getenv ("COLLECT_GCC");
+ if (c_file_name == 0)
+ {
+ c_file_name = concat (target_machine, "-gcc", NULL);
+ p = find_a_file (&cpath, c_file_name, X_OK);
+ if (p == 0)
+ p = find_a_file (&path, c_file_name, X_OK);
+
+ if (p == 0) {
+ c_file_name = "gcc";
+ p = find_a_file (&cpath, c_file_name, X_OK);
+ if (p == 0)
+ p = find_a_file (&path, c_file_name, X_OK);
+ }
+ }
+ else
+ {
+ p = find_a_file (&cpath, c_file_name, X_OK);
+
+ /* Here it should be safe to use the system search path since we should have
+ already qualified the name of the compiler when it is needed. */
+ if (p == 0)
+ p = find_a_file (&path, c_file_name, X_OK);
+ }
+
+ if (p)
+ c_file_name = p;
+
+ if (c_file_name) {
+ is_cross_compiler = strncmp(basename(c_file_name), target_machine, strlen(target_machine)) == 0;
+ }
+
+ for (i = 0; i < USE_LD_MAX; i++)
+ /* lld and mold are platform-agnostic and not prefixed with target
+ triple. */
+ if (!(i == USE_LLD_LD || i == USE_MOLD_LD) && is_cross_compiler)
+ full_ld_suffixes[i] = concat (target_machine, "-", ld_suffixes[i],
+ NULL);
+ else
+ full_ld_suffixes[i] = ld_suffixes[i];
+
+ full_nm_suffix =
+ is_cross_compiler ? concat (target_machine, "-", nm_suffix, NULL) : nm_suffix;
+
+ full_gnm_suffix =
+ is_cross_compiler ? concat (target_machine, "-", gnm_suffix, NULL) : gnm_suffix;
+
+ full_strip_suffix =
+ is_cross_compiler ? concat (target_machine, "-", strip_suffix, NULL) : strip_suffix;
+
+ full_gstrip_suffix =
+ is_cross_compiler ? concat (target_machine, "-", gstrip_suffix, NULL) : gstrip_suffix;
+
+#ifdef LDD_SUFFIX
+ full_ldd_suffix =
+ is_cross_compiler ? concat (target_machine, "-", ldd_suffix, NULL) : ldd_suffix;
+#endif
+
/* Try to discover a valid linker/nm/strip to use. */
/* Maybe we know the right file to use (if not cross). */
@@ -1139,27 +1167,6 @@ main (int argc, char **argv)
if (strip_file_name == 0)
strip_file_name = find_a_file (&path, full_strip_suffix, X_OK);
- /* Determine the full path name of the C compiler to use. */
- c_file_name = getenv ("COLLECT_GCC");
- if (c_file_name == 0)
- {
-#ifdef CROSS_DIRECTORY_STRUCTURE
- c_file_name = concat (target_machine, "-gcc", NULL);
-#else
- c_file_name = "gcc";
-#endif
- }
-
- p = find_a_file (&cpath, c_file_name, X_OK);
-
- /* Here it should be safe to use the system search path since we should have
- already qualified the name of the compiler when it is needed. */
- if (p == 0)
- p = find_a_file (&path, c_file_name, X_OK);
-
- if (p)
- c_file_name = p;
-
*ld1++ = *ld2++ = ld_file_name;
/* Make temp file names. */
@@ -1595,6 +1602,8 @@ main (int argc, char **argv)
(c_file ? c_file : "not found"));
fprintf (stderr, "o_file = %s\n",
(o_file ? o_file : "not found"));
+ fprintf (stderr, "is_cross_compiler = %s\n",
+ (is_cross_compiler ? "yes" : "no"));
ptr = getenv ("COLLECT_GCC_OPTIONS");
if (ptr)
@@ -1644,9 +1653,9 @@ main (int argc, char **argv)
maybe_unlink (export_file);
#endif
if (lto_mode != LTO_MODE_NONE)
- maybe_run_lto_and_relink (ld1_argv, object_lst, object, false);
+ maybe_run_lto_and_relink (ld1_argv, object_lst, object, false, is_cross_compiler);
else
- post_ld_pass (/*temp_file*/false);
+ post_ld_pass (/*temp_file*/false, is_cross_compiler);
return 0;
}
@@ -1698,7 +1707,7 @@ main (int argc, char **argv)
do_link (ld1_argv, "ld1_args");
if (lto_mode)
- maybe_run_lto_and_relink (ld1_argv, object_lst, object, false);
+ maybe_run_lto_and_relink (ld1_argv, object_lst, object, false, is_cross_compiler);
/* Strip now if it was requested on the command line. */
if (strip_flag)
@@ -1716,7 +1725,7 @@ main (int argc, char **argv)
#ifdef COLLECT_EXPORT_LIST
maybe_unlink (export_file);
#endif
- post_ld_pass (/*temp_file*/false);
+ post_ld_pass (/*temp_file*/false, is_cross_compiler);
return 0;
}
@@ -1799,15 +1808,15 @@ main (int argc, char **argv)
do_link (ld2_argv, "ld2_args");
if (lto_mode)
- maybe_run_lto_and_relink (ld2_argv, object_lst, object, false);
+ maybe_run_lto_and_relink (ld2_argv, object_lst, object, false, is_cross_compiler);
#else
/* Otherwise, simply call ld because link is already done. */
if (lto_mode)
- maybe_run_lto_and_relink (ld2_argv, object_lst, object, true);
+ maybe_run_lto_and_relink (ld2_argv, object_lst, object, true, is_cross_compiler);
else
{
fork_execute ("ld", ld2_argv, HAVE_GNU_LD && at_file_supplied, "ld_args");
- post_ld_pass (/*temp_file*/false);
+ post_ld_pass (/*temp_file*/false, is_cross_compiler);
}
/* Let scan_prog_file do any final mods (OSF/rose needs this for
@@ -3020,7 +3029,7 @@ process_args (int *argcp, char **argv) {
}
static void
-do_dsymutil (const char *output_file) {
+do_dsymutil (const char *output_file, bool is_cross_compiler) {
const char *dsymutil = 0;
struct pex_obj *pex;
char **real_argv = XCNEWVEC (char *, verbose ? 4 : 3);
@@ -3032,11 +3041,7 @@ do_dsymutil (const char *output_file) {
here is consistent with the way other installations work (and one can
always symlink a multitarget dsymutil with a target-specific name). */
const char *dsname = "dsymutil";
-#ifdef CROSS_DIRECTORY_STRUCTURE
- const char *qname = concat (target_machine, "-", dsname, NULL);
-#else
- const char *qname = dsname;
-#endif
+ const char *qname = is_cross_compiler ? concat (target_machine, "-", dsname, NULL) : dsname;
#ifdef DEFAULT_DSYMUTIL
/* Configured default takes priority. */
if (dsymutil == 0 && access (DEFAULT_DSYMUTIL, X_OK) == 0)
@@ -3071,14 +3076,14 @@ do_dsymutil (const char *output_file) {
}
static void
-post_ld_pass (bool temp_file) {
+post_ld_pass (bool temp_file, bool is_cross_compiler) {
if (!(temp_file && flag_idsym) && !flag_dsym)
return;
- do_dsymutil (output_file);
+ do_dsymutil (output_file, is_cross_compiler);
}
#else
static void
process_args (int *argcp ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { }
-static void post_ld_pass (bool temp_file ATTRIBUTE_UNUSED) { }
+static void post_ld_pass (bool temp_file ATTRIBUTE_UNUSED, bool is_cross_compiler ATTRIBUTE_UNUSED) { }
#endif

View File

@@ -0,0 +1,49 @@
From bb3277895d3bd77bcacb7c489ebb1390478bbc12 Mon Sep 17 00:00:00 2001
From: John Ericson <John.Ericson@Obsidian.Systems>
Date: Thu, 17 Jul 2025 11:00:07 -0400
Subject: [PATCH 2/2] Force regular dirs
Override directories in libgcc so they are normal $out/lib and
$dev/include. This is not suitable for upstreaming, but is done on top
of a different patch which is, and which makes this smaller.
---
libgcc/Makefile.in | 6 +++---
libgcc/configure.ac | 3 ---
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index 4661c36703d..986cd035148 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -202,10 +202,10 @@ STRIP = @STRIP@
STRIP_FOR_TARGET = $(STRIP)
# Used to install the shared libgcc.
-slibdir = @slibdir@
+slibdir = $(libdir)
# Maybe used for DLLs on Windows targets.
-toolexecdir = @toolexecdir@
-toolexeclibdir = @toolexeclibdir@
+toolexecdir = $(bindir)
+toolexeclibdir = $(libdir)
export AR_FOR_TARGET
export AR_CREATE_FOR_TARGET
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
index 5fdac5d95f2..89044cb65c9 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -479,9 +479,6 @@ if test x"$enable_as_accelerator_for" != x; then
accel_dir_suffix=/accel/${target_noncanonical}
real_host_noncanonical=${enable_as_accelerator_for}
fi
-# Directory in which the compiler finds libraries etc.
-libdir=${orig_libdir}/gcc/${real_host_noncanonical}/'$(version)'${accel_dir_suffix}
-includedir=${libdir}/include
if test x"$enable_offload_targets" != x; then
extra_parts="${extra_parts} crtoffloadbegin.o crtoffloadend.o"
--
2.47.2

View File

@@ -0,0 +1,53 @@
From 7a0c8ca8872a73c6886940448ba9b3203b13268d Mon Sep 17 00:00:00 2001
From: John Ericson <git@JohnEricson.me>
Date: Mon, 21 Jul 2025 11:42:13 -0400
Subject: [PATCH] libgfortran: Force regular include/lib dir
---
libgfortran/Makefile.am | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
index 21b35c76a06..3d38cde5b42 100644
--- a/libgfortran/Makefile.am
+++ b/libgfortran/Makefile.am
@@ -42,14 +42,13 @@ extra_darwin_ldflags_libgfortran += -Wc,-nodefaultrpaths
extra_darwin_ldflags_libgfortran += -Wl,-rpath,@loader_path
endif
-gfor_c_HEADERS = ISO_Fortran_binding.h
-gfor_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
+include_HEADERS = ISO_Fortran_binding.h
LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) \
$(lt_host_flags)
-toolexeclib_LTLIBRARIES = libgfortran.la
-toolexeclib_DATA = libgfortran.spec
+lib_LTLIBRARIES = libgfortran.la
+toolexeclib_DATA = libgfortran.spec # needs "exec" in name
libgfortran_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS)
libgfortran_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
$(LTLDFLAGS) $(LIBQUADLIB) ../libbacktrace/libbacktrace.la \
@@ -58,16 +57,14 @@ libgfortran_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
$(version_arg) -Wc,-shared-libgcc
libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP)
-cafexeclib_LTLIBRARIES = libcaf_single.la
-cafexeclibdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)
+lib_LTLIBRARIES += libcaf_single.la
libcaf_single_la_SOURCES = caf/single.c
libcaf_single_la_LDFLAGS = -static
libcaf_single_la_DEPENDENCIES = caf/libcaf.h
libcaf_single_la_LINK = $(LINK) $(libcaf_single_la_LDFLAGS)
if IEEE_SUPPORT
-fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude
-nodist_finclude_HEADERS = ieee_arithmetic.mod ieee_exceptions.mod ieee_features.mod
+nodist_include_HEADERS = ieee_arithmetic.mod ieee_exceptions.mod ieee_features.mod
endif
## io.h conflicts with a system header on some platforms, so
--
2.47.2

View File

@@ -0,0 +1,30 @@
From e7dac0e90f3e4363d858a6f147d7cc4f62815dd6 Mon Sep 17 00:00:00 2001
From: John Ericson <John.Ericson@Obsidian.Systems>
Date: Fri, 18 Jul 2025 16:54:17 -0400
Subject: [PATCH 3/3] Force regular dirs
Override directories in libssp so they are normal $out/lib and
$dev/include. This is not suitable for upstreaming, but is done on top
of a different patch which is, and which makes this smaller.
---
libssp/configure.ac | 4 ----
1 file changed, 4 deletions(-)
diff --git a/libssp/configure.ac b/libssp/configure.ac
index 5b9fa4fbecc..f1723dc33ce 100644
--- a/libssp/configure.ac
+++ b/libssp/configure.ac
@@ -207,10 +207,6 @@ esac
AC_SUBST(toolexecdir)
AC_SUBST(toolexeclibdir)
-# Directory in which the compiler finds libraries etc.
-libdir='$(toolexeclibdir)'
-includedir=${orig_libdir}/gcc/${host_noncanonical}/'$(version)/include'
-
if test ${multilib} = yes; then
multilib_arg="--enable-multilib"
else
--
2.47.2

View File

@@ -0,0 +1,120 @@
From db427c55334dd2edc11397d3a92d55dc9c06d1c3 Mon Sep 17 00:00:00 2001
From: John Ericson <git@JohnEricson.me>
Date: Sun, 20 Jul 2025 14:20:00 -0400
Subject: [PATCH] libstdc++: Force regular include/lib dir
Delete a bunch of unneeded logic to do this.
---
libstdc++-v3/acinclude.m4 | 80 ++------------------------------
libstdc++-v3/include/Makefile.am | 2 +-
2 files changed, 4 insertions(+), 78 deletions(-)
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index a0094c2dd95..a0718dff394 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -727,85 +727,11 @@ dnl
dnl This logic must match gcc/configure.ac's setting of gcc_gxx_include_dir.
dnl config/gxx-include-dir.m4 must be kept consistant with this as well.
AC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO], [
- glibcxx_toolexecdir=no
- glibcxx_toolexeclibdir=no
+ glibcxx_toolexecdir='$(libdir)'
+ glibcxx_toolexeclibdir='$(libdir)'
+ gxx_include_dir='$(includedir)'
glibcxx_prefixdir=$prefix
- AC_MSG_CHECKING([for gxx-include-dir])
- AC_ARG_WITH([gxx-include-dir],
- AC_HELP_STRING([--with-gxx-include-dir=DIR],
- [installation directory for include files]),
- [case "$withval" in
- yes) AC_MSG_ERROR([Missing directory for --with-gxx-include-dir]) ;;
- no) gxx_include_dir=no ;;
- *) gxx_include_dir=$withval ;;
- esac],
- [gxx_include_dir=no])
- AC_MSG_RESULT($gxx_include_dir)
-
- AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
- AC_ARG_ENABLE([version-specific-runtime-libs],
- AC_HELP_STRING([--enable-version-specific-runtime-libs],
- [Specify that runtime libraries should be installed in a compiler-specific directory]),
- [case "$enableval" in
- yes) version_specific_libs=yes ;;
- no) version_specific_libs=no ;;
- *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
- esac],
- [version_specific_libs=no])
- AC_MSG_RESULT($version_specific_libs)
-
- GCC_WITH_TOOLEXECLIBDIR
-
- # Default case for install directory for include files.
- if test $version_specific_libs = no && test $gxx_include_dir = no; then
- gxx_include_dir='include/c++/${gcc_version}'
- if test -n "$with_cross_host" &&
- test x"$with_cross_host" != x"no"; then
- gxx_include_dir='${prefix}/${target_alias}/'"$gxx_include_dir"
- else
- gxx_include_dir='${prefix}/'"$gxx_include_dir"
- fi
- fi
-
- # Version-specific runtime libs processing.
- if test $version_specific_libs = yes; then
- # Need the gcc compiler version to know where to install libraries
- # and header files if --enable-version-specific-runtime-libs option
- # is selected. FIXME: these variables are misnamed, there are
- # no executables installed in _toolexecdir or _toolexeclibdir.
- if test x"$gxx_include_dir" = x"no"; then
- gxx_include_dir='${libdir}/gcc/${host_alias}/${gcc_version}/include/c++'
- fi
- glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
- glibcxx_toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)'
- fi
-
- # Calculate glibcxx_toolexecdir, glibcxx_toolexeclibdir
- # Install a library built with a cross compiler in tooldir, not libdir.
- if test x"$glibcxx_toolexecdir" = x"no"; then
- if test -n "$with_cross_host" &&
- test x"$with_cross_host" != x"no"; then
- glibcxx_toolexecdir='${exec_prefix}/${host_alias}'
- case ${with_toolexeclibdir} in
- no)
- glibcxx_toolexeclibdir='${toolexecdir}/lib'
- ;;
- *)
- glibcxx_toolexeclibdir=${with_toolexeclibdir}
- ;;
- esac
- else
- glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
- glibcxx_toolexeclibdir='${libdir}'
- fi
- multi_os_directory=`$CXX -print-multi-os-directory`
- case $multi_os_directory in
- .) ;; # Avoid trailing /.
- *) glibcxx_toolexeclibdir=$glibcxx_toolexeclibdir/$multi_os_directory ;;
- esac
- fi
-
AC_MSG_CHECKING([for install location])
AC_MSG_RESULT($gxx_include_dir)
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 537774c2668..c0bfeb43b44 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -1048,7 +1048,7 @@ endif
host_srcdir = ${glibcxx_srcdir}/$(OS_INC_SRCDIR)
host_builddir = ./${host_alias}/bits
-host_installdir = ${gxx_include_dir}/${host_alias}$(MULTISUBDIR)/bits
+host_installdir = ${gxx_include_dir}/bits
host_headers = \
${host_srcdir}/ctype_base.h \
${host_srcdir}/ctype_inline.h \
--
2.47.2

View File

@@ -0,0 +1,3 @@
# GCC Next-Generation
Experimental split GCC package set based on the LLVM package set design.

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;
}
];
}

View File

@@ -0,0 +1,70 @@
{
lib,
callPackage,
stdenv,
stdenvAdapters,
recurseIntoAttrs,
gccVersions ? { },
patchesFn ? lib.id,
buildPackages,
targetPackages,
binutilsNoLibc,
binutils,
generateSplicesForMkScope,
...
}@packageSetArgs:
let
versions = {
"15.1.0".officialRelease.sha256 = "sha256-4rCewhZg8B/s/7cV4BICZSFpQ/A40OSKmGhxPlTwbOo=";
}
// gccVersions;
mkPackage =
{
name ? null,
officialRelease ? null,
gitRelease ? null,
monorepoSrc ? null,
version ? null,
}@args:
let
inherit
(import ./common/common-let.nix {
inherit
lib
gitRelease
officialRelease
version
;
})
releaseInfo
;
inherit (releaseInfo) release_version;
attrName =
args.name or (if (gitRelease != null) then "git" else lib.versions.major release_version);
in
lib.nameValuePair attrName (
recurseIntoAttrs (
callPackage ./common (
{
inherit (stdenvAdapters) overrideCC;
inherit
officialRelease
gitRelease
monorepoSrc
version
patchesFn
;
buildGccPackages = buildPackages."gccNGPackages_${attrName}";
targetGccPackages = targetPackages."gccNGPackages_${attrName}" or gccPackages."${attrName}";
otherSplices = generateSplicesForMkScope "gccNGPackages_${attrName}";
}
// packageSetArgs # Allow overrides.
)
)
);
gccPackages = lib.mapAttrs' (version: args: mkPackage (args // { inherit version; })) versions;
in
gccPackages // { inherit mkPackage; }