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,97 @@
From e160a8cd4a704f4b7724df02b62394f677cc4198 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <siarheit@google.com>
Date: Fri, 22 Sep 2023 22:41:49 +0100
Subject: [PATCH] gcc/file-prefix-map.cc: always mangle __FILE__ into invalid
store path
Without the change `__FILE__` used in static inline functions in headers
embed paths to header files into executable images. For local headers
it's not a problem, but for headers in `/nix/store` this causes `-dev`
inputs to be retained in runtime closure.
Typical examples are `nix` -> `nlohmann_json` and `pipewire` ->
`lttng-ust.dev`.
For this reason we want to remove the occurrences of hashes in the
expansion of `__FILE__`. `nuke-references` does it by replacing hashes
by `eeeeee...`. It is handy to be able to invert the transformation to
go back to the original store path. The chosen solution is to make the
hash uppercase:
- it does not trigger runtime references (except for all digit hashes,
which are unlikely enough)
- it visually looks like a bogus store path
- it is easy to find the original store path if required
Ideally we would like to use `-fmacro-prefix-map=` feature of `gcc` as:
-fmacro-prefix-map=/nix/store/$hash1-nlohmann-json-ver=/nix/store/$HASH1-nlohmann-json-ver
-fmacro-prefix-map=/nix/...
In practice it quickly exhausts argument length limit due to `gcc`
deficiency: https://gcc.gnu.org/PR111527
Until it's fixed let's hardcode header mangling if $NIX_STORE variable
is present in the environment.
Tested as:
$ printf "# 0 \"/nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-pppppp-vvvvvvv\" \nconst char * f(void) { return __FILE__; }" | NIX_STORE=/nix/store ./gcc/xgcc -Bgcc -x c - -S -o -
...
.string "/nix/store/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA-pppppp-vvvvvvv"
...
Mangled successfully.
To reverse the effect of the mangle use new `NIX_GCC_DONT_MANGLE_PREFIX_MAP`
environment variable. It should not normally be needed.
--- a/gcc/file-prefix-map.cc
+++ b/gcc/file-prefix-map.cc
@@ -74,7 +74,7 @@ add_prefix_map (file_prefix_map *&maps, const char *arg, const char *opt)
remapping was performed. */
static const char *
-remap_filename (file_prefix_map *maps, const char *filename)
+remap_filename (file_prefix_map *maps, const char *filename, bool mangle_nix_store = false)
{
file_prefix_map *map;
char *s;
@@ -102,6 +102,30 @@ remap_filename (file_prefix_map *maps, const char *filename)
break;
if (!map)
{
+ if (mangle_nix_store && getenv("NIX_GCC_DONT_MANGLE_PREFIX_MAP") == NULL)
+ {
+ /* Remap all fo $NIX_STORE/.{32} paths to uppercase
+ *
+ * That way we avoid argument parameters explosion
+ * and still avoid embedding headers into runtime closure:
+ * https://gcc.gnu.org/PR111527
+ */
+ char * nix_store = getenv("NIX_STORE");
+ size_t nix_store_len = nix_store ? strlen(nix_store) : 0;
+ const char * name = realname ? realname : filename;
+ size_t name_len = strlen(name);
+ if (nix_store && name_len >= nix_store_len + 1 + 32 && memcmp(name, nix_store, nix_store_len) == 0)
+ {
+ s = (char *) ggc_alloc_atomic (name_len + 1);
+ memcpy(s, name, name_len + 1);
+ for (size_t i = nix_store_len + 1; i < nix_store_len + 1 + 32; i++) {
+ s[i] = TOUPPER(s[i]);
+ }
+ if (realname != filename)
+ free (const_cast <char *> (realname));
+ return s;
+ }
+ }
if (realname != filename)
free (const_cast <char *> (realname));
return filename;
@@ -163,7 +187,7 @@ add_profile_prefix_map (const char *arg)
const char *
remap_macro_filename (const char *filename)
{
- return remap_filename (macro_prefix_maps, filename);
+ return remap_filename (macro_prefix_maps, filename, true);
}
/* Remap using -fdebug-prefix-map. Return the GC-allocated new name

View File

@@ -0,0 +1,13 @@
--- a/gcc/config/riscv/linux.h
+++ b/gcc/config/riscv/linux.h
@@ -69,9 +69,5 @@
#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
-#define STARTFILE_PREFIX_SPEC \
- "/lib" XLEN_SPEC "/" ABI_SPEC "/ " \
- "/usr/lib" XLEN_SPEC "/" ABI_SPEC "/ " \
- "/lib/ " \
- "/usr/lib/ "
+#define STARTFILE_PREFIX_SPEC ""

View File

@@ -0,0 +1,39 @@
diff --git a/config/intlmacosx.m4 b/config/intlmacosx.m4
index 3141bf8c5..7a31862b9 100644
--- a/config/intlmacosx.m4
+++ b/config/intlmacosx.m4
@@ -63,7 +63,7 @@ AC_DEFUN([gt_INTL_MACOSX],
dnl and we have to link it in explicitly, otherwise an exception
dnl NSInvalidArgumentException "unrecognized selector sent to instance"
dnl occurs.
- INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation -Wl,-framework -Wl,CoreServices"
+ INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
fi
AC_SUBST([INTL_MACOSX_LIBS])
])
diff --git a/gcc/configure b/gcc/configure
index 23da7d55d..8bd09364d 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -13932,7 +13932,7 @@ $as_echo "#define HAVE_CFLOCALECOPYPREFERREDLANGUAGES 1" >>confdefs.h
INTL_MACOSX_LIBS=
if test $gt_cv_func_CFPreferencesCopyAppValue = yes \
|| test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then
- INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation -Wl,-framework -Wl,CoreServices"
+ INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
fi
diff --git a/libcpp/configure b/libcpp/configure
index 32d6aaa30..592c33881 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -7570,7 +7570,7 @@ $as_echo "#define HAVE_CFLOCALECOPYPREFERREDLANGUAGES 1" >>confdefs.h
INTL_MACOSX_LIBS=
if test $gt_cv_func_CFPreferencesCopyAppValue = yes \
|| test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then
- INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation -Wl,-framework -Wl,CoreServices"
+ INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
fi

View File

@@ -0,0 +1,21 @@
diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in
index 0666fc00b..0e2d53eb8 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -793,14 +793,14 @@ gnatlib-shared-darwin:
-o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
$(SO_OPTS) \
- -Wl,-install_name,@rpath/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ -Wl,-install_name,$(ADA_RTL_DSO_DIR)/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
-nodefaultrpaths -Wl,-rpath,@loader_path/,-rpath,@loader_path/.. \
-Wl,-rpath,@loader_path/../../../../ $(MISCLIB)
cd $(RTSDIR); $(GCC_FOR_ADA_RTS) -dynamiclib $(PICFLAG_FOR_TARGET) \
-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
$(GNATRTL_TASKING_OBJS) \
$(SO_OPTS) \
- -Wl,-install_name,@rpath/libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ -Wl,-install_name,$(ADA_RTL_DSO_DIR)/libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
-nodefaultrpaths -Wl,-rpath,@loader_path/,-rpath,@loader_path/.. \
-Wl,-rpath,@loader_path/../../../../ \
$(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext)

View File

@@ -0,0 +1,13 @@
diff --git a/libgcc/config.host b/libgcc/config.host
index 7332903704..27a8b5bedb 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -236,7 +236,7 @@
esac
tmake_file="$tmake_file t-slibgcc-darwin"
case ${host} in
- *-*-darwin2*)
+ *-*-darwin2* | *-*-darwin)
tmake_file="t-darwin-min-11 $tmake_file"
;;
*-*-darwin1[89]*)

View File

@@ -0,0 +1,11 @@
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -239,7 +239,7 @@ case ${host} in
x86_64-*-darwin2[0-2]*)
tmake_file="t-darwin-min-11 t-darwin-libgccs1 $tmake_file"
;;
- *-*-darwin2*)
+ *-*-darwin2* | *-*-darwin)
tmake_file="t-darwin-min-11 $tmake_file"
;;
*-*-darwin1[89]*)

View File

@@ -0,0 +1,33 @@
As originally implemented, the error message check
described in the configure script
breaks detection of Ada compiler support on x86_64-darwin,
because the assembler in the version of cctools currently used
unconditionally emits a deprecation message to stdout,
with no way to disable it.
Furthermore, GCC 3.4 was the minimum version needed to build GNAT
as far back as GCC 4.4 (see the GCC git repo, tags/releases/gcc-4.4.0,
gcc/doc/install.texi, lines 2052-2053 [1]);
GCC 3.4 is newer than any of the broken GCC versions
that the configure script works around
(see the part of the comment in the configure script
before the context in the patch below),
and GCC 4.4 is older than any GCC that Nix currently packages (GCC 4.8).
We therefore choose to not check for error messages,
and just check for an error code.
There's no harm in still checking for an object file being created, though.
[1]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/doc/install.texi;h=6bdfbece981f7fb6c26da672d45e5d3ba7879c69;hb=b7fc996728085c0591ea7c5d0e1c84a8f6a29bd8#l2052
--- a/configure 2022-08-19 18:09:52.000000000 +1000
+++ b/configure 2022-12-26 17:30:49.000000000 +1100
@@ -5622,8 +5622,7 @@
# Other compilers, like HP Tru64 UNIX cc, exit successfully when
# given a .adb file, but produce no object file. So we must check
# if an object file was really produced to guard against this.
-errors=`(${CC} -c conftest.adb) 2>&1 || echo failure`
-if test x"$errors" = x && test -f conftest.$ac_objext; then
+if ${CC} -c conftest.adb && test -f conftest.$ac_objext; then
acx_cv_cc_gcc_supports_ada=yes
fi
rm -f conftest.*

View File

@@ -0,0 +1,16 @@
this patch fixes build for clang-18+
diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S
index d3235bc33..1a56eb61c 100644
--- a/libgcc/config/aarch64/lse.S
+++ b/libgcc/config/aarch64/lse.S
@@ -170,8 +170,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
.globl \name
.hidden \name
.type \name, %function
- .cfi_startproc
\name:
+ .cfi_startproc
BTI_C
.endm

View File

@@ -0,0 +1,16 @@
this patch fixes build for clang-18+
diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S
index ecef47086..b478dd4d9 100644
--- a/libgcc/config/aarch64/lse.S
+++ b/libgcc/config/aarch64/lse.S
@@ -174,8 +174,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
.globl \name
HIDDEN(\name)
SYMBOL_TYPE(\name, %function)
- .cfi_startproc
\name:
+ .cfi_startproc
.endm
.macro ENDFN name

View File

@@ -0,0 +1,16 @@
this patch fixes build for clang-18+
diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S
index d3235bc33..1a56eb61c 100644
--- a/libgcc/config/aarch64/lse.S
+++ b/libgcc/config/aarch64/lse.S
@@ -197,8 +197,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
.text
.balign 16
.private_extern _\name
- .cfi_startproc
_\name:
+ .cfi_startproc
BTI_C
.endm

View File

@@ -0,0 +1,240 @@
{
lib,
stdenv,
langC,
langAda,
langObjC,
langObjCpp,
langFortran,
langGo,
reproducibleBuild,
profiledCompiler,
langJit,
staticCompiler,
enableShared,
enableLTO,
version,
fetchpatch,
majorVersion,
targetPlatform,
hostPlatform,
noSysDirs,
buildPlatform,
fetchurl,
withoutTargetLibc,
threadsCross,
}:
let
atLeast15 = lib.versionAtLeast version "15";
atLeast14 = lib.versionAtLeast version "14";
is15 = majorVersion == "15";
is14 = majorVersion == "14";
is13 = majorVersion == "13";
# We only apply these patches when building a native toolchain for
# aarch64-darwin, as it breaks building a foreign one:
# https://github.com/iains/gcc-12-branch/issues/18
canApplyIainsDarwinPatches =
stdenv.hostPlatform.isDarwin
&& stdenv.hostPlatform.isAarch64
&& (lib.systems.equals buildPlatform hostPlatform)
&& (lib.systems.equals hostPlatform targetPlatform);
inherit (lib) optionals optional;
in
#
# Patches below are organized into two general categories:
# 1. Patches relevant on every platform
# 2. Patches relevant on specific platforms
#
## 1. Patches relevant on every platform ####################################
[ ]
# Pass the path to a C++ compiler directly in the Makefile.in
++ optional (!lib.systems.equals targetPlatform hostPlatform) ./libstdc++-target.patch
++ optionals noSysDirs (
[
# Do not try looking for binaries and libraries in /lib and /usr/lib
./gcc-12-no-sys-dirs.patch
]
++ (
{
"15" = [
# Do not try looking for binaries and libraries in /lib and /usr/lib
./13/no-sys-dirs-riscv.patch
# Mangle the nix store hash in __FILE__ to prevent unneeded runtime references
#
# TODO: Remove these and the `useMacroPrefixMap` conditional
# in `cc-wrapper` once <https://gcc.gnu.org/PR111527>
# is fixed.
./13/mangle-NIX_STORE-in-__FILE__.patch
];
"14" = [
./13/no-sys-dirs-riscv.patch
./13/mangle-NIX_STORE-in-__FILE__.patch
];
"13" = [
./13/no-sys-dirs-riscv.patch
./13/mangle-NIX_STORE-in-__FILE__.patch
];
}
."${majorVersion}" or [ ]
)
)
# Pass CFLAGS on to gnat
++ optional langAda ./gnat-cflags-11.patch
++
optional langFortran
# Fix interaction of gfortran and libtool
# Fixes the output of -v
# See also https://github.com/nixOS/nixpkgs/commit/cc6f814a8f0e9b70ede5b24192558664fa1f98a2
./gcc-12-gfortran-driving.patch
# Do not pass a default include dir on PowerPC+Musl
# See https://github.com/NixOS/nixpkgs/pull/45340/commits/d6bb7d45162ac93e017cc9b665ae4836f6410710
++ [ ./ppc-musl.patch ]
# Moves the .cfi_starproc instruction to after the function label
# Needed to build llvm-18 and later
# See https://github.com/NixOS/nixpkgs/pull/354107/commits/2de1b4b14e17f42ba8b4bf43a29347c91511e008
++ optional (!atLeast14) ./cfi_startproc-reorder-label-09-1.diff
++ optional (atLeast14 && !canApplyIainsDarwinPatches) ./cfi_startproc-reorder-label-14-1.diff
## 2. Patches relevant on specific platforms ####################################
### Musl+Go+gcc12
# backport fixes to build gccgo with musl libc
++ optionals (stdenv.hostPlatform.isMusl && langGo) [
# libgo: handle stat st_atim32 field and SYS_SECCOMP
# syscall: gofmt
# Add blank lines after //sys comments where needed, and then run gofmt
# on the syscall package with the new formatter.
# See https://go-review.googlesource.com/c/gofrontend/+/412074
(fetchpatch {
excludes = [ "gcc/go/gofrontend/MERGE" ];
url = "https://github.com/gcc-mirror/gcc/commit/cf79b1117bd177d3d4c6ed24b6fa243c3628ac2d.diff";
hash = "sha256-mS5ZiYi5D8CpGXrWg3tXlbhp4o86ew1imCTwaHLfl+I=";
})
# libgo: permit loff_t and off_t to be macros
# See https://go-review.googlesource.com/c/gofrontend/+/412075
(fetchpatch {
excludes = [ "gcc/go/gofrontend/MERGE" ];
url = "https://github.com/gcc-mirror/gcc/commit/7f195a2270910a6ed08bd76e3a16b0a6503f9faf.diff";
hash = "sha256-Ze/cFM0dQofKH00PWPDoklXUlwWhwA1nyTuiDAZ6FKo=";
})
# libgo: handle stat st_atim32 field and SYS_SECCOMP
# See https://go-review.googlesource.com/c/gofrontend/+/415294
(fetchpatch {
excludes = [ "gcc/go/gofrontend/MERGE" ];
url = "https://github.com/gcc-mirror/gcc/commit/762fd5e5547e464e25b4bee435db6df4eda0de90.diff";
hash = "sha256-o28upwTcHAnHG2Iq0OewzwSBEhHs+XpBGdIfZdT81pk=";
})
# runtime: portable access to sigev_notify_thread_id
# See https://sourceware.org/bugzilla/show_bug.cgi?id=27417
# See https://go-review.googlesource.com/c/gofrontend/+/434755
(fetchpatch {
excludes = [ "gcc/go/gofrontend/MERGE" ];
url = "https://github.com/gcc-mirror/gcc/commit/e73d9fcafbd07bc3714fbaf8a82db71d50015c92.diff";
hash = "sha256-1SjYCVHLEUihdON2TOC3Z2ufM+jf2vH0LvYtZL+c1Fo=";
})
# syscall, runtime: always call XSI strerror_r
# See https://go-review.googlesource.com/c/gofrontend/+/454176
(fetchpatch {
excludes = [ "gcc/go/gofrontend/MERGE" ];
url = "https://github.com/gcc-mirror/gcc/commit/b6c6a3d64f2e4e9347733290aca3c75898c44b2e.diff";
hash = "sha256-RycJ3YCHd3MXtYFjxP0zY2Wuw7/C4bWoBAQtTKJZPOQ=";
})
# libgo: check for makecontext in -lucontext
# See https://go-review.googlesource.com/c/gofrontend/+/458396
(fetchpatch {
excludes = [ "gcc/go/gofrontend/MERGE" ];
url = "https://github.com/gcc-mirror/gcc/commit/2b1a604a9b28fbf4f382060bebd04adb83acc2f9.diff";
hash = "sha256-WiBQG0Xbk75rHk+AMDvsbrm+dc7lDH0EONJXSdEeMGE=";
})
# x86: Fix -fsplit-stack feature detection via TARGET_CAN_SPLIT_STACK
# Fixes compiling for non-glibc target
(fetchpatch {
url = "https://github.com/gcc-mirror/gcc/commit/c86b726c048eddc1be320c0bf64a897658bee13d.diff";
hash = "sha256-QSIlqDB6JRQhbj/c3ejlmbfWz9l9FurdSWxpwDebnlI=";
})
]
## Darwin
# Fixes detection of Darwin on x86_64-darwin. Otherwise, GCC uses a deployment target of 10.5, which crashes ld64.
++ optional (
is14 && stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64
) ../patches/14/libgcc-darwin-detection.patch
++ optional (
atLeast15 && stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64
) ../patches/15/libgcc-darwin-detection.patch
# Fix detection of bootstrap compiler Ada support (cctools as) on Nix Darwin
++ optional (stdenv.hostPlatform.isDarwin && langAda) ./ada-cctools-as-detection-configure.patch
# Remove CoreServices on Darwin, as it is only needed for macOS SDK 14+
++ optional (
atLeast14 && stdenv.hostPlatform.isDarwin && langAda
) ../patches/14/gcc-darwin-remove-coreservices.patch
# Use absolute path in GNAT dylib install names on Darwin
++ optionals (stdenv.hostPlatform.isDarwin && langAda) (
{
"15" = [ ../patches/14/gnat-darwin-dylib-install-name-14.patch ];
"14" = [ ../patches/14/gnat-darwin-dylib-install-name-14.patch ];
"13" = [ ./gnat-darwin-dylib-install-name-13.patch ];
}
.${majorVersion} or [ ]
)
# Here we apply patches by Iains (https://github.com/iains)
# GitHub's "compare" API produces unstable diffs, so we resort to reusing
# diffs from the Homebrew repo.
++ optionals canApplyIainsDarwinPatches (
{
"15" = [
# Patches from https://github.com/iains/gcc-15-branch/compare/releases/gcc-15..gcc-15.1-darwin-rc1
(fetchpatch {
name = "gcc-15-darwin-aarch64-support.patch";
url = "https://raw.githubusercontent.com/Homebrew/formula-patches/a25079204c1cb3d78ba9dd7dd22b8aecce7ce264/gcc/gcc-15.1.0.diff";
sha256 = "sha256-MJxSGv6LEP1sIM8cDqbmfUV7byV0bYgADeIBY/Teyu8=";
})
];
"14" = [
# Patches from https://github.com/iains/gcc-14-branch/compare/04696df09633baf97cdbbdd6e9929b9d472161d3..gcc-14.2-darwin-r2
(fetchpatch {
# There are no upstream release tags nor a static branch for 14.3.0 in https://github.com/iains/gcc-14-branch.
# aa4cd614456de65ee3417acb83c6cff0640144e9 is the merge base of https://github.com/iains/gcc-14-branch/tree/gcc-14-3-darwin-pre-0 and https://github.com/gcc-mirror/gcc/releases/tag/releases%2Fgcc-14.3.0
# 3e1d48d240f4aa5223c701b5c231c66f66ab1126 is the newest commit of https://github.com/iains/gcc-14-branch/tree/gcc-14-3-darwin-pre-0
name = "gcc-14-darwin-aarch64-support.patch";
url = "https://github.com/iains/gcc-14-branch/compare/aa4cd614456de65ee3417acb83c6cff0640144e9..3e1d48d240f4aa5223c701b5c231c66f66ab1126.diff";
hash = "sha256-BSTSYnkBJBEm++mGerVVyaCUC4dUyXq0N1tqbk25bO4=";
})
];
# Patches from https://github.com/iains/gcc-13-branch/compare/b71f1de6e9cf7181a288c0f39f9b1ef6580cf5c8..gcc-13-3-darwin
"13" = [
(fetchpatch {
name = "gcc-13-darwin-aarch64-support.patch";
url = "https://raw.githubusercontent.com/Homebrew/formula-patches/698885df7f624d0ce15bceb79a4d9760a473b502/gcc/gcc-13.4.0.diff";
hash = "sha256-xqkBDFYZ6fdowtqR3kV7bR8a4Cu11RDokSzGn1k3a1w=";
})
];
}
.${majorVersion} or [ ]
)
++ optional targetPlatform.isCygwin (fetchpatch {
name = "libstdc-fix-compilation-in-freestanding-win32.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250922182808.2599390-2-corngood@gmail.com/raw";
hash = "sha256-+EYW9lG8CviVX7RyNHp+iX+8BRHUjt5b07k940khbbY=";
})
++ optionals targetPlatform.isCygwin [
(fetchpatch {
name = "cygwin-fix-compilation-with-inhibit_libc.patch";
url = "https://inbox.sourceware.org/gcc-patches/20250926170154.2222977-1-corngood@gmail.com/raw";
hash = "sha256-mgzMRvgPdhj+Q2VRsFhpE2WQzg0CvWsc5/FRAsSU1Es=";
})
]

View File

@@ -0,0 +1,20 @@
This patch fixes interaction with Libtool.
See <http://thread.gmane.org/gmane.comp.gcc.patches/258777>, for details.
--- a/gcc/fortran/gfortranspec.cc
+++ b/gcc/fortran/gfortranspec.cc
@@ -461,8 +461,15 @@ For more information about these matters, see the file named COPYING\n\n"));
{
fprintf (stderr, _("Driving:"));
for (i = 0; i < g77_newargc; i++)
+ {
+ if (g77_new_decoded_options[i].opt_index == OPT_l)
+ /* Make sure no white space is inserted after `-l'. */
+ fprintf (stderr, " -l%s",
+ g77_new_decoded_options[i].canonical_option[1]);
+ else
fprintf (stderr, " %s",
g77_new_decoded_options[i].orig_option_with_args_text);
+ }
fprintf (stderr, "\n");
}

