Add GCC 12

The latest version of GCC.
And with this, the glibc-musl-gcc toolchain is complete.

A variety of modern features (default PIE SSP) are enabled.
This commit is contained in:
fosslinux 2023-04-18 10:59:13 +10:00
parent ac4685e886
commit 6fb676c8c2
10 changed files with 255 additions and 1 deletions

View File

@ -1157,3 +1157,24 @@ mistaken plugin loading support). Other modern features are added, including;
* threaded linking
* 64-bit linking on 32-bit x86
* the modern, rewritten gold linker used by some distributions
gcc 12.2.0
==========
This is the most recent version of GCC. With this version of GCC, the
final gcc-binutils-musl toolchain is complete. The focus of further builds
shifts to rebuilds for correctness, cleanup and preparation for downstream
consumption.
In line with this, a variety of modern features + minor build changes are used
to ensure the compiler is suitable for downstream consumption;
* A full internal GCC bootstrap is used to ensure there are no lagging
historical problems.
* PIE and SSP are enabled by default, as is done on every major modern Linux
distribution.
* libssp is disabled and handed off to the libc (done by many modern Linux
distributions). libssp in GCC is very broken and glibc-centric - it should
really be handled by the libc, which is what most distributions do.
* LTO now fully functions correctly, despite both the linker and the compiler
being static binaries.

View File

@ -50,6 +50,7 @@ d7b7453ad400eac1ba39f99971afdc392cb8a92c557ef5d6fd9fa2625124de4a ed-1.4_0.tar.b
5ff7fbe16b55563719b108260bd6a34ebabab0465d758ca98cba522932532e45 gawk-3.0.4_0.tar.bz2
6de1c1380026ef9948387e665610185b6014f47a80453177a6c81898c95cbbd3 gc-8.0.4_0.tar.bz2
cb1aca35878f7c53e7dc96294ceca2ce3c72cf89359fe2bec46336d5f0849387 gcc-10.4.0_0.tar.bz2
0c58c12e71c8571f9c958dbebf53677cb4612eaa5cfd2aaa9ed7a1b76a081dae gcc-12.2.0_0.tar.bz2
b09580c3972ff4e5f6e624bdc83d5328ce017422e0b92a7c170b51b6f04a47d2 gcc-4.0.4_0.tar.bz2
58d0d431bb2e96a273965b5e7aa760fb6961a7f7f2fd98ef5fc5a6b7b44bc989 gcc-4.0.4_1.tar.bz2
a2301d8dbbfbfcdd18444f01848e8e4366780281009640acbd3af0fab9b11aea gcc-4.7.4_0.tar.bz2

View File

