LOL... after falling asleep playing games, around 6'ish I started working on my GNU toolchain in Crux, to bring glibc, binutils and gcc up to the same commits as Arch. I didn't anticipate the problems I was going to have because I removed their 32 bit glibc that came with the base system (after the fact, I don't use anything lib32 and initially forgot that it was installed). It was only there because their gcc was built with multi-arch, as was my first 15.2.1 upgrade because the old lib32 glibc was still there. That meant my new binutils built without multilib support (good), but then my gcc wouldn't compile. I just have to have things my way... no default PIE and stack protector output (SSP), no Intel CET (I disable that in binutils, glibc and gcc). I can't stand distro dogfood. Stuff like PIE executables and such should be up to individual projects to turn on appropriately. Opt-in.
I had removed --enable-multiarch in anticipation but I found out it's also necessary to --disable-multilib which is implied by that. It failed on including a binutils header, /usr/include/gnu/stubs-32.h which of course wasn't present. OK... start the build again, should be fine now, but I kept missing shit in the Pkgfile, like $PKG/usr/lib{,32} which means do whatever in both lib and lib32. Any failure causes it to delete the Work directory and you have to start the pkgmk over.
In total, because of my mental state, I think it took me 4 tries to get this right. I'd like fix something, make sure there are no more instances of it, run my eyes through the rest and miss different things, start pkgmk again then start watching some youtube shorts while waiting. It kept me up past 9 AM, and of course THEN I couldn't get to sleep. I should have left it for today
I also made it harder on myself by changing $version to reflect the revisions. It's a git checkout rolled into a tarball that I named so $name-$version.tar.xz would work out, while the directory name is "gcc" instead of "gcc-$version". So I had to hard code some 15.2.1 shit that I'll have to remember next time that changes.
The gcc-4.7.3-multilib-dirs.patch is still necessary to correct some "lib64" paths in certain places (and some are changed with sed).
I debated whether or not to change --with-pkgversion="CRUX-x86_64-multilib" but decided to leave that in case something else in the distro cares about that string, even though the compiler isn't multilib anymore (I've never built anything 32 bit on this system). Ahh well, it's simplified now.
Code: Select all
# Description: The GNU Compiler Collection
# URL: https://gcc.gnu.org
# Maintainer: CRUX System Team, core-ports at crux dot nu
# Depends on: libmpc zstd
name=gcc
version=15.2.1-r447
release=1
source=($name-$version.tar.xz $name-4.7.3-multilib-dirs.patch)
build() {
patch -d gcc -p1 -i $SRC/gcc-4.7.3-multilib-dirs.patch
sed -e '/m64=/s/lib64/lib/' -i $SRC/gcc/gcc/config/i386/t-linux64
# pipe fails tests
CFLAGS=${CFLAGS/-pipe/}
CXXFLAGS=${CXXFLAGS/-pipe/}
mkdir build
cd build
../gcc/configure \
--prefix=/usr \
--libexecdir=/usr/lib \
--enable-threads=posix \
--with-build-config=bootstrap-lto \
--with-linker-hash-style=gnu \
--with-system-zlib \
--enable-languages=c,c++,lto \
--enable-stage1-languages=c,lto \
--enable-link-serialization=1 \
--enable-linker-build-id \
--enable-gnu-indirect-function \
--enable-__cxa_atexit \
--enable-clocale=gnu \
--enable-shared \
--enable-lto \
--enable-plugin \
--disable-cet \
--with-pkgversion="CRUX-x86_64-multilib" \
--with-x=no \
--disable-fixincludes \
--disable-multilib \
--disable-nls
make -O -j24 STAGE1_CFLAGS="$CFLAGS" \
BOOT_CFLAGS="$CFLAGS" \
BOOT_LDFLAGS="$LDFLAGS" \
LDFLAGS_FOR_TARGET="$LDFLAGS" \
bootstrap
make -j24 DESTDIR=$PKG install
install -d $PKG/lib
ln -sf ../usr/bin/cpp $PKG/lib/cpp
ln -sf gcc $PKG/usr/bin/cc
ln -sf g++ $PKG/usr/bin/c++
################# Don't forget to edit these hard coded versions ################
rm -r $PKG/usr/share/{info,gcc-15.2.1}
rm -r $PKG/usr/bin/*-linux-gnu-*
rm -r $PKG/usr/lib/gcc/*/15.2.1/{install-tools,include-fixed}
for D in lib; do
install -d -m 0755 $PKG/usr/share/gdb/auto-load/usr/${D}
mv $PKG/usr/${D}/libstdc++.so.*-gdb.py $PKG/usr/share/gdb/auto-load/usr/${D}
done
mkdir $PKG/usr/lib/bfd-plugins
ln -sfv ../../lib/gcc/$($PKG/usr/bin/gcc -dumpmachine)/15.2.1/liblto_plugin.so \
$PKG/usr/lib/bfd-plugins/
sed -i "s|-L$SRC[^ ]* ||g" $PKG/usr/lib/{libstdc++.la,libsupc++.la}
}