View File

@@ -0,0 +1,26 @@
--- a/gcc/cppdefault.cc 2013-01-10 21:38:27.000000000 +0100
+++ b/gcc/cppdefault.cc 2014-08-18 16:20:32.893944536 +0200
@@ -35,6 +35,8 @@
# undef CROSS_INCLUDE_DIR
#endif
+#undef LOCAL_INCLUDE_DIR
+
const struct default_include cpp_include_defaults[]
#ifdef INCLUDE_DEFAULTS
= INCLUDE_DEFAULTS;
--- a/gcc/gcc.cc 2014-03-23 12:30:57.000000000 +0100
+++ b/gcc/gcc.cc 2014-08-18 13:19:32.689201690 +0200
@@ -1162,10 +1162,10 @@
/* Default prefixes to attach to command names. */
#ifndef STANDARD_STARTFILE_PREFIX_1
-#define STANDARD_STARTFILE_PREFIX_1 "/lib/"
+#define STANDARD_STARTFILE_PREFIX_1 ""
#endif
#ifndef STANDARD_STARTFILE_PREFIX_2
-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
+#define STANDARD_STARTFILE_PREFIX_2 ""
#endif
#ifdef CROSS_DIRECTORY_STRUCTURE /* Don't use these prefixes for a cross compiler. */