@ -84,7 +84,6 @@ src_configure() {
mkdir build
cd build
# -rdynamic is required for plugin support in a static ld
LDFLAGS="-static" \
../configure \
--prefix="${PREFIX}" \

101
sysc/gcc-12.2.0/gcc-12.2.0.sh Executable file
View File

@ -0,0 +1,101 @@
# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
#
# SPDX-License-Identifier: GPL-3.0-or-later
src_prepare() {
default
# Remove vendored zlib
rm -r zlib/
# Regen gperf file (because GCC's make rules suck)
rm gcc/cp/cfns.h
# (taken directly from gcc/cp/Make-lang.in)
gperf -o -C -E -k '1-6,$' -j1 -D -N 'libc_name_p' -L C++ \
gcc/cp/cfns.gperf --output-file gcc/cp/cfns.h
# Regenerate autogen stuff
autogen Makefile.def
pushd fixincludes
./genfixes
popd
# Regenerate autotools
# configure
find . -name configure | sed 's:/configure::' | while read d; do
pushd "${d}"
AUTOMAKE=automake-1.15 ACLOCAL=aclocal-1.15 autoreconf-2.69 -fiv
popd
done
# Because GCC is stupid, copy depcomp back in
cp "${PREFIX}/share/automake-1.15/depcomp" .
# Makefile.in only
local BACK="${PWD}"
find . -type d \
-exec test -e "{}/Makefile.am" -a ! -e "{}/configure" \; \
-print | while read d; do
d="$(readlink -f "${d}")"
cd "${d}"
# Find the appropriate configure script for automake
while [ ! -e configure ]; do
cd ..
done
automake-1.15 -fai "${d}/Makefile"
cd "${BACK}"
done
# Remove bison generated files
rm intl/plural.c
# Remove flex generated files
rm gcc/gengtype-lex.cc
# Remove unused generated files
rm -r libgfortran/generated
# intl/ Makefile is a bit broken because of new gettext
sed -i 's/@USE_INCLUDED_LIBINTL@/no/' intl/Makefile.in
# Regenerate crc table in libiberty/crc32.c
pushd libiberty
sed -n -e '38,65p' crc32.c > crcgen.c
gcc -o crcgen crcgen.c
head -n 69 crc32.c > crc32.c.new
./crcgen >> crc32.c.new
tail -n +138 crc32.c >> crc32.c.new
mv crc32.c.new crc32.c
popd
# Remove docs/translation
find . -name "*.gmo" -delete
find . -name "*.info" -delete
}
src_configure() {
mkdir build
cd build
LDFLAGS="-static" \
../configure \
--prefix="${PREFIX}" \
--libdir="${LIBDIR}" \
--build=i386-unknown-linux-musl \
--target=i386-unknown-linux-musl \
--host=i386-unknown-linux-musl \
--enable-bootstrap \
--enable-static \
--enable-default-pie \
--enable-default-ssp \
--disable-plugins \
--disable-libssp \
--disable-libsanitizer \
--program-transform-name= \
--enable-languages=c,c++ \
--with-system-zlib \
--disable-multilib \
--enable-threads=posix
}
src_compile() {
make "${MAKEJOBS}" BOOT_LDFLAGS="-static"
}

View File

@ -0,0 +1,43 @@
SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
SPDX-FileCopyrightText: 2022 Thomas Schwinge <thomas@codesourcery.com>
SPDX-License-Identifier: GPL-3.0-or-later
Backport of commit 25861cf3a88a07c8dca3fb32d098c0ad756bbe38
====
With that, we may then run plain 'autoreconf' for all of GCC's subpackages,
instead of for some of those (that don't use Automake) manually having to run
the applicable combination of 'aclocal', 'autoconf', 'autoheader'.
See also 'AC_CONFIG_MACRO_DIRS'/'AC_CONFIG_MACRO_DIR' usage elsewhere.
diff --git gcc/configure.ac gcc/configure.ac
index e1ef2ecf026..45bf7560e6f 100644
--- gcc/configure.ac
+++ gcc/configure.ac
@@ -25,6 +25,7 @@
AC_INIT
AC_CONFIG_SRCDIR(tree.cc)
+AC_CONFIG_MACRO_DIRS([../config] [..])
AC_CONFIG_HEADER(auto-host.h:config.in)
gcc_version=`cat $srcdir/BASE-VER`
diff --git libobjc/configure libobjc/configure
index a8fdc643349..6da20b8e4ff 100755
diff --git libobjc/configure.ac libobjc/configure.ac
index f8f577cfbef..6f58a45d4cb 100644
--- libobjc/configure.ac
+++ libobjc/configure.ac
@@ -20,6 +20,7 @@
AC_INIT(package-unused, version-unused,, libobjc)
AC_CONFIG_SRCDIR([objc/objc.h])
+AC_CONFIG_MACRO_DIRS([../config] [..])
GCC_TOPLEV_SUBDIRS
# We need the following definitions because AC_PROG_LIBTOOL relies on them
--
2.31.1

View File

@ -0,0 +1,34 @@
SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
SPDX-FileCopyrightText: 2022 Simon Marchi <simon.marchi@efficios.com>
SPDX-License-Identifier: GPL-3.0-or-later
Backport of commit 1f237573caa5cf72218ea31fe78eb3983a717ca6
====
Add
AC_CONFIG_MACRO_DIRS([../config])
So that just running:
$ autoreconf -vf
... does the right thing (no need to specify -I ../config).
diff --git libiberty/configure.ac libiberty/configure.ac
index 84a7b378fad..28d996f9cf7 100644
--- libiberty/configure.ac
+++ libiberty/configure.ac
@@ -2,6 +2,7 @@ dnl Process this file with autoconf to produce a configure script
AC_INIT
AC_CONFIG_SRCDIR([xmalloc.c])
+AC_CONFIG_MACRO_DIRS([../config])
# This works around the fact that libtool configuration may change LD
# for this particular configuration, but some shells, instead of
--
2.31.1

View File

@ -0,0 +1,35 @@
SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
SPDX-FileCopyrightText: 2020 Timo Teräs <timo.teras@iki.fi>
SPDX-License-Identifier: GPL-3.0-or-later
The original motivation from this patch from Alpine Linux:
Subject: [PATCH] Alpine musl package provides libssp_nonshared.a. We link to
it unconditionally, as otherwise we get link failures if some objects are
-fstack-protector built and final link happens with -fno-stack-protector.
This seems to be the common case when bootstrapping gcc, the piepatches do
not seem to fully fix the crosstoolchain and bootstrap sequence wrt.
stack-protector flag usage.
Which matches precisely the problem when compiling GCC with --enable-bootstrap
in live-bootstrap.
---
gcc/gcc.cc | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git gcc/gcc.cc gcc/gcc.cc
index cc99d0b7aa1..c60a75371f8 100644
--- gcc/gcc.cc
+++ gcc/gcc.cc
@@ -1004,8 +1004,7 @@ proper position among the other output files. */
#ifndef LINK_SSP_SPEC
#ifdef TARGET_LIBC_PROVIDES_SSP
-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
- "|fstack-protector-strong|fstack-protector-explicit:}"
+#define LINK_SSP_SPEC "-lssp_nonshared"
#else
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
"|fstack-protector-strong|fstack-protector-explicit" \

View File

@ -0,0 +1,17 @@
SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
SPDX-License-Identifier: GPL-3.0-or-later
In new gettext external is required for AM_GNU_GETTEXT.
--- intl/configure.ac 2023-02-07 18:43:58.989786230 +1100
+++ intl/configure.ac 2023-02-07 18:43:02.182632631 +1100
@@ -4,7 +4,7 @@
AC_CONFIG_HEADER(config.h)
AC_CONFIG_MACRO_DIR(../config)
AM_GNU_GETTEXT_VERSION(0.12.1)
-AM_GNU_GETTEXT([], [need-ngettext])
+AM_GNU_GETTEXT([external], [need-ngettext])
# This replaces the extensive use of DEFS in the original Makefile.in.
AC_DEFINE(IN_LIBINTL, 1, [Define because this is libintl.])

1
sysc/gcc-12.2.0/sources Normal file
View File

@ -0,0 +1 @@
http://ftp.gnu.org/gnu/gcc/gcc-12.2.0/gcc-12.2.0.tar.xz e549cf9cf3594a00e27b6589d4322d70e0720cdd213f39beb4181e06926230ff

View File

@ -124,6 +124,8 @@ build gcc-10.4.0
build binutils-2.38 pass2.sh
build gcc-12.2.0
if [ "$FORCE_TIMESTAMPS" = True ] ; then
echo 'Forcing all files timestamps to be 0 unix time.'
canonicalise_all_files_timestamp