Skip to content

Commit

Permalink
Improve GCC builds
Browse files Browse the repository at this point in the history
- Move to GCC 13.2.0
- Move to GDB 14.2
- Do not use GCC 7.3.0 as default, since now AliRoot it's built
  with its own default.
- Add support for CCACHE. While disabled by default it can be enabled
  by passing CCACHE_DISABLE=false as environment variable.
  • Loading branch information
ktf committed Apr 29, 2024
1 parent 5cca9fc commit bf6acf1
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 27 deletions.
3 changes: 0 additions & 3 deletions defaults-ali.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ overrides:
- Vc
- ZeroMQ
- JAliEn-ROOT
GCC-Toolchain:
version: v12.2.0-alice1
tag: v12.2.0-alice1
cgal:
version: 4.12.2
fastjet:
Expand Down
3 changes: 0 additions & 3 deletions defaults-o2-dataflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ disable:
- OpenSSL
- curl:(?!osx.*)
overrides:
GCC-Toolchain:
version: "v12.2.0-alice1"
tag: "v12.2.0-alice1"
Python-modules-list:
env:
PIP_BASE_REQUIREMENTS: |
Expand Down
3 changes: 0 additions & 3 deletions defaults-o2-epn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ overrides:
- Vc
- ZeroMQ
- JAliEn-ROOT
GCC-Toolchain:
version: v12.2.0-alice1
tag: v12.2.0-alice1
cgal:
version: 4.12.2
fastjet:
Expand Down
3 changes: 0 additions & 3 deletions defaults-o2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ overrides:
- Vc
- ZeroMQ
- JAliEn-ROOT
GCC-Toolchain:
version: v12.2.0-alice1
tag: v12.2.0-alice1
cgal:
version: 4.12.2
fastjet:
Expand Down
170 changes: 155 additions & 15 deletions gcc-toolchain.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package: GCC-Toolchain
version: "%(tag_basename)s"
tag: v7.3.0-alice2
tag: v13.2.0-alice1
source: https://github.com/alisw/gcc-toolchain
prepend_path:
"LD_LIBRARY_PATH": "$GCC_TOOLCHAIN_ROOT/lib64"
"PATH": "$GCC_TOOLCHAIN_ROOT/libexec/bin"
build_requires:
- "autotools:(slc6|slc7)"
- yacc-like
Expand All @@ -25,9 +26,9 @@ prefer_system_check: |
#error "System's GCC cannot be used: we need at least ($MIN_GCC_VERSION/1e4), while we intend to go for GCC $REQUESTED_VERSION. We'll compile our own version."
#endif
EOF
env:
CCACHE_CONFIGPATH: $GCC_TOOLCHAIN_ROOT/etc/ccache.conf
---
#!/bin/bash -e
unset CXXFLAGS
unset CFLAGS
Expand All @@ -49,6 +50,58 @@ esac
rsync -a --exclude='**/.git' --delete --delete-excluded "$SOURCEDIR/" ./
# Build a very basic CMake, to compile ccache and nothing else
# in case we manage, we build ccache
if [ -e ccache ]; then
mkdir -p build-cmake
pushd build-cmake
cat > build-flags.cmake <<- EOF
# Disable Java capabilities; we don't need it and on OS X might miss the
# required /System/Library/Frameworks/JavaVM.framework/Headers/jni.h.
SET(JNI_H FALSE CACHE BOOL "" FORCE)
SET(Java_JAVA_EXECUTABLE FALSE CACHE BOOL "" FORCE)
SET(Java_JAVAC_EXECUTABLE FALSE CACHE BOOL "" FORCE)
# SL6 with GCC 4.6.1 and LTO requires -ltinfo with -lcurses for link to succeed,
# but cmake is not smart enough to find it. We do not really need ccmake anyway,
# so just disable it.
SET(BUILD_CursesDialog FALSE CACHE BOOL "" FORCE)
EOF
$SOURCEDIR/cmake/bootstrap --prefix=$BUILDDIR/bootstrap-cmake \
--no-debugger \
--no-qt-gui \
--init=build-flags.cmake \
${JOBS:+--parallel=$JOBS}
make ${JOBS+-j $JOBS}
make install/strip
popd