View File

@@ -0,0 +1,35 @@
diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in
index 4e74252bd74..0d848b5b4e3 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -111,7 +111,7 @@ NO_OMIT_ADAFLAGS = -fno-omit-frame-pointer
NO_SIBLING_ADAFLAGS = -fno-optimize-sibling-calls
NO_REORDER_ADAFLAGS = -fno-toplevel-reorder
GNATLIBFLAGS = -W -Wall -gnatg -nostdinc
-GNATLIBCFLAGS = -g -O2
+GNATLIBCFLAGS = -g -O2 $(CFLAGS_FOR_TARGET)
# Pretend that _Unwind_GetIPInfo is available for the target by default. This
# should be autodetected during the configuration of libada and passed down to
# here, but we need something for --disable-libada and hope for the best.
@@ -198,7 +198,7 @@ RTSDIR = rts$(subst /,_,$(MULTISUBDIR))
# Link flags used to build gnat tools. By default we prefer to statically
# link with libgcc to avoid a dependency on shared libgcc (which is tricky
# to deal with as it may conflict with the libgcc provided by the system).
-GCC_LINK_FLAGS=-static-libstdc++ -static-libgcc
+GCC_LINK_FLAGS=-static-libstdc++ -static-libgcc $(CFLAGS_FOR_TARGET)
# End of variables for you to override.
diff --git a/libada/Makefile.in b/libada/Makefile.in
index 522b9207326..ca866c74471 100644
--- a/libada/Makefile.in
+++ b/libada/Makefile.in
@@ -59,7 +59,7 @@ LDFLAGS=
CFLAGS=-g
PICFLAG = @PICFLAG@
GNATLIBFLAGS= -W -Wall -gnatpg -nostdinc
-GNATLIBCFLAGS= -g -O2
+GNATLIBCFLAGS= -g -O2 $(CFLAGS)
GNATLIBCFLAGS_FOR_C = -W -Wall $(GNATLIBCFLAGS) $(CFLAGS_FOR_TARGET) \
-fexceptions -DIN_RTS @have_getipinfo@ @have_capability@

