Skip to content

Commit a436f22

Browse files
committed
sys-devel/gcc-13.2.0-r1: switch to original source + patch for arm64-darwin
Borrow patch from Homebrew to apply to 13.2.0 proper. Add two patches to help interoperability with newer OS/CLTs. Signed-off-by: Fabian Groffen <[email protected]>
1 parent f61f449 commit a436f22

4 files changed

+276
-0
lines changed

sys-devel/gcc/Manifest

+3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ DIST gcc-12.2-darwin-r0.tar.gz 131069986 BLAKE2B 42de71c9f0802f1a43e675d3fae7341
66
DIST gcc-12.2.0-musl-patches-1.tar.xz 3844 BLAKE2B 004432806696f7d0a32366270ac45695e858abee73a255e44dc6e0a225339e4cad40aab0d51dfe9a55d5aa4b4001f5726064bb2eea3212a0874b2d27e229abd7 SHA512 c354edcd641a9dfaf902a0ff4c44c75065d0cf1c36bbf6c3c35c2e23bff22b8f70bcf4458a5a0ef86371e9f2fafca8a54ca822e35820ff442c9458a2819c3606
77
DIST gcc-12.2.0-patches-1.tar.xz 12864 BLAKE2B a5ae0a85dfc1b6f0bd968f0d5262ebed14ec9cdb3249e3a4c571578c54eda0e53708ee7fe8e03e506366c7f3cf7926eced9b390d9dee948c1249298c0fabd9fb SHA512 f3d793b89a2a0385d596162fb0c653d4acdf21ae418cb792c1786a01fde0391bd0719715dbf07d53636f127168f5cd99108a1dc11cf6cea889b7d82385bcc258
88
DIST gcc-12.2.0.tar.xz 84645292 BLAKE2B 715574af9ad678f9dc8cfd19c866bf910c7edfd479e7e9681337feaa9b54e5d304ddb85483816b8d89754d502405823ae2eff0d1e444538763f40be8e428d8da SHA512 e9e857bd81bf7a370307d6848c81b2f5403db8c7b5207f54bce3f3faac3bde63445684092c2bc1a2427cddb6f7746496d9fbbef05fbbd77f2810b2998f1f9173
9+
DIST gcc-13-20240323.tar.xz 84414636 BLAKE2B cd95fc9d83d9e2477597543af5ec4e9ac82029eca6deb8cd8f82b71132e3a54e5a770be201c9e596c48f936a169f60e19979128527f41086a9a12deebbfebb26 SHA512 b25fb0efbe7346f72407ad1102d877f2ed5b40a8bff88018db4541d15cd47a849d7aeb8706be3c2ca6256fc073fe6881c8ba74db220c80b01666195d3be038d4
910
DIST gcc-13.2-darwin-r0.tar.gz 137958605 BLAKE2B b6777b76baf2dc007c4080c0b7a6d448223747f0cf832e493e3b903b3bdb7f87a0e2e9cf41f9355769b178a72409b1e2866b3e73b1cc33ed0aba837f3a9e66c1 SHA512 a33177bd55d228d1df93e2a029e8af5d215ad8b2ebc84a0c90df629d6f69c5de0ed1ec9dd27bc21a62362522d83bad9a8f34407b89b13321b65f513fa2202dd2
11+
DIST gcc-13.2.0-arm64-darwin.patch 470156 BLAKE2B 5ba9c380d488c1ceda2f4ece68701a51d1de3d82f6aa9c96f33c4f2066e7053356c00158eec524298c16c916ff1d14bb3560eedb90f09bade44970156e86c604 SHA512 4428340c79cad8f4324bb4f5962640805f45e4a2a2be165abb0386e283f863fad9dbff8eefa508ee30ba966691f604fdadfb4d42bc9cc4c29536feaae5c1f55a
1012
DIST gcc-13.2.0-musl-patches-2.tar.xz 5292 BLAKE2B c057d6574d03c05854edaa9f3fd40e9149662b04f3ac7a7db3eb078d73a7b535726d1bf52e5b12736dedb2f9898ad731f2e48a6421fcfbf7b90f929dee072fcb SHA512 a691da0c87c443a5e9d23731f4005f27871c5b12bc9102873ffa24d374aa7b9fbd187c4f5635d23fa9ffb17e351e76173c2d3fdf40646e355c4cb314b538de69
13+
DIST gcc-13.2.0-patches-14.tar.xz 46928 BLAKE2B fce23bc5315f35b04a4976550c4b44578944a1b17e40c7553351eeb8a1ef0f3a2538da5a5e1ae6f37b784ff11bbd8a44b8f6eec542be63e34d984dee69e1cd81 SHA512 d7d52bb2915fd89c06b0134bede8db939cadbb1f2dcddf923bee2c3f9f577ff9e5e986b60420d892539edf82867a0d1bd635807814bc618b06a2b37cdaca893a
1114
DIST gcc-13.2.0-patches-7.tar.xz 37064 BLAKE2B 4a8700a8d44bfaa84926f8bfd0da4c5b0c0377f47fc0679456e909f7c9029b9cf1b72c0ba0bc505d9035d5c38e27f7e5b029727eaf2bc7aca417a6be966b2f43 SHA512 f440c97e6782ecb8581d41608e31a648ac426e2d870bc1d171da7794cdeff2fd0546cae0c7214e72fd3a00ead8a5c66f3f633b670b74553a2f3a40378b51f20c
1215
DIST gcc-13.2.0.tar.xz 87858592 BLAKE2B 0034b29d3d6cc05821f0c4253ce077805943aff7b370729dd203bda57d89c107edd657eeddc2fb1e69ea15c7b0323b961f46516c7f4af89a3ccf7fea84701be2 SHA512 d99e4826a70db04504467e349e9fbaedaa5870766cda7c5cab50cdebedc4be755ebca5b789e1232a34a20be1a0b60097de9280efe47bdb71c73251e30b0862a2
1316
DIST gcc-14-20240225.tar.xz 87651536 BLAKE2B 01283581b8684e0dce73b2d9a586e473f3c87753435d905e193816911edc06f9bd2a8d542a95d69f47f1c884124349520f410925b13b7bb51b913e603000d32f SHA512 f424b0935d8fdcf9ff55067467eac20a518a11c2cb14928a47e1a218cde1f4238091f25861daf417d1125c5d5d5465d32fc1b3cb04504b3ca99fe27a7a7d5792
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
https://raw.githubusercontent.com/Homebrew/formula-patches/e923a0cd6c0e60bb388e8a5b8cd1dcf9c3bf7758/gcc/gcc-xcode15-warnings.diff
2+
https://github.com/iains/gcc-13-branch/issues/11
3+
4+
diff --git a/gcc/config/aarch64/darwin.h b/gcc/config/aarch64/darwin.h
5+
index 5609c569dc1..9fcbfa3d777 100644
6+
--- a/gcc/config/aarch64/darwin.h
7+
+++ b/gcc/config/aarch64/darwin.h
8+
@@ -65,10 +65,6 @@ along with GCC; see the file COPYING3. If not see
9+
#define DARWIN_NOPIE_SPEC \
10+
" %<no-pie %<fno-pie %<fno-PIE "
11+
12+
-/* Hack alert - we want the exported cas etc. */
13+
-#undef LIB_SPEC
14+
-#define LIB_SPEC "%{!static:-lSystem} -lgcc"
15+
-
16+
/* Force the default endianness and ABI flags onto the command line
17+
in order to make the other specs easier to write. Match clang in
18+
silently ignoring mdynamic-no-pic */
19+
diff --git a/libgfortran/libgfortran.spec.in b/libgfortran/libgfortran.spec.in
20+
index 367d485c230..058ee5775bf 100644
21+
--- a/libgfortran/libgfortran.spec.in
22+
+++ b/libgfortran/libgfortran.spec.in
23+
@@ -5,4 +5,4 @@
24+
#
25+
26+
%rename lib liborig
27+
-*lib: @LIBQUADSPEC@ @LIBM@ %(libgcc) %(liborig)
28+
+*lib: @LIBQUADSPEC@ @LIBM@ %(liborig)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
From 93f803d53b5ccaabded9d7b4512b54da81c1c616 Mon Sep 17 00:00:00 2001
2+
From: Rainer Orth <[email protected]>
3+
Date: Thu, 17 Aug 2023 10:16:57 +0200
4+
Subject: [PATCH] fixincludes: Update darwin_flt_eval_method for macOS 14
5+
6+
On macOS 14, a guard in <math.h> changed:
7+
8+
@@ -43 +44 @@
9+
-#if __FLT_EVAL_METHOD__ == 0
10+
+#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == -1
11+
@@ -49 +50 @@
12+
-#elif __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ == -1
13+
+#elif __FLT_EVAL_METHOD__ == 2
14+
15+
Therefore the darwin_flt_eval_method fixincludes fix doesn't match any
16+
longer, leading to a large number of testsuite failures like
17+
18+
/private/var/gcc/regression/master/14-gcc/build/gcc/include-fixed/math.h:69:5:
19+
error: #error "Unsupported value of __FLT_EVAL_METHOD__."
20+
21+
where __FLT_EVAL_METHOD__ = 16.
22+
23+
This patch adjusts the fix to allow for both forms.
24+
25+
Tested with make check in fixincludes on x86_64-apple-darwin23.0.0 and
26+
verifying that <math.h> has indeed been fixed as expected.
27+
28+
2023-08-16 Rainer Orth <[email protected]>
29+
30+
fixincludes:
31+
* inclhack.def (darwin_flt_eval_method): Handle macOS 14 guard
32+
variant.
33+
* fixincl.x: Regenerate.
34+
* tests/base/math.h [DARWIN_FLT_EVAL_METHOD_CHECK]: Update test.
35+
---
36+
fixincludes/fixincl.x | 8 ++++----
37+
fixincludes/inclhack.def | 7 ++++---
38+
fixincludes/tests/base/math.h | 1 +
39+
3 files changed, 9 insertions(+), 7 deletions(-)
40+
41+
diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
42+
index 416d2c2e3a4..e52f11d8460 100644
43+
--- a/fixincludes/fixincl.x
44+
+++ b/fixincludes/fixincl.x
45+
@@ -3674,7 +3674,7 @@ tSCC* apzDarwin_Flt_Eval_MethodMachs[] = {
46+
* content selection pattern - do fix if pattern found
47+
*/
48+
tSCC zDarwin_Flt_Eval_MethodSelect0[] =
49+
- "^#if __FLT_EVAL_METHOD__ == 0$";
50+
+ "^#if __FLT_EVAL_METHOD__ == 0( \\|\\| __FLT_EVAL_METHOD__ == -1)?$";
51+
52+
#define DARWIN_FLT_EVAL_METHOD_TEST_CT 1
53+
static tTestDesc aDarwin_Flt_Eval_MethodTests[] = {
54+
@@ -3685,7 +3685,7 @@ static tTestDesc aDarwin_Flt_Eval_MethodTests[] = {
55+
*/
56+
static const char* apzDarwin_Flt_Eval_MethodPatch[] = {
57+
"format",
58+
- "#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16",
59+
+ "%0 || __FLT_EVAL_METHOD__ == 16",
60+
(char*)NULL };
61+
62+
/* * * * * * * * * * * * * * * * * * * * * * * * * *
63+
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
64+
index 45e0cbc0c10..19e0ea2df66 100644
65+
--- a/fixincludes/inclhack.def
66+
+++ b/fixincludes/inclhack.def
67+
@@ -1819,10 +1819,11 @@ fix = {
68+
hackname = darwin_flt_eval_method;
69+
mach = "*-*-darwin*";
70+
files = math.h;
71+
- select = "^#if __FLT_EVAL_METHOD__ == 0$";
72+
+ select = "^#if __FLT_EVAL_METHOD__ == 0( \\|\\| __FLT_EVAL_METHOD__ == -1)?$";
73+
c_fix = format;
74+
- c_fix_arg = "#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16";
75+
- test_text = "#if __FLT_EVAL_METHOD__ == 0";
76+
+ c_fix_arg = "%0 || __FLT_EVAL_METHOD__ == 16";
77+
+ test_text = "#if __FLT_EVAL_METHOD__ == 0\n"
78+
+ "#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == -1";
79+
};
80+
81+
/*
82+
diff --git a/fixincludes/tests/base/math.h b/fixincludes/tests/base/math.h
83+
index 29b67579748..7b92f29a409 100644
84+
--- a/fixincludes/tests/base/math.h
85+
+++ b/fixincludes/tests/base/math.h
86+
@@ -32,6 +32,7 @@
87+
88+
#if defined( DARWIN_FLT_EVAL_METHOD_CHECK )
89+
#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16
90+
+#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == -1 || __FLT_EVAL_METHOD__ == 16
91+
#endif /* DARWIN_FLT_EVAL_METHOD_CHECK */
92+
93+
94+
--
95+
2.39.3
96+

sys-devel/gcc/gcc-13.2.0-r1.ebuild

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Copyright 1999-2022 Gentoo Authors
2+
# Distributed under the terms of the GNU General Public License v2
3+
4+
EAPI=8
5+
6+
TOOLCHAIN_PATCH_DEV="sam"
7+
PATCH_GCC_VER="13.2.0"
8+
PATCH_VER="7"
9+
MUSL_VER="2"
10+
MUSL_GCC_VER="13.2.0"
11+
12+
inherit toolchain
13+
14+
# Don't keyword live ebuilds
15+
if ! tc_is_live && [[ -z ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then
16+
KEYWORDS="~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
17+
fi
18+
19+
# use alternate source for Apple M1 (also works for x86_64)
20+
SRC_URI+=" elibc_Darwin? ( https://raw.githubusercontent.com/Homebrew/formula-patches/3c5cbc8e9cf444a1967786af48e430588e1eb481/gcc/gcc-13.2.0.diff -> gcc-13.2.0-arm64-darwin.patch )"
21+
IUSE+=" bootstrap"
22+
23+
# Technically only if USE=hardened *too* right now, but no point in complicating it further.
24+
# If GCC is enabling CET by default, we need glibc to be built with support for it.
25+
# bug #830454
26+
RDEPEND="!prefix-guest? ( elibc_glibc? ( sys-libs/glibc[cet(-)?] ) )"
27+
DEPEND="${RDEPEND}"
28+
BDEPEND="
29+
amd64? ( >=${CATEGORY}/binutils-2.30[cet(-)?] )
30+
kernel_Darwin? (
31+
|| ( ${CATEGORY}/binutils-apple ${CATEGORY}/native-cctools )
32+
)"
33+
34+
src_prepare() {
35+
# apply big arm64-darwin patch first thing
36+
use elibc_Darwin && eapply "${DISTDIR}"/gcc-13.2.0-arm64-darwin.patch
37+
38+
# make sure 64-bits native targets don't screw up the linker paths
39+
eapply "${FILESDIR}"/gcc-12-no-libs-for-startfile.patch
40+
41+
if [[ ${CHOST} == *-darwin* ]] ; then
42+
# https://bugs.gentoo.org/898610#c17
43+
# kill no_pie patch, it breaks things here
44+
rm "${WORKDIR}"/patch/09_all_nopie-all-flags.patch || die
45+
# fails on Darwin's sources
46+
rm "${WORKDIR}"/patch/81_all_match.p*.patch
47+
fi
48+
# doesn't apply on official and Darwin sources
49+
rm "${WORKDIR}"/patch/31_all_gm2_make_P_var.patch
50+
51+
toolchain_src_prepare
52+
53+
# make it have correct install_names on Darwin
54+
eapply -p1 "${FILESDIR}"/4.3.3/darwin-libgcc_s-installname.patch
55+
56+
if [[ ${CHOST} == powerpc*-darwin* ]] ; then
57+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44107
58+
sed -i -e 's|^ifeq (/usr/lib,|ifneq (/usr/lib,|' \
59+
libgcc/config/t-slibgcc-darwin || die
60+
fi
61+
62+
if [[ ${CHOST} == *-solaris* ]] ; then
63+
# madvise is not available in the compatibility mode GCC uses,
64+
# posix_madvise however, is
65+
sed -i -e 's/madvise/posix_madvise/' gcc/cp/module.cc || die
66+
fi
67+
68+
if [[ ${CHOST} == *-darwin* ]] ; then
69+
use bootstrap && eapply "${FILESDIR}"/${PN}-13-darwin14-bootstrap.patch
70+
eapply "${FILESDIR}"/${PN}-13-darwin14-fix-duplicate-libs.patch
71+
eapply "${FILESDIR}"/${PN}-13-darwin14-math_h.patch
72+
73+
# our ld64 is a slight bit different, so tweak expression to not
74+
# get confused and break the build
75+
sed -i -e 's/grep ld64/grep :ld64/' gcc/configure || die
76+
77+
# rip out specific macos version min
78+
sed -i -e 's/-mmacosx-version-min=11.0//' \
79+
libgcc/config/aarch64/t-darwin \
80+
libgcc/config/aarch64/t-heap-trampoline \
81+
|| die
82+
fi
83+
84+
eapply "${FILESDIR}"/${PN}-13-fix-cross-fixincludes.patch
85+
eapply_user
86+
}
87+
88+
src_configure() {
89+
local myconf=()
90+
case ${CTARGET}:" ${USE} " in
91+
powerpc*-darwin*)
92+
# bug #381179
93+
filter-flags "-mcpu=*" "-mtune=*"
94+
# bug #657522
95+
# A bug in configure checks whether -no-pie works, but the
96+
# compiler doesn't pass -no-pie onto the linker if -fno-PIE
97+
# isn't passed, so the configure check always finds -no-pie
98+
# is accepted. (Likewise, when -fno-PIE is passed, the
99+
# compiler passes -no_pie onto the linker.)
100+
# Since our linker doesn't grok this, avoid above checks to
101+
# be run
102+
# NOTE: later ld64 does grok -no_pie, not -no-pie (as checked)
103+
export gcc_cv_c_no_fpie=no
104+
export gcc_cv_no_pie=no
105+
;;
106+
*-darwin20)
107+
# use sysroot with the linker, #756160
108+
export gcc_cv_ld_sysroot=yes
109+
;;
110+
*-solaris*)
111+
# todo: some magic for native vs. GNU linking?
112+
myconf+=( --with-gnu-ld --with-gnu-as --enable-largefile )
113+
# Solaris 11 defines this in its headers, but that causes a
114+
# mismatch whilst compiling, bug #657514
115+
#export ac_cv_func_aligned_alloc=no
116+
#export ac_cv_func_memalign=no
117+
#export ac_cv_func_posix_memalign=no
118+
;;
119+
i[34567]86-*-linux*:*" prefix "*)
120+
# to allow the linux-x86-on-amd64.patch become useful, we need
121+
# to enable multilib, even if there is just one multilib option.
122+
myconf+=( --enable-multilib )
123+
if [[ ${CBUILD:-${CHOST}} == "${CHOST}" ]]; then
124+
# we might be on x86_64-linux, but don't do cross-compile, so
125+
# tell the host-compiler to really create 32bits (for stage1)
126+
# (real x86-linux-gcc also accept -m32).
127+
append-flags -m32
128+
fi
129+
;;
130+
esac
131+
132+
if [[ ${CHOST} == *-darwin ]] ; then
133+
# GCC' Darwin fork enables support for "-stdlib=libc++"
134+
# unconditionally, and its default include path is invalid,
135+
# causing package build failures due to missing header.
136+
# But more importantly, it breaks the assumption of many build
137+
# scripts and changes their CFLAGS and linking behaviors. The
138+
# situation is tricky and needs careful considerations.
139+
# For now, just disable support for "-stdlib=libc++".
140+
myconf+=( --with-gxx-libcxx-include-dir=no )
141+
fi
142+
143+
# Since GCC 4.1.2 some non-posix (?) /bin/sh compatible code is used, at
144+
# least on Solaris, and AIX /bin/sh is way too slow,
145+
# so force it to use $BASH (that portage uses) - it can't be EPREFIX
146+
# in case that doesn't exist yet
147+
export CONFIG_SHELL="${CONFIG_SHELL:-${BASH}}"
148+
toolchain_src_configure "${myconf[@]}"
149+
}

0 commit comments

Comments
 (0)