mkdir build-ccache-bootstrap
pushd build-ccache-bootstrap
$BUILDDIR/bootstrap-cmake/bin/cmake -S ../ccache \
-DENABLE_DOCUMENTATION=OFF \
-DENABLE_TESTING=OFF \
-DCMAKE_INSTALL_PREFIX="$BUILDDIR/bootstrap-ccache"
make ${JOBS:+-j $JOBS} install
popd
# Notice how we configure CCACHE to work, but then
# disable so that users need to export CCACHE_DISABLE=false
# to actually have it working.
cat > $INSTALLROOT/etc/ccache.conf <<EOF
cache_dir=$WORK_DIR/TMP/ccache/$ARCHITECTURE
disable=true
EOF
export CCACHE_CONFIGPATH=$INSTALLROOT/etc/ccache.conf
mkdir -p $WORK_DIR/TMP/ccache/$ARCHITECTURE
ln -sf ccache $BUILDDIR/bootstrap-ccache/bin/gcc
ln -sf ccache $BUILDDIR/bootstrap-ccache/bin/g++
ln -sf ccache $BUILDDIR/bootstrap-ccache/bin/cc
ln -sf ccache $BUILDDIR/bootstrap-ccache/bin/c++
export PATH=$BUILDDIR/bootstrap-ccache/bin:$PATH
fi

ccache --show-stats

if [ -e autoconf-archive ]; then
(cd autoconf-archive && autoreconf -ivf )
mkdir build-autoconf-archive
Expand All @@ -58,10 +111,12 @@ if [ -e autoconf-archive ]; then
popd
export ACLOCAL_PATH=$INSTALLROOT/share/aclocal
fi
ccache --show-stats

# Binutils
mkdir build-binutils
pushd build-binutils
env > env.sh
../binutils/configure --prefix="$INSTALLROOT" \
${MARCH:+--build=$MARCH --host=$MARCH} \
${USE_GOLD:+--enable-gold=yes} \
Expand All @@ -74,6 +129,7 @@ pushd build-binutils
make install MAKEINFO=":"
hash -r
popd
ccache --show-stats

# Test program
cat > test.c <<EOF
Expand All @@ -82,18 +138,26 @@ cat > test.c <<EOF
int main(void) { printf("The answer is 42.\n"); }
EOF

# We will need to rebuild them with the final GCC
rsync -a gcc/mpfr/ mpfr
rsync -a gcc/gmp/ gmp
rsync -a gcc/isl/ isl
rsync -a gcc/mpc/ mpc

pushd gcc
[ -e mpfr ] && (cd mpfr && autoreconf -ivf)
[ -e mpc ] && (cd mpc && autoreconf -ivf)
[ -e gmp ] && (cd gmp && autoreconf -ivf)
[ -e isl ] && (cd isl && autoreconf -ivf)
[ -e cloog ] && (cd cloog && autoreconf -ivf)
[ -d mpfr ] && (cd mpfr && autoreconf -ivf)
[ -d mpc ] && (cd mpc && autoreconf -ivf)
[ -d gmp ] && (cd gmp && autoreconf -ivf)
[ -d isl ] && (cd isl && autoreconf -ivf)
[ -d cloog ] && (cd cloog && autoreconf -ivf)
popd
[ -e mpfr ] && (cd mpfr && autoreconf -ivf)
[ -e mpc ] && (cd mpc && autoreconf -ivf)
[ -e gmp ] && (cd gmp && autoreconf -ivf)
[ -e isl ] && (cd isl && autoreconf -ivf)
[ -e cloog ] && (cd cloog && autoreconf -ivf)

[ -d mpfr ] && (cd mpfr && autoreconf -ivf)
[ -d mpc ] && (cd mpc && autoreconf -ivf)
[ -d gmp ] && (cd gmp && autoreconf -ivf)
[ -d isl ] && (cd isl && autoreconf -ivf)
[ -d cloog ] && (cd cloog && autoreconf -ivf)
[ -d distcc ] && (cd distcc && autoreconf -ivf)