View File

@@ -0,0 +1,18 @@
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -788,13 +788,13 @@ gnatlib-shared-darwin:
-o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
$(SO_OPTS) \
- -Wl,-install_name,@rpath/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ -Wl,-install_name,$(ADA_RTL_DSO_DIR)/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
$(MISCLIB)
cd $(RTSDIR); $(GCC_FOR_ADA_RTS) -dynamiclib $(PICFLAG_FOR_TARGET) \
-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
$(GNATRTL_TASKING_OBJS) \
$(SO_OPTS) \
- -Wl,-install_name,@rpath/libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ -Wl,-install_name,$(ADA_RTL_DSO_DIR)/libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
$(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext)
cd $(RTSDIR); $(LN_S) libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
libgnat$(soext)

View File

@@ -0,0 +1,32 @@
Patch to make the target libraries 'configure' scripts find the proper CPP.
I noticed that building the mingw32 cross compiler.
Looking at the build script for mingw in archlinux, I think that only nixos
needs this patch. I don't know why.
diff --git a/Makefile.in b/Makefile.in
index 93f66b6..d691917 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \
AR="$(AR_FOR_TARGET)"; export AR; \
AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
+ CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \
CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \
@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \
RAW_CXX_TARGET_EXPORTS = \
$(BASE_TARGET_EXPORTS) \
CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
- CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
+ CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
+ CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
NORMAL_TARGET_EXPORTS = \
$(BASE_TARGET_EXPORTS) \
- CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
+ CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
+ CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
# Where to find GMP
HOST_GMPLIBS = @gmplibs@

View File

@@ -0,0 +1,18 @@
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index cbee89140dd..e1f26b0a096 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -996,13 +996,7 @@ ncrtn.o%s"
{ GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
-#ifdef LOCAL_INCLUDE_DIR
-#define INCLUDE_DEFAULTS_MUSL_LOCAL \
- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
-#else
#define INCLUDE_DEFAULTS_MUSL_LOCAL
-#endif
#ifdef PREFIX_INCLUDE_DIR
#define INCLUDE_DEFAULTS_MUSL_PREFIX \