2020-01-02 02:06:14 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-05-15 18:05:18 +00:00
|
|
|
set -e
|
2019-11-02 16:34:54 +00:00
|
|
|
# This file will need to be run in bash, for now.
|
|
|
|
|
2020-03-07 16:38:16 +00:00
|
|
|
|
|
|
|
# === CONFIGURATION AND SETUP ===
|
|
|
|
|
2019-04-15 13:16:47 +00:00
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2019-11-02 16:34:54 +00:00
|
|
|
echo "$DIR"
|
2019-04-15 14:34:41 +00:00
|
|
|
|
2019-12-17 21:42:42 +00:00
|
|
|
ARCH=${ARCH:-"i686"}
|
|
|
|
TARGET="$ARCH-pc-serenity"
|
2019-04-15 13:16:47 +00:00
|
|
|
PREFIX="$DIR/Local"
|
2020-05-06 15:40:06 +00:00
|
|
|
BUILD=$(realpath "$DIR/../Build")
|
|
|
|
SYSROOT="$BUILD/Root"
|
2019-04-15 13:16:47 +00:00
|
|
|
|
2020-03-22 04:25:17 +00:00
|
|
|
MAKE="make"
|
|
|
|
MD5SUM="md5sum"
|
|
|
|
NPROC="nproc"
|
2020-01-02 02:06:14 +00:00
|
|
|
|
Travis: Toolchain only depends on headers, not impls
When libstdc++ was added in 4977fd22b874fb9d6d089665e36badd03bcde827, just calling
'make install' was the easiest way to install the headers. And the headers are all
that is needed for libstdc++ to determine the ABI. Since then, BuildIt.sh was
rewritten again and again, and somehow everyone just silently assumed that
libstdc++ also depends on libc.a and libm.a, because surely it does?
Turns out, it doesn't! This massively reduces the dependencies of libstdc++,
hopefully meaning that the Toolchain doesn't need to be rebuilt so often on Travis.
Furthermore, the old method of trying to determine the dependency tree with
bash/grep/etc. has finally broken anyways:
https://travis-ci.com/github/SerenityOS/serenity/builds/179805569#L567
In summary, this should eliminate most of the Toolchain rebuilds on Travis,
and therefore make Travis build blazingly fast! :^)
2020-08-14 23:11:58 +00:00
|
|
|
# Each cache entry is 70 MB. 5 entries are 350 MiB.
|
Travis: Reduce Toolchain cache item size by 73%
Empirically, every single push or PR has to download *and then upload*
about 3.6 GiB of "cache stuff", which takes up about 400 seconds:
https://travis-ci.com/github/SerenityOS/serenity/builds/177500795
On every single push/PR! No matter what!
Those 3.6 GB consist of:
- 3.2 GB Toolchain cache (around 260 MB per compressed item)
- 0.4 GB ccache, but is capped at 0.5 GB: https://travis-ci.com/github/BenWiederhake/serenity/builds/177528549
- (And 200 KB for some weird debian package? Dunno.)
Investigating in the size, the Toolchain consists mostly of *DEBUG SYMBOLS IN
THE COMPILER BINARIES* which comically misses the point. If we ever run into
compiler crashes, any stacktrace would be lost anyway as soon as the Travis VM
shuts down. Furthermore, Travis will only ever compile Serenity itself, and
Serenity forbids C in it's Contribution Guidelines. That's another 20 MB we
don't need to cache.
Stripping the binaries and deleting the C compiler reduces the uncompressed size
from 1200 MB down to 220 MB. The compressed size gets reduced from 260 MB to 70MB.
That's a reduction of 73%.
It'll take a while until the 'old' toolchains get deleted.
I guess it'll take less than a week.
From that point onward, the Travis cache will be 1.2 GB, consisting of:
- 0.7 GB Toolchain cache
- 0.5 GB ccache
- (And that weird 200 KB deb file)
If network speeds are linear, then this should reduce the "cache network
overhead time" from about 400 seconds to about 120 seconds.
tl;dr: Strip unnecessary debug infos, delete an unused files, and speed
everything up by two minutes. (Both Toolchain cache hits and Toolchain rebuilds!)
2020-07-28 22:11:28 +00:00
|
|
|
# It seems that Travis starts having trouble around a total
|
|
|
|
# cache size of 9 GiB, so I think this is a good amount.
|
Travis: Toolchain only depends on headers, not impls
When libstdc++ was added in 4977fd22b874fb9d6d089665e36badd03bcde827, just calling
'make install' was the easiest way to install the headers. And the headers are all
that is needed for libstdc++ to determine the ABI. Since then, BuildIt.sh was
rewritten again and again, and somehow everyone just silently assumed that
libstdc++ also depends on libc.a and libm.a, because surely it does?
Turns out, it doesn't! This massively reduces the dependencies of libstdc++,
hopefully meaning that the Toolchain doesn't need to be rebuilt so often on Travis.
Furthermore, the old method of trying to determine the dependency tree with
bash/grep/etc. has finally broken anyways:
https://travis-ci.com/github/SerenityOS/serenity/builds/179805569#L567
In summary, this should eliminate most of the Toolchain rebuilds on Travis,
and therefore make Travis build blazingly fast! :^)
2020-08-14 23:11:58 +00:00
|
|
|
KEEP_CACHE_COUNT=5
|
2020-05-11 04:11:26 +00:00
|
|
|
|
2020-07-08 21:57:51 +00:00
|
|
|
if command -v ginstall &>/dev/null; then
|
|
|
|
INSTALL=ginstall
|
|
|
|
else
|
|
|
|
INSTALL=install
|
|
|
|
fi
|
|
|
|
|
2020-03-22 04:25:17 +00:00
|
|
|
if [ "$(uname -s)" = "OpenBSD" ]; then
|
2020-01-02 02:06:14 +00:00
|
|
|
MAKE=gmake
|
|
|
|
MD5SUM="md5 -q"
|
|
|
|
NPROC="sysctl -n hw.ncpuonline"
|
|
|
|
export CC=egcc
|
|
|
|
export CXX=eg++
|
|
|
|
export with_gmp=/usr/local
|
|
|
|
export LDFLAGS=-Wl,-z,notext
|
2020-03-22 04:25:17 +00:00
|
|
|
elif [ "$(uname -s)" = "FreeBSD" ]; then
|
2020-03-21 08:46:30 +00:00
|
|
|
MAKE=gmake
|
|
|
|
MD5SUM="md5 -q"
|
|
|
|
NPROC="sysctl -n hw.ncpu"
|
2020-01-02 02:06:14 +00:00
|
|
|
fi
|
|
|
|
|
2020-04-27 08:03:27 +00:00
|
|
|
git_patch=
|
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
case $1 in
|
|
|
|
--dev ) git_patch=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2019-11-02 16:34:54 +00:00
|
|
|
echo PREFIX is "$PREFIX"
|
|
|
|
echo SYSROOT is "$SYSROOT"
|
2019-05-08 13:50:24 +00:00
|
|
|
|
2019-04-15 13:16:47 +00:00
|
|
|
mkdir -p "$DIR/Tarballs"
|
2019-04-25 17:28:10 +00:00
|
|
|
|
2020-10-12 09:52:58 +00:00
|
|
|
BINUTILS_VERSION="2.35.1"
|
|
|
|
BINUTILS_MD5SUM="bca600eea3b8fc33ad3265c9c1eee8d4"
|
2019-12-17 21:42:42 +00:00
|
|
|
BINUTILS_NAME="binutils-$BINUTILS_VERSION"
|
|
|
|
BINUTILS_PKG="${BINUTILS_NAME}.tar.gz"
|
|
|
|
BINUTILS_BASE_URL="http://ftp.gnu.org/gnu/binutils"
|
|
|
|
|
2020-10-12 09:38:50 +00:00
|
|
|
GCC_VERSION="10.2.0"
|
|
|
|
GCC_MD5SUM="941a8674ea2eeb33f5c30ecf08124874"
|
2019-12-17 21:42:42 +00:00
|
|
|
GCC_NAME="gcc-$GCC_VERSION"
|
|
|
|
GCC_PKG="${GCC_NAME}.tar.gz"
|
|
|
|
GCC_BASE_URL="http://ftp.gnu.org/gnu/gcc"
|
|
|
|
|
2020-03-07 16:38:16 +00:00
|
|
|
|
|
|
|
# === CHECK CACHE AND REUSE ===
|
|
|
|
|
|
|
|
pushd "$DIR"
|
|
|
|
if [ "${TRY_USE_LOCAL_TOOLCHAIN}" = "y" ] ; then
|
|
|
|
echo "Checking cached toolchain:"
|
Travis: Toolchain only depends on headers, not impls
When libstdc++ was added in 4977fd22b874fb9d6d089665e36badd03bcde827, just calling
'make install' was the easiest way to install the headers. And the headers are all
that is needed for libstdc++ to determine the ABI. Since then, BuildIt.sh was
rewritten again and again, and somehow everyone just silently assumed that
libstdc++ also depends on libc.a and libm.a, because surely it does?
Turns out, it doesn't! This massively reduces the dependencies of libstdc++,
hopefully meaning that the Toolchain doesn't need to be rebuilt so often on Travis.
Furthermore, the old method of trying to determine the dependency tree with
bash/grep/etc. has finally broken anyways:
https://travis-ci.com/github/SerenityOS/serenity/builds/179805569#L567
In summary, this should eliminate most of the Toolchain rebuilds on Travis,
and therefore make Travis build blazingly fast! :^)
2020-08-14 23:11:58 +00:00
|
|
|
# TODO: This is still overly pessimistic.
|
|
|
|
DEPS_CONFIG="\
|
2020-03-07 16:38:16 +00:00
|
|
|
uname=$(uname),TARGET=${TARGET},
|
2020-07-28 23:09:13 +00:00
|
|
|
BuildItHash=$($MD5SUM "$(basename "$0")"),
|
2020-03-07 16:38:16 +00:00
|
|
|
MAKE=${MAKE},MD5SUM=${MD5SUM},NPROC=${NPROC},
|
|
|
|
CC=${CC},CXX=${CXX},with_gmp=${with_gmp},LDFLAGS=${LDFLAGS},
|
|
|
|
BINUTILS_VERSION=${BINUTILS_VERSION},BINUTILS_MD5SUM=${BINUTILS_MD5SUM},
|
|
|
|
GCC_VERSION=${GCC_VERSION},GCC_MD5SUM=${GCC_MD5SUM}"
|
2020-10-19 18:24:56 +00:00
|
|
|
DEPS_HASH=$("$DIR/ComputeDependenciesHash.sh" "$MD5SUM" <<<"${DEPS_CONFIG}")
|
|
|
|
DEPS_HASH_EXIT_CODE="$?"
|
2020-10-19 18:03:15 +00:00
|
|
|
CACHED_TOOLCHAIN_ARCHIVE="Cache/ToolchainLocal_${DEPS_HASH}.tar.gz"
|
2020-10-19 18:24:56 +00:00
|
|
|
if [ "$DEPS_HASH_EXIT_CODE" -ne 0 ] ; then
|
Travis: Toolchain only depends on headers, not impls
When libstdc++ was added in 4977fd22b874fb9d6d089665e36badd03bcde827, just calling
'make install' was the easiest way to install the headers. And the headers are all
that is needed for libstdc++ to determine the ABI. Since then, BuildIt.sh was
rewritten again and again, and somehow everyone just silently assumed that
libstdc++ also depends on libc.a and libm.a, because surely it does?
Turns out, it doesn't! This massively reduces the dependencies of libstdc++,
hopefully meaning that the Toolchain doesn't need to be rebuilt so often on Travis.
Furthermore, the old method of trying to determine the dependency tree with
bash/grep/etc. has finally broken anyways:
https://travis-ci.com/github/SerenityOS/serenity/builds/179805569#L567
In summary, this should eliminate most of the Toolchain rebuilds on Travis,
and therefore make Travis build blazingly fast! :^)
2020-08-14 23:11:58 +00:00
|
|
|
# Make it stand out more
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo
|
2020-03-07 16:38:16 +00:00
|
|
|
echo "Dependency hashing failed"
|
|
|
|
echo "Will rebuild toolchain from scratch, and NOT SAVE THE RESULT."
|
|
|
|
echo "Someone should look into this, but for now it'll work, albeit inefficient."
|
Travis: Toolchain only depends on headers, not impls
When libstdc++ was added in 4977fd22b874fb9d6d089665e36badd03bcde827, just calling
'make install' was the easiest way to install the headers. And the headers are all
that is needed for libstdc++ to determine the ABI. Since then, BuildIt.sh was
rewritten again and again, and somehow everyone just silently assumed that
libstdc++ also depends on libc.a and libm.a, because surely it does?
Turns out, it doesn't! This massively reduces the dependencies of libstdc++,
hopefully meaning that the Toolchain doesn't need to be rebuilt so often on Travis.
Furthermore, the old method of trying to determine the dependency tree with
bash/grep/etc. has finally broken anyways:
https://travis-ci.com/github/SerenityOS/serenity/builds/179805569#L567
In summary, this should eliminate most of the Toolchain rebuilds on Travis,
and therefore make Travis build blazingly fast! :^)
2020-08-14 23:11:58 +00:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo
|
2020-03-07 16:38:16 +00:00
|
|
|
# Should be empty anyway, but just to make sure:
|
|
|
|
DEPS_HASH=""
|
2020-10-19 18:03:15 +00:00
|
|
|
elif [ -r "${CACHED_TOOLCHAIN_ARCHIVE}" ] ; then
|
|
|
|
echo "Cache at ${CACHED_TOOLCHAIN_ARCHIVE} exists!"
|
2020-03-07 16:38:16 +00:00
|
|
|
echo "Extracting toolchain from cache:"
|
2020-10-19 18:03:15 +00:00
|
|
|
if tar xzf "${CACHED_TOOLCHAIN_ARCHIVE}" ; then
|
|
|
|
echo "Done 'building' the toolchain."
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "Could not extract cached toolchain archive, removing it and rebuilding from scratch."
|
|
|
|
rm -f "${CACHED_TOOLCHAIN_ARCHIVE}"
|
|
|
|
fi
|
2020-03-07 16:38:16 +00:00
|
|
|
else
|
2020-10-19 18:03:15 +00:00
|
|
|
echo "Cache at ${CACHED_TOOLCHAIN_ARCHIVE} does not exist."
|
2020-03-07 16:38:16 +00:00
|
|
|
echo "Will rebuild toolchain from scratch, and save the result."
|
2020-05-11 04:11:26 +00:00
|
|
|
echo "But first, getting rid of old, outdated caches. Current caches:"
|
|
|
|
pushd "Cache/"
|
|
|
|
ls -l
|
|
|
|
# Travis preserves timestamps. Don't ask me why, but it does.
|
|
|
|
# We can exploit this to get an easy approximation of recent-ness.
|
|
|
|
# Our purging algorithm is simple: keep only the newest X entries.
|
2020-07-28 23:09:13 +00:00
|
|
|
# Note that `find` doesn't easily support ordering by date,
|
|
|
|
# and we control the filenames anyway.
|
|
|
|
# shellcheck disable=SC2012
|
2020-05-11 04:11:26 +00:00
|
|
|
ls -t | tail "-n+${KEEP_CACHE_COUNT}" | xargs -r rm -v
|
|
|
|
echo "After deletion:"
|
|
|
|
ls -l
|
|
|
|
popd
|
2020-03-07 16:38:16 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
popd
|
|
|
|
|
|
|
|
|
|
|
|
# === DOWNLOAD AND PATCH ===
|
|
|
|
|
2019-04-15 13:16:47 +00:00
|
|
|
pushd "$DIR/Tarballs"
|
2020-01-02 02:06:14 +00:00
|
|
|
md5="$($MD5SUM $BINUTILS_PKG | cut -f1 -d' ')"
|
2019-05-08 13:50:24 +00:00
|
|
|
echo "bu md5='$md5'"
|
2019-12-17 21:42:42 +00:00
|
|
|
if [ ! -e $BINUTILS_PKG ] || [ "$md5" != ${BINUTILS_MD5SUM} ] ; then
|
|
|
|
rm -f $BINUTILS_PKG
|
2020-06-18 14:31:12 +00:00
|
|
|
curl -LO "$BINUTILS_BASE_URL/$BINUTILS_PKG"
|
2019-04-15 14:34:41 +00:00
|
|
|
else
|
|
|
|
echo "Skipped downloading binutils"
|
2019-04-15 13:16:47 +00:00
|
|
|
fi
|
|
|
|
|
2020-01-02 02:06:14 +00:00
|
|
|
md5="$($MD5SUM ${GCC_PKG} | cut -f1 -d' ')"
|
2019-05-08 13:50:24 +00:00
|
|
|
echo "gc md5='$md5'"
|
2019-12-17 21:42:42 +00:00
|
|
|
if [ ! -e $GCC_PKG ] || [ "$md5" != ${GCC_MD5SUM} ] ; then
|
|
|
|
rm -f $GCC_PKG
|
2020-06-18 14:31:12 +00:00
|
|
|
curl -LO "$GCC_BASE_URL/$GCC_NAME/$GCC_PKG"
|
2019-04-15 14:34:41 +00:00
|
|
|
else
|
|
|
|
echo "Skipped downloading gcc"
|
2019-04-15 13:16:47 +00:00
|
|
|
fi
|
|
|
|
|
2019-12-17 21:42:42 +00:00
|
|
|
if [ ! -d ${BINUTILS_NAME} ]; then
|
2019-04-15 14:34:41 +00:00
|
|
|
echo "Extracting binutils..."
|
2020-01-02 02:06:14 +00:00
|
|
|
tar -xzf ${BINUTILS_PKG}
|
2019-04-15 13:16:47 +00:00
|
|
|
|
2019-12-17 21:42:42 +00:00
|
|
|
pushd ${BINUTILS_NAME}
|
2020-04-27 08:03:27 +00:00
|
|
|
if [ "$git_patch" = "1" ]; then
|
|
|
|
git init > /dev/null
|
|
|
|
git add . > /dev/null
|
|
|
|
git commit -am "BASE" > /dev/null
|
|
|
|
git apply "$DIR"/Patches/binutils.patch > /dev/null
|
|
|
|
else
|
|
|
|
patch -p1 < "$DIR"/Patches/binutils.patch > /dev/null
|
|
|
|
fi
|
2019-04-15 13:16:47 +00:00
|
|
|
popd
|
2019-04-15 14:34:41 +00:00
|
|
|
else
|
|
|
|
echo "Skipped extracting binutils"
|
2019-04-15 13:16:47 +00:00
|
|
|
fi
|
|
|
|
|
2019-12-17 21:42:42 +00:00
|
|
|
if [ ! -d $GCC_NAME ]; then
|
2019-04-15 14:34:41 +00:00
|
|
|
echo "Extracting gcc..."
|
2020-01-02 02:06:14 +00:00
|
|
|
tar -xzf $GCC_PKG
|
2019-12-17 21:42:42 +00:00
|
|
|
pushd $GCC_NAME
|
2020-04-27 08:03:27 +00:00
|
|
|
if [ "$git_patch" = "1" ]; then
|
|
|
|
git init > /dev/null
|
|
|
|
git add . > /dev/null
|
|
|
|
git commit -am "BASE" > /dev/null
|
|
|
|
git apply "$DIR"/Patches/gcc.patch > /dev/null
|
|
|
|
else
|
2020-05-16 04:52:49 +00:00
|
|
|
patch -p1 < "$DIR/Patches/gcc.patch" > /dev/null
|
2020-04-27 08:03:27 +00:00
|
|
|
fi
|
2019-04-15 13:16:47 +00:00
|
|
|
popd
|
2019-04-15 14:34:41 +00:00
|
|
|
else
|
|
|
|
echo "Skipped extracting gcc"
|
2019-04-15 13:16:47 +00:00
|
|
|
fi
|
2019-12-25 14:21:23 +00:00
|
|
|
|
|
|
|
if [ "$(uname)" = "Darwin" ]; then
|
|
|
|
pushd "gcc-${GCC_VERSION}"
|
|
|
|
./contrib/download_prerequisites
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2019-04-15 13:16:47 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
|
2020-03-07 16:38:16 +00:00
|
|
|
# === COMPILE AND INSTALL ===
|
|
|
|
|
|
|
|
mkdir -p "$PREFIX"
|
2019-04-15 13:16:47 +00:00
|
|
|
mkdir -p "$DIR/Build/binutils"
|
|
|
|
mkdir -p "$DIR/Build/gcc"
|
|
|
|
|
2019-05-15 18:08:23 +00:00
|
|
|
if [ -z "$MAKEJOBS" ]; then
|
2020-01-02 02:06:14 +00:00
|
|
|
MAKEJOBS=$($NPROC)
|
2019-05-15 18:08:23 +00:00
|
|
|
fi
|
|
|
|
|
2019-04-15 13:16:47 +00:00
|
|
|
pushd "$DIR/Build/"
|
|
|
|
unset PKG_CONFIG_LIBDIR # Just in case
|
|
|
|
|
|
|
|
pushd binutils
|
2020-08-01 13:32:04 +00:00
|
|
|
echo "XXX configure binutils"
|
2020-10-12 09:52:58 +00:00
|
|
|
"$DIR"/Tarballs/$BINUTILS_NAME/configure --prefix="$PREFIX" \
|
|
|
|
--target="$TARGET" \
|
|
|
|
--with-sysroot="$SYSROOT" \
|
|
|
|
--enable-shared \
|
|
|
|
--disable-nls \
|
|
|
|
${TRY_USE_LOCAL_TOOLCHAIN:+"--quiet"} || exit 1
|
2019-12-28 16:53:14 +00:00
|
|
|
if [ "$(uname)" = "Darwin" ]; then
|
|
|
|
# under macOS generated makefiles are not resolving the "intl"
|
|
|
|
# dependency properly to allow linking its own copy of
|
|
|
|
# libintl when building with --enable-shared.
|
2020-01-02 02:06:14 +00:00
|
|
|
"$MAKE" -j "$MAKEJOBS" || true
|
2019-12-28 16:53:14 +00:00
|
|
|
pushd intl
|
2020-01-02 02:06:14 +00:00
|
|
|
"$MAKE" all-yes
|
2019-12-28 16:53:14 +00:00
|
|
|
popd
|
|
|
|
fi
|
2020-08-01 13:32:04 +00:00
|
|
|
echo "XXX build binutils"
|
2020-01-02 02:06:14 +00:00
|
|
|
"$MAKE" -j "$MAKEJOBS" || exit 1
|
|
|
|
"$MAKE" install || exit 1
|
2019-04-15 13:16:47 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
pushd gcc
|
2020-03-22 04:25:17 +00:00
|
|
|
if [ "$(uname -s)" = "OpenBSD" ]; then
|
|
|
|
perl -pi -e 's/-no-pie/-nopie/g' "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/configure"
|
2020-01-02 02:06:14 +00:00
|
|
|
fi
|
|
|
|
|
2020-08-01 13:32:04 +00:00
|
|
|
echo "XXX configure gcc and libgcc"
|
2020-03-22 04:25:17 +00:00
|
|
|
"$DIR/Tarballs/gcc-$GCC_VERSION/configure" --prefix="$PREFIX" \
|
2019-11-11 19:07:44 +00:00
|
|
|
--target="$TARGET" \
|
|
|
|
--with-sysroot="$SYSROOT" \
|
|
|
|
--disable-nls \
|
|
|
|
--with-newlib \
|
2019-12-27 13:26:25 +00:00
|
|
|
--enable-shared \
|
2020-08-01 13:32:04 +00:00
|
|
|
--enable-languages=c,c++ \
|
|
|
|
${TRY_USE_LOCAL_TOOLCHAIN:+"--quiet"} || exit 1
|
2019-04-15 14:34:41 +00:00
|
|
|
|
2019-05-08 13:50:24 +00:00
|
|
|
echo "XXX build gcc and libgcc"
|
2020-01-02 02:06:14 +00:00
|
|
|
"$MAKE" -j "$MAKEJOBS" all-gcc all-target-libgcc || exit 1
|
2019-05-08 13:50:24 +00:00
|
|
|
echo "XXX install gcc and libgcc"
|
2020-01-02 02:06:14 +00:00
|
|
|
"$MAKE" install-gcc install-target-libgcc || exit 1
|
2019-04-17 15:29:45 +00:00
|
|
|
|
Travis: Toolchain only depends on headers, not impls
When libstdc++ was added in 4977fd22b874fb9d6d089665e36badd03bcde827, just calling
'make install' was the easiest way to install the headers. And the headers are all
that is needed for libstdc++ to determine the ABI. Since then, BuildIt.sh was
rewritten again and again, and somehow everyone just silently assumed that
libstdc++ also depends on libc.a and libm.a, because surely it does?
Turns out, it doesn't! This massively reduces the dependencies of libstdc++,
hopefully meaning that the Toolchain doesn't need to be rebuilt so often on Travis.
Furthermore, the old method of trying to determine the dependency tree with
bash/grep/etc. has finally broken anyways:
https://travis-ci.com/github/SerenityOS/serenity/builds/179805569#L567
In summary, this should eliminate most of the Toolchain rebuilds on Travis,
and therefore make Travis build blazingly fast! :^)
2020-08-14 23:11:58 +00:00
|
|
|
echo "XXX serenity libc and libm headers"
|
2020-05-20 12:23:30 +00:00
|
|
|
mkdir -p "$BUILD"
|
|
|
|
pushd "$BUILD"
|
Travis: Toolchain only depends on headers, not impls
When libstdc++ was added in 4977fd22b874fb9d6d089665e36badd03bcde827, just calling
'make install' was the easiest way to install the headers. And the headers are all
that is needed for libstdc++ to determine the ABI. Since then, BuildIt.sh was
rewritten again and again, and somehow everyone just silently assumed that
libstdc++ also depends on libc.a and libm.a, because surely it does?
Turns out, it doesn't! This massively reduces the dependencies of libstdc++,
hopefully meaning that the Toolchain doesn't need to be rebuilt so often on Travis.
Furthermore, the old method of trying to determine the dependency tree with
bash/grep/etc. has finally broken anyways:
https://travis-ci.com/github/SerenityOS/serenity/builds/179805569#L567
In summary, this should eliminate most of the Toolchain rebuilds on Travis,
and therefore make Travis build blazingly fast! :^)
2020-08-14 23:11:58 +00:00
|
|
|
mkdir -p Root/usr/include/
|
2020-05-20 12:23:30 +00:00
|
|
|
SRC_ROOT=$(realpath "$DIR"/..)
|
2020-07-08 21:57:51 +00:00
|
|
|
FILES=$(find "$SRC_ROOT"/Libraries/LibC "$SRC_ROOT"/Libraries/LibM -name '*.h' -print)
|
|
|
|
for header in $FILES; do
|
2020-05-20 12:23:30 +00:00
|
|
|
target=$(echo "$header" | sed -e "s@$SRC_ROOT/Libraries/LibC@@" -e "s@$SRC_ROOT/Libraries/LibM@@")
|
2020-07-08 21:57:51 +00:00
|
|
|
$INSTALL -D "$header" "Root/usr/include/$target"
|
2020-05-20 12:23:30 +00:00
|
|
|
done
|
|
|
|
unset SRC_ROOT
|
|
|
|
popd
|
|
|
|
|
2020-05-20 12:23:31 +00:00
|
|
|
echo "XXX build libstdc++"
|
2020-08-01 16:22:17 +00:00
|
|
|
"$MAKE" -j "$MAKEJOBS" all-target-libstdc++-v3 || exit 1
|
2020-05-20 12:23:31 +00:00
|
|
|
echo "XXX install libstdc++"
|
|
|
|
"$MAKE" install-target-libstdc++-v3 || exit 1
|
|
|
|
|
2020-03-22 04:25:17 +00:00
|
|
|
if [ "$(uname -s)" = "OpenBSD" ]; then
|
|
|
|
cd "$DIR/Local/libexec/gcc/i686-pc-serenity/$GCC_VERSION" && ln -sf liblto_plugin.so.0.0 liblto_plugin.so
|
2020-01-02 02:06:14 +00:00
|
|
|
fi
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2019-04-15 13:16:47 +00:00
|
|
|
popd
|
2019-04-29 13:09:57 +00:00
|
|
|
popd
|
|
|
|
|
2020-03-07 16:38:16 +00:00
|
|
|
|
|
|
|
# == SAVE TO CACHE ==
|
|
|
|
|
|
|
|
pushd "$DIR"
|
|
|
|
if [ "${TRY_USE_LOCAL_TOOLCHAIN}" = "y" ] ; then
|
|
|
|
echo "Caching toolchain:"
|
|
|
|
|
|
|
|
if [ -z "${DEPS_HASH}" ] ; then
|
|
|
|
echo "NOT SAVED, because hashing failed."
|
|
|
|
echo "It's computed in the beginning; see there for the error message."
|
|
|
|
elif [ -e "Cache/ToolchainLocal_${DEPS_HASH}.tar.gz" ] ; then
|
|
|
|
# Note: This checks for *existence*. Initially we checked for
|
|
|
|
# *readability*. If Travis borks permissions, there's not much we can do.
|
|
|
|
echo "Cache exists but was not used?!"
|
|
|
|
echo "Not touching cache then."
|
|
|
|
else
|
|
|
|
mkdir -p Cache/
|
Travis: Reduce Toolchain cache item size by 73%
Empirically, every single push or PR has to download *and then upload*
about 3.6 GiB of "cache stuff", which takes up about 400 seconds:
https://travis-ci.com/github/SerenityOS/serenity/builds/177500795
On every single push/PR! No matter what!
Those 3.6 GB consist of:
- 3.2 GB Toolchain cache (around 260 MB per compressed item)
- 0.4 GB ccache, but is capped at 0.5 GB: https://travis-ci.com/github/BenWiederhake/serenity/builds/177528549
- (And 200 KB for some weird debian package? Dunno.)
Investigating in the size, the Toolchain consists mostly of *DEBUG SYMBOLS IN
THE COMPILER BINARIES* which comically misses the point. If we ever run into
compiler crashes, any stacktrace would be lost anyway as soon as the Travis VM
shuts down. Furthermore, Travis will only ever compile Serenity itself, and
Serenity forbids C in it's Contribution Guidelines. That's another 20 MB we
don't need to cache.
Stripping the binaries and deleting the C compiler reduces the uncompressed size
from 1200 MB down to 220 MB. The compressed size gets reduced from 260 MB to 70MB.
That's a reduction of 73%.
It'll take a while until the 'old' toolchains get deleted.
I guess it'll take less than a week.
From that point onward, the Travis cache will be 1.2 GB, consisting of:
- 0.7 GB Toolchain cache
- 0.5 GB ccache
- (And that weird 200 KB deb file)
If network speeds are linear, then this should reduce the "cache network
overhead time" from about 400 seconds to about 120 seconds.
tl;dr: Strip unnecessary debug infos, delete an unused files, and speed
everything up by two minutes. (Both Toolchain cache hits and Toolchain rebuilds!)
2020-07-28 22:11:28 +00:00
|
|
|
# We *most definitely* don't need debug symbols in the linker/compiler.
|
2020-09-13 21:36:43 +00:00
|
|
|
# This cuts the uncompressed size from 1.2 GiB per Toolchain down to about 190 MiB.
|
|
|
|
echo "Before: $(du -sh Local)"
|
|
|
|
find Local/ -type f -executable ! -name '*.la' ! -name '*.sh' ! -name 'mk*' -exec strip {} +
|
|
|
|
echo "After: $(du -sh Local)"
|
2020-03-07 16:38:16 +00:00
|
|
|
tar czf "Cache/ToolchainLocal_${DEPS_HASH}.tar.gz" Local/
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
popd
|