mkdir build-gcc
pushd build-gcc
Expand Down Expand Up @@ -126,21 +190,97 @@ popd

# From now on, use own linker and GCC
export PATH="$INSTALLROOT/bin:$PATH"
ccache --show-stats
export LD_LIBRARY_PATH="$INSTALLROOT/lib64:$INSTALLROOT/lib:$LD_LIBRARY_PATH"
hash -r

# Test own linker and own GCC
which ld
which g++
type ld
type g++
g++ test.c
./a.out
rm -f a.out
# We rebuild ccache using our own compiler, so that we do not have issue
# with libstdc++ compatibility.

mkdir build-ccache
pushd build-ccache
$BUILDDIR/bootstrap-cmake/bin/cmake -S ../ccache \
-DENABLE_DOCUMENTATION=OFF \
-DENABLE_TESTING=OFF \
-DSTATIC_LINK=ON \
-DCMAKE_INSTALL_PREFIX="$INSTALLROOT/libexec/ccache"
make ${JOBS:+-j $JOBS} install
ln -sf ccache $INSTALLROOT/libexec/ccache/bin/gcc
ln -sf ccache $INSTALLROOT/libexec/ccache/bin/g++
ln -sf ccache $INSTALLROOT/libexec/ccache/bin/cc
ln -sf ccache $INSTALLROOT/libexec/ccache/bin/c++
export PATH=$INSTALLROOT/libexec/ccache/bin:$PATH
popd
ccache --show-stats

# We rebuild mpfr, gmp, isl to be used with gdb. We do so because
# we want to make sure they were actually built with the GCC we
# use, not with the bootstrap xgcc.
[ -d mpfr ] && (cd mpfr && autoreconf -ivf)
[ -d gmp ] && (cd gmp && autoreconf -ivf)
[ -d isl ] && (cd isl && autoreconf -ivf)
[ -d mpc ] && (cd mpc && autoreconf -ivf)
mkdir -p build-gmp
mkdir -p build-mpfr
mkdir -p build-isl
mkdir -p build-mpc

pushd build-gmp
../gmp/configure --prefix="$INSTALLROOT/libexec/extra" \
--disable-shared \
--enable-static
make ${JOBS:+-j$JOBS} MAKEINFO=":"
make install MAKEINFO=":"
popd
ccache --show-stats

pushd build-mpfr
../mpfr/configure --prefix="$INSTALLROOT/libexec/extra" \
--disable-shared \
--with-gmp="$INSTALLROOT/libexec/extra" \
--enable-static
make ${JOBS:+-j$JOBS} MAKEINFO=":"
make install MAKEINFO=":"
popd
ccache --show-stats

pushd build-isl
../isl/configure --prefix="$INSTALLROOT/libexec/extra" \
--with-gmp-prefix="$INSTALLROOT/libexec/extra" \
--disable-shared \
--enable-static
make ${JOBS:+-j$JOBS} MAKEINFO=":"
make install MAKEINFO=":"
popd
ccache --show-stats

pushd build-mpc
../mpc/configure --prefix="$INSTALLROOT/libexec/extra" \
--disable-shared \
--with-gmp="$INSTALLROOT/libexec/extra" \
--with-mpft="$INSTALLROOT/libexec/extra" \
--enable-static
make ${JOBS:+-j$JOBS} MAKEINFO=":"
make install MAKEINFO=":"
popd
ccache --show-stats

# GDB
mkdir build-gdb
pushd build-gdb
../gdb/configure --prefix="$INSTALLROOT" \
${MARCH:+--build=$MARCH --host=$MARCH} \
--with-gmp=$INSTALLROOT/libexec/extra \
--with-mpfr=$INSTALLROOT/libexec/extra \
--with-isl=$INSTALLROOT/libexec/extra \
--with-mpc=$INSTALLROOT/libexec/extra \
--without-guile \
--without-python \
--disable-multilib
make ${JOBS:+-j$JOBS} MAKEINFO=":"
Expand Down

0 comments on commit bf6acf1

Please sign in to comment.