# gcc1320/cfg - "Build" settings for package #--------------------------------------------------------------------- [technotes] 1. "gcc1320" builds "gcc" 13.2.0. Note: This point applies to the "gcc/glibc" copy of this distro. Cop- ies that are based on "clang" and/or "musl" instead will not follow the instructions listed here. Documentation for such copies remains to be added. #--------------------------------------------------------------------- 2. Presently, "gcc1320" (gcc 13.2.0) is needed, and used, to build it- self. If you're porting this distro to a new architecture, you may be able to use a lower-numbered "gcc" release to bootstrap this package. The details are beyond the scope of this discussion. If you use "gcc1320" to rebuild itself, it's recommended that you back-up the package first. Failure to do so may "brick" this distro from a "gcc" standpoint. #--------------------------------------------------------------------- 3. If you'd like to make a newer release of "gcc" the default 'C'/C++ compiler, this is possible but tricky. It should only be attempted by "gcc" and CLI experts. The first step is to make a back-up copy of the system. This is opt- ional. However, the "build" procedure may "brick" the system. So, a back-up is advisable. The procedure used is as follows: a. Create a new "src"-tree directory for the new release of "gcc". b. Copy this "cfg" file to that directory. c. Go to that directory. d. Edit the new "cfg" file. Modify the source tarball download URL and/or procedure as necessary. Replace the source tarball with the new one. e. Update the patches as necessary. f. Build the new package. g. Execute a command similar to the following, but replace "gcc- 1111" and "gcc2222" with the package names for the old and new master "gcc" packages: gcc-update-master gcc1111 gcc2222 If there is no old master "gcc" package, specify the new one twice. h. Try to compile a "Hello World" test program directly. Re- builds of simple 'C' packages (though not C++ packages) in the package system are expected to work as well. i. If the new compiler doesn't work out, repeat the command from step (8) with the arguments reversed: gcc-update-master gcc2222 gcc1111 Then stop here. j. Rebuild some packages as follows: j1. Delete the package "built" flags for these packages and for packages that are "stricted" by them: autoconf automake libtool ac213 am185 autoconf-archive actools For example: cd /$LACARCH/status/build rm -fr autoconf automake libtool ac213 am185 autoconf-archive rm -fr actools stricted ; rm -fr `stricted` Repeat the last line until no more "stricted" packages are listed. j2. Execute: makelac actools k. Create and build a new "glibc-*" package as explained in the "cfg" file for the current such package. l. Execute: cd $PRODTREE/glibc/lib/ rm -f libgcc_s.so* cp -a $PRODTREE/gcc/lib/libgcc_s.so* . rm -f libstdc++.so* cp -a $PRODTREE/gcc/lib/libstdc++.so* . Or you can just use a command similar to the following in- stead. Substitute the new "gcc" package name for "gcc2222" here. In other words, specify the new package twice. gcc-update-master gcc2222 gcc2222 Note: The preceding alternate command will take longer to run than the suggested remove-copy sequence. m. Modify the "cfg" file for the "gfortran" package so that it depends on the new "gcc" as opposed to the one. n. If the new "gcc" is 64-bits, build the 32-bit version of the same "gcc" package. Failure to do this step will cause the 64-bit copy's "-m32" switch to stop working. This will break kernel builds. To address this step, boot into the appropriate 32-bit distro and build the same "gcc-####" package there. Execute the appropriate steps from this list. Then boot back into the 64- bit distro in use. o. Build a new copy of the Linux kernel using the new "gcc". p. Reboot. There is a potential for brick-age at this point. This may happen if any packages build kernel modules that are needed to boot. This situation should be avoided if possible. q. Delete the "/glibc##/status/build/..." files for all packages that build kernel modules. Substitute the appropriate number, 32 or 64, for "##" here. r. Rebuild any packages whose statuses were reset in steps (3j1) or (3q) above. Remarks from BLFS: If you are upgrading GCC from any other version prior to (the current one), then you must be careful (about) compiling 3rd party kernel mod- ules. You should ensure that the kernel and all its native modules are (compiled) using the same version of GCC that you use to build the 3rd party (modules). #--------------------------------------------------------------------- 4. While this package is being built, no other builds should be done. #--------------------------------------------------------------------- 5. The executables stored in this package's main "bin" directory shouldn't be compressed (i.e., using "upx" or a similar program). If this is done, the distro's compiler wrapper won't be able to operate correctly. It's also a bad idea to compress executables stored in this package's other directories. In theory, this should work. In practice, it pro- duces a slow compiler. #--------------------------------------------------------------------- 6. List of useful standards switches (partial): -std=gnu++14 -std=gnu++98 -std=gnu++1z -std=c++1z #--------------------------------------------------------------------- [buildtimes] # Some of these times are actually for builds of "gcc" 10.3.0 but # should be close enough to "gcc" 13.2.0 build times for our purpos- # es. 00.21 hours (or 012.78 minutes) - HP EliteBook 8560w 32GB RAM 00.23 hours (or 013.87 minutes) - 2021 L.A. dedi box: 6x2 CPU 32GB RAM 00.24 hours (or 014.62 minutes) - 2023 dedi Xeon E3-1200 v3 4x2 32GB RAM 00.28 hours (or 017.05 minutes) - ThinkPad E540 i7 4x2 16GB RAM 00.39 hours (or 023.63 minutes) - ThinkPad W530 i7 4x2 32GB RAM 00.73 hours (or 043.58 minutes) - ThinkPad W530 i7 4x2 32GB RAM using a 64-bit kernel and 32-bit distro #--------------------------------------------------------------------- [settings] altpkg = yes configure = none # Handled during "build" stage license = See "license*.txt" in installed tree licfile = COPYING nodebug = yes nosyslinks = yes # Disable normal integration purge = no # This is a critical package tmpsize = 934M unpack = relaxed #--------------------------------------------------------------------- [depends] actools:forward bison:forward chrpath:forward flex:forward gawk:forward grep:forward none #--------------------------------------------------------------------- [build] #--------------------------------------------------------------------- # Initial setup. GCCTRIPLE=13.2.0 PATH=$PRODTREE/gcc1040/bin:$PATH #--------------------------------------------------------------------- if [ "x$LACARCH" == "x" ]; then echo Error: LACARCH not set exit 1 fi if [ "x$LACSYSTREE" == "x" ]; then echo Error: LACSYSTREE not set exit 1 fi sed -e 's@__META_SYSTREE__@$LACSYSTREE@' \ -i gcc/cppdefault.cc gcc/collect2.cc gcc/config/i386/linux64.h date && echo Start echo Compiling with: hash gcc g++ gcc --version rm -fr /usr/lib64/*.a mkdir -p /usr/lib64 for x in libc.so libpthread.so do FX=/usr/lib64/$x if [ -f $FX ]; then echo Error: $FX exists exit 1 fi done #--------------------------------------------------------------------- SUPLIB=$PKGDIR_SPECIAL/suplib tar Jxf $SUPLIB/gmp-6.2.1.tar.xz tar Jxf $SUPLIB/isl-0.24.tar.xz tar zxf $SUPLIB/mpc-1.3.1.tar.gz tar Jxf $SUPLIB/mpfr-4.2.0.tar.xz mv gmp{-6.2.1,} mv isl{-0.24,} mv mpc{-1.3.1,} mv mpfr{-4.2.0,} #--------------------------------------------------------------------- # This step is from BFLS and/or Slackware. # sed -e '/m64=/s/lib64/lib/' \ -i gcc/config/i386/t-linux64 # From BLFS: # sed -e 's@\./fixinc\.sh@-c true@' \ -i gcc/Makefile.in #--------------------------------------------------------------------- echo `date` treetextsub start treetextsub \ --pattern="/usr/lib64" \ --newtext="$LACSYSTREE/lib" --keeptimes treetextsub \ --pattern="/usr/lib" \ --newtext="$LACSYSTREE/lib" --keeptimes echo `date` treetextsub done #--------------------------------------------------------------------- BINDIR=$PKGDIR_PROD/bin LIBDIR=$PKGDIR_PROD/lib mkdir -p $BINDIR $LIBDIR #--------------------------------------------------------------------- # The "chown/chmod" commands used here are based partly on Slackware # recommendations. chown -R 0.0 . find . -perm 777 -exec chmod 755 {} \; find . -perm 775 -exec chmod 755 {} \; find . -perm 754 -exec chmod 755 {} \; # Skip this one. It's too slow for some releases of gcc: # # find . -perm 664 -print -exec chmod 644 {} \; #--------------------------------------------------------------------- SDIR=`pwd` cd .. mkdir obj cd obj XDIR=`pwd` #--------------------------------------------------------------------- export FORCEPATHMAX=yes PREFIX=$PKGDIR_PROD mkdir -p $PREFIX/lib export TEMPDIR=/ram export TMP=$TEMPDIR export TMPDIR=$TEMPDIR mkdir -p $TEMPDIR #--------------------------------------------------------------------- # "configure" step. echo `date` configure start GCCLANG="c,c++,fortran,objc,obj-c++" PATH=`pwd`:$PATH export LACNOWERROR=no bash ../gcc*/configure \ --prefix=$PREFIX \ --build=$LACARCHBUILD \ --host=$LACARCHHOST \ \ --disable-bootstrap \ --disable-libmpx \ --disable-libstdcxx-pch \ --disable-multilib \ --disable-nls \ \ --enable-c99 \ --enable-checking=release \ --enable-clocale=gnu \ --enable-languages=$GCCLANG \ --enable-libgomp \ --enable-lto=no \ --enable-shared \ --enable-static \ --enable-threads=posix \ --enable-__cxa_atexit \ \ --libexecdir=$PREFIX/lib echo `date` configure done #--------------------------------------------------------------------- # Not used under normal circumstances: # # --with-gmp=$PREFIX \ # --with-mpc=$PREFIX \ # --with-mpfr=$PREFIX \ # --with-local-prefix=$PREFIX \ # --with-build-sysroot=$PREFIX \ # --with-sysroot=$PREFIX \ #--------------------------------------------------------------------- LACLIBTOOL=`which libtool` for x in $SDIR $XDIR do cd $x for ltfile in `find . -type f -name libtool` do # These commands may be needed for cross-compilation: # rm $ltfile # cp -p $LACLIBTOOL $ltfile X=42 # Just a placeholder command done done #--------------------------------------------------------------------- GLIBCDIR=$LACSYSTREE/toolchain/lib ALIBCDIR=$PRODTREE/glibc/lib if [ -f "$ALIBCDIR/crti.o" ]; then GLIBCDIR=$ALIBCDIR fi if [ \! -f "$GLIBCDIR/crti.o" ]; then echo "Error: glibc crtX.o setup isn't as expected" exit 1 fi pushd $GLIBCDIR for x in /lib /usr/lib /usr/local/lib $LACSYSTREE/lib do mkdir -p $x for crto in *crt*.o do ln -nsf $GLIBCDIR/$crto $x/ done done popd #--------------------------------------------------------------------- cd / sync #--------------------------------------------------------------------- date && echo 1st make start cd $XDIR smpmake all-target-libgomp || make all-target-libgomp smpmake || smpmake || make date && echo 1st make done #--------------------------------------------------------------------- # "make install" step. date && echo make install start make install || make install || make install date && echo make install done for x in /lib /usr/lib /usr/local/lib $LACSYSTREE/lib do rm -f $x/crt*.o done #--------------------------------------------------------------------- date && echo Post-install cleanup # install -v -dm755 $LACSYSTREE/lib/bfd-plugins # ln -sfv \ # ../../libexec/gcc/$(gcc -dumpmachine)/$GCCTRIPLE/liblto_plugin.so \ # $LACSYSTREE/lib/bfd-plugins/ #--------------------------------------------------------------------- cd $BINDIR (strip -p * || true) 2> /dev/null rm -fr cc wrapcc sed -e "s@__META_SYSTREE__@$LACSYSTREE@g" \ -e "s@__META_PKGNAME__@$EXEWORD@g" \ < $PKGDIR_SPECIAL/altcc \ > cc chmod 755 cc sed -e "s@__META_LACARCH__@$LACARCH@g" \ < /laclin/sysutil/toolchain/wrapcc.txt \ > wrapcc chmod 755 wrapcc #--------------------------------------------------------------------- # The "for"-loop below tries to do the following: # # (1) rename 'C' compiler ELF executables that are not already named # "*.bin" to corresponding "*.bin" names # # (2) hard-link the original 'C' compiler executable names to a wrap- # per script that was installed previously # "trueifexe" is a distro-specific utility script. echo trueifexe loop start for x in c++ g++ gcc *-c++ *-g++ *-gcc *-gcc-[0-9.]* do if [ -f "$x.bin" ]; then trueifexe "$x.bin" || (echo trueifexe error-1: $x ; exit 1) fi z=`echo $x | sed 's/\.bin//'` if [ "@$x" == "@$z" ]; then # Doesn't end with ".bin" trueifexe $x && rm -fr $x.bin && mv $x $x.bin ln -f wrapcc $x trueifexe "$x.bin" || (echo trueifexe error-2: $x ; exit 1) else trueifexe "$x" || (echo trueifexe error-3: $x ; exit 1) fi done echo trueifexe loop end #--------------------------------------------------------------------- mkdir -p $SYSTREE/usr/bin/ ln -nsf $BINDIR/cpp $SYSTREE/usr/bin/ rm -f $LIBDIR/libstdc++.so.*-gdb.py #--------------------------------------------------------------------- # This is needed by some programs. It may need some work. cd $PREFIX sed -e 's|#include_next|#include|' \ -i `find . -type f -name cstdlib` \ `find . -type f -name cmath` \ `find . -type f -name std_abs.h` rm -fr `find . -type d -name include-fixed` #--------------------------------------------------------------------- # Wrap it up. cd $LACSYSTREE/bin for x in cc c++ gcc g++ do ln -nsf $PRODTREE/gcc/bin/$x . done date && echo Done #--------------------------------------------------------------------- # Original URLs. These URLs were valid at one point, but may have died # since then. If you download newer versions of tarballs [etc.], don't # delete the original versions, as you may not be able to replace # them. [urls] url_debian = tbd url_home = http://www.gnu.org/software/gcc/ url_tarball = ftp://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.xz url_lfs = http://www.linuxfromscratch.org/lfs/view/\ stable/chapter06/gcc.html #--------------------------------------------------------------------- [history] 240225 Added package. Started with 13.2.0.