2020-01-02 02:06:14 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-05-27 06:02:57 +00:00
|
|
|
set -eo pipefail
|
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
|
|
|
|
2022-10-02 17:55:22 +00:00
|
|
|
ARCH=${ARCH:-"x86_64"}
|
2019-12-17 21:42:42 +00:00
|
|
|
TARGET="$ARCH-pc-serenity"
|
2020-12-29 03:38:52 +00:00
|
|
|
PREFIX="$DIR/Local/$ARCH"
|
2021-03-07 19:37:29 +00:00
|
|
|
BUILD="$DIR/../Build/$ARCH"
|
2020-05-06 15:40:06 +00:00
|
|
|
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-12-28 23:36:15 +00:00
|
|
|
REALPATH="realpath"
|
2020-01-02 02:06:14 +00:00
|
|
|
|
2020-07-08 21:57:51 +00:00
|
|
|
if command -v ginstall &>/dev/null; then
|
|
|
|
INSTALL=ginstall
|
|
|
|
else
|
|
|
|
INSTALL=install
|
|
|
|
fi
|
|
|
|
|
2021-04-18 12:45:26 +00:00
|
|
|
SYSTEM_NAME="$(uname -s)"
|
|
|
|
|
2021-04-17 19:28:02 +00:00
|
|
|
# We *most definitely* don't need debug symbols in the linker/compiler.
|
|
|
|
# This cuts the uncompressed size from 1.2 GiB per Toolchain down to about 120 MiB.
|
|
|
|
# Hence, this might actually cause marginal speedups, although the point is to not waste space as blatantly.
|
2021-05-21 11:22:39 +00:00
|
|
|
export CFLAGS="-g0 -O2 -mtune=native"
|
|
|
|
export CXXFLAGS="-g0 -O2 -mtune=native"
|
2021-04-17 19:28:02 +00:00
|
|
|
|
2021-04-18 12:45:26 +00:00
|
|
|
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
|
2020-01-02 02:06:14 +00:00
|
|
|
MAKE=gmake
|
|
|
|
MD5SUM="md5 -q"
|
|
|
|
NPROC="sysctl -n hw.ncpuonline"
|
2020-12-28 23:36:15 +00:00
|
|
|
REALPATH="readlink -f"
|
2020-01-02 02:06:14 +00:00
|
|
|
export CC=egcc
|
|
|
|
export CXX=eg++
|
|
|
|
export with_gmp=/usr/local
|
|
|
|
export LDFLAGS=-Wl,-z,notext
|
2021-04-18 12:45:26 +00:00
|
|
|
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
|
2020-03-21 08:46:30 +00:00
|
|
|
MAKE=gmake
|
|
|
|
MD5SUM="md5 -q"
|
|
|
|
NPROC="sysctl -n hw.ncpu"
|
2020-10-17 20:25:13 +00:00
|
|
|
export with_gmp=/usr/local
|
|
|
|
export with_mpfr=/usr/local
|
2020-01-02 02:06:14 +00:00
|
|
|
fi
|
|
|
|
|
2020-12-28 23:36:15 +00:00
|
|
|
# On at least OpenBSD, the path must exist to call realpath(3) on it
|
|
|
|
if [ ! -d "$BUILD" ]; then
|
|
|
|
mkdir -p "$BUILD"
|
|
|
|
fi
|
|
|
|
BUILD=$($REALPATH "$BUILD")
|
|
|
|
|
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
|
|
|
|
2022-08-23 06:52:23 +00:00
|
|
|
BINUTILS_VERSION="2.39"
|
|
|
|
BINUTILS_MD5SUM="ab6825df57514ec172331e988f55fc10"
|
2019-12-17 21:42:42 +00:00
|
|
|
BINUTILS_NAME="binutils-$BINUTILS_VERSION"
|
|
|
|
BINUTILS_PKG="${BINUTILS_NAME}.tar.gz"
|
2021-10-03 20:56:30 +00:00
|
|
|
BINUTILS_BASE_URL="https://ftp.gnu.org/gnu/binutils"
|
2019-12-17 21:42:42 +00:00
|
|
|
|
2022-08-23 07:05:33 +00:00
|
|
|
GDB_VERSION="12.1"
|
|
|
|
GDB_MD5SUM="0c7339e33fa347ce4d7df222d8ce86af"
|
2021-09-06 23:14:32 +00:00
|
|
|
GDB_NAME="gdb-$GDB_VERSION"
|
|
|
|
GDB_PKG="${GDB_NAME}.tar.gz"
|
2021-10-03 20:56:30 +00:00
|
|
|
GDB_BASE_URL="https://ftp.gnu.org/gnu/gdb"
|
2021-09-06 23:14:32 +00:00
|
|
|
|
2021-04-27 07:25:02 +00:00
|
|
|
# Note: If you bump the gcc version, you also have to update the matching
|
|
|
|
# GCC_VERSION variable in the project's root CMakeLists.txt
|
2022-08-23 06:51:40 +00:00
|
|
|
GCC_VERSION="12.2.0"
|
|
|
|
GCC_MD5SUM="d7644b494246450468464ffc2c2b19c3"
|
2019-12-17 21:42:42 +00:00
|
|
|
GCC_NAME="gcc-$GCC_VERSION"
|
|
|
|
GCC_PKG="${GCC_NAME}.tar.gz"
|
2021-10-03 20:56:30 +00:00
|
|
|
GCC_BASE_URL="https://ftp.gnu.org/gnu/gcc"
|
2019-12-17 21:42:42 +00:00
|
|
|
|
2021-04-18 00:35:16 +00:00
|
|
|
buildstep() {
|
|
|
|
NAME=$1
|
|
|
|
shift
|
2021-04-18 15:25:46 +00:00
|
|
|
"$@" 2>&1 | sed $'s|^|\x1b[34m['"${NAME}"$']\x1b[39m |'
|
2021-04-18 00:35:16 +00:00
|
|
|
}
|
|
|
|
|
2021-05-30 08:48:47 +00:00
|
|
|
# === DEPENDENCIES ===
|
|
|
|
buildstep dependencies echo "Checking whether 'make' is available..."
|
|
|
|
if ! command -v ${MAKE:-make} >/dev/null; then
|
|
|
|
buildstep dependencies echo "Please make sure to install GNU Make (for the '${MAKE:-make}' tool)."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
buildstep dependencies echo "Checking whether 'patch' is available..."
|
|
|
|
if ! command -v patch >/dev/null; then
|
|
|
|
buildstep dependencies echo "Please make sure to install GNU patch (for the 'patch' tool)."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
buildstep dependencies echo "Checking whether your C compiler works..."
|
|
|
|
if ! ${CC:-cc} -o /dev/null -xc - >/dev/null <<'PROGRAM'
|
|
|
|
int main() {}
|
|
|
|
PROGRAM
|
|
|
|
then
|
|
|
|
buildstep dependencies echo "Please make sure to install a working C compiler."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$SYSTEM_NAME" != "Darwin" ]; then
|
|
|
|
for lib in gmp mpc mpfr; do
|
|
|
|
buildstep dependencies echo "Checking whether the $lib library and headers are available..."
|
|
|
|
if ! ${CC:-cc} -I /usr/local/include -L /usr/local/lib -l$lib -o /dev/null -xc - >/dev/null <<PROGRAM
|
|
|
|
#include <$lib.h>
|
|
|
|
int main() {}
|
|
|
|
PROGRAM
|
|
|
|
then
|
|
|
|
echo "Please make sure to install the $lib library and headers."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2020-03-07 16:38:16 +00:00
|
|
|
# === CHECK CACHE AND REUSE ===
|
|
|
|
|
|
|
|
pushd "$DIR"
|
|
|
|
if [ "${TRY_USE_LOCAL_TOOLCHAIN}" = "y" ] ; then
|
2020-11-03 19:43:23 +00:00
|
|
|
# The actual logic had to be moved to .github/workflows/cmake.yml.
|
|
|
|
# Github Actions guarantees that Toolchain/Cache/ is empty on a cache
|
|
|
|
# miss, and non-empty on a cache hit.
|
|
|
|
# The following logic is correct *only* because of that.
|
|
|
|
|
|
|
|
mkdir -p Cache
|
|
|
|
echo "Cache (before):"
|
|
|
|
ls -l Cache
|
|
|
|
CACHED_TOOLCHAIN_ARCHIVE="Cache/ToolchainBinariesGithubActions.tar.gz"
|
|
|
|
if [ -r "${CACHED_TOOLCHAIN_ARCHIVE}" ] ; then
|
2020-10-19 18:03:15 +00:00
|
|
|
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."
|
2020-11-03 19:43:23 +00:00
|
|
|
echo "Cache unchanged."
|
2020-10-19 18:03:15 +00:00
|
|
|
exit 0
|
|
|
|
else
|
2020-11-03 19:43:23 +00:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo "Could not extract cached toolchain archive."
|
|
|
|
echo "This means the cache is broken and *should be removed*!"
|
|
|
|
echo "As Github Actions cannot update a cache, this will unnecessarily"
|
|
|
|
echo "slow down all future builds for this hash, until someone"
|
|
|
|
echo "resets the cache."
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo
|
2020-10-19 18:03:15 +00:00
|
|
|
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."
|
|
|
|
fi
|
2020-11-03 19:43:23 +00:00
|
|
|
echo "::group::Actually building Toolchain"
|
2020-03-07 16:38:16 +00:00
|
|
|
fi
|
|
|
|
popd
|
|
|
|
|
|
|
|
|
|
|
|
# === DOWNLOAD AND PATCH ===
|
|
|
|
|
2019-04-15 13:16:47 +00:00
|
|
|
pushd "$DIR/Tarballs"
|
2021-09-06 23:14:32 +00:00
|
|
|
# Build aarch64-gdb for cross-debugging support on x86 systems
|
|
|
|
if [ "$ARCH" = "aarch64" ]; then
|
|
|
|
md5=""
|
|
|
|
if [ -e "$GDB_PKG" ]; then
|
|
|
|
md5="$($MD5SUM $GDB_PKG | cut -f1 -d' ')"
|
2022-08-23 07:05:33 +00:00
|
|
|
echo "gdb md5='$md5'"
|
2021-09-06 23:14:32 +00:00
|
|
|
fi
|
|
|
|
if [ "$md5" != ${GDB_MD5SUM} ] ; then
|
|
|
|
rm -f $GDB_PKG
|
|
|
|
curl -LO "$GDB_BASE_URL/$GDB_PKG"
|
|
|
|
else
|
|
|
|
echo "Skipped downloading gdb"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-05-27 06:02:57 +00:00
|
|
|
md5=""
|
|
|
|
if [ -e "$BINUTILS_PKG" ]; then
|
|
|
|
md5="$($MD5SUM $BINUTILS_PKG | cut -f1 -d' ')"
|
2022-08-23 06:52:23 +00:00
|
|
|
echo "binutils md5='$md5'"
|
2021-05-27 06:02:57 +00:00
|
|
|
fi
|
|
|
|
if [ "$md5" != ${BINUTILS_MD5SUM} ] ; then
|
2019-12-17 21:42:42 +00:00
|
|
|
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
|
|
|
|
|
2021-05-27 06:02:57 +00:00
|
|
|
md5=""
|
|
|
|
if [ -e "$GCC_PKG" ]; then
|
|
|
|
md5="$($MD5SUM ${GCC_PKG} | cut -f1 -d' ')"
|
2022-08-23 06:51:40 +00:00
|
|
|
echo "gcc md5='$md5'"
|
2021-05-27 06:02:57 +00:00
|
|
|
fi
|
|
|
|
if [ "$md5" != ${GCC_MD5SUM} ] ; then
|
2019-12-17 21:42:42 +00:00
|
|
|
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
|
|
|
|
|
2021-09-06 23:14:32 +00:00
|
|
|
if [ "$ARCH" = "aarch64" ]; then
|
|
|
|
if [ -d ${GDB_NAME} ]; then
|
|
|
|
rm -rf "${GDB_NAME}"
|
|
|
|
rm -rf "$DIR/Build/$ARCH/$GDB_NAME"
|
|
|
|
fi
|
|
|
|
echo "Extracting GDB..."
|
|
|
|
tar -xzf ${GDB_PKG}
|
|
|
|
|
|
|
|
pushd ${GDB_NAME}
|
|
|
|
if [ "$git_patch" = "1" ]; then
|
|
|
|
git init > /dev/null
|
|
|
|
git add . > /dev/null
|
|
|
|
git commit -am "BASE" > /dev/null
|
|
|
|
git apply "$DIR"/Patches/gdb.patch > /dev/null
|
|
|
|
else
|
|
|
|
patch -p1 < "$DIR"/Patches/gdb.patch > /dev/null
|
|
|
|
fi
|
|
|
|
$MD5SUM "$DIR"/Patches/gdb.patch > .patch.applied
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2022-09-26 21:28:31 +00:00
|
|
|
patch_md5="$(${MD5SUM} "${DIR}"/Patches/binutils/*.patch)"
|
|
|
|
|
|
|
|
if [ ! -d "${BINUTILS_NAME}" ] || [ "$(cat ${BINUTILS_NAME}/.patch.applied)" != "${patch_md5}" ]; then
|
|
|
|
if [ -d ${BINUTILS_NAME} ]; then
|
|
|
|
rm -rf "${BINUTILS_NAME}"
|
|
|
|
rm -rf "${DIR}/Build/${ARCH}/${BINUTILS_NAME}"
|
2021-02-21 18:20:29 +00:00
|
|
|
fi
|
2022-09-26 21:28:31 +00:00
|
|
|
echo "Extracting binutils..."
|
|
|
|
tar -xzf ${BINUTILS_PKG}
|
|
|
|
|
|
|
|
pushd ${BINUTILS_NAME}
|
|
|
|
if [ "${git_patch}" = "1" ]; then
|
|
|
|
git init > /dev/null
|
|
|
|
git add . > /dev/null
|
|
|
|
git commit -am "BASE" > /dev/null
|
|
|
|
git am "${DIR}"/Patches/binutils/*.patch > /dev/null
|
|
|
|
else
|
|
|
|
for patch in "${DIR}"/Patches/binutils/*.patch; do
|
|
|
|
patch -p1 < "${patch}" > /dev/null
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
${MD5SUM} "${DIR}"/Patches/binutils/*.patch > .patch.applied
|
|
|
|
popd
|
|
|
|
else
|
|
|
|
echo "Using existing binutils source directory"
|
2019-04-15 13:16:47 +00:00
|
|
|
fi
|
2022-09-26 21:28:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
patch_md5="$(${MD5SUM} "${DIR}"/Patches/gcc/*.patch)"
|
|
|
|
|
|
|
|
if [ ! -d "${GCC_NAME}" ] || [ "$(cat ${GCC_NAME}/.patch.applied)" != "${patch_md5}" ]; then
|
|
|
|
if [ -d ${GCC_NAME} ]; then
|
|
|
|
rm -rf "${GCC_NAME}"
|
|
|
|
rm -rf "${DIR}/Build/${ARCH}/${GCC_NAME}"
|
2021-02-21 18:20:29 +00:00
|
|
|
fi
|
2022-09-26 21:28:31 +00:00
|
|
|
echo "Extracting gcc..."
|
|
|
|
tar -xzf ${GCC_PKG}
|
2019-12-25 14:21:23 +00:00
|
|
|
|
2022-09-26 21:28:31 +00:00
|
|
|
pushd ${GCC_NAME}
|
|
|
|
if [ "${git_patch}" = "1" ]; then
|
|
|
|
git init > /dev/null
|
|
|
|
git add . > /dev/null
|
|
|
|
git commit -am "BASE" > /dev/null
|
|
|
|
git am --keep-non-patch "${DIR}"/Patches/gcc/*.patch > /dev/null
|
|
|
|
else
|
|
|
|
for patch in "${DIR}"/Patches/gcc/*.patch; do
|
|
|
|
patch -p1 < "${patch}" > /dev/null
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
${MD5SUM} "${DIR}"/Patches/gcc/*.patch > .patch.applied
|
|
|
|
|
|
|
|
if [ "${SYSTEM_NAME}" = "Darwin" ]; then
|
|
|
|
./contrib/download_prerequisites
|
|
|
|
fi
|
2019-12-25 14:21:23 +00:00
|
|
|
popd
|
2022-09-26 21:28:31 +00:00
|
|
|
else
|
|
|
|
echo "Using existing GCC source directory"
|
2019-12-25 14:21:23 +00:00
|
|
|
fi
|
2019-04-15 13:16:47 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
|
2020-03-07 16:38:16 +00:00
|
|
|
# === COMPILE AND INSTALL ===
|
|
|
|
|
2021-04-16 18:42:18 +00:00
|
|
|
rm -rf "$PREFIX"
|
2020-03-07 16:38:16 +00:00
|
|
|
mkdir -p "$PREFIX"
|
2019-04-15 13:16:47 +00:00
|
|
|
|
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
|
|
|
|
|
2021-04-16 18:42:18 +00:00
|
|
|
mkdir -p "$DIR/Build/$ARCH"
|
|
|
|
|
2020-12-29 03:38:52 +00:00
|
|
|
pushd "$DIR/Build/$ARCH"
|
2019-04-15 13:16:47 +00:00
|
|
|
unset PKG_CONFIG_LIBDIR # Just in case
|
|
|
|
|
2021-09-06 23:14:32 +00:00
|
|
|
if [ "$ARCH" = "aarch64" ]; then
|
|
|
|
rm -rf gdb
|
|
|
|
mkdir -p gdb
|
|
|
|
|
|
|
|
pushd gdb
|
|
|
|
echo "XXX configure gdb"
|
2022-03-31 23:06:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
if [ "$SYSTEM_NAME" = "Darwin" ]; then
|
|
|
|
buildstep "gdb/configure" "$DIR"/Tarballs/$GDB_NAME/configure --prefix="$PREFIX" \
|
|
|
|
--target="$TARGET" \
|
|
|
|
--with-sysroot="$SYSROOT" \
|
|
|
|
--enable-shared \
|
|
|
|
--disable-werror \
|
|
|
|
--with-libgmp-prefix="$(brew --prefix gmp)" \
|
|
|
|
--with-gmp="$(brew --prefix gmp)" \
|
|
|
|
--with-isl="$(brew --prefix isl)" \
|
|
|
|
--with-mpc="$(brew --prefix libmpc)" \
|
|
|
|
--with-mpfr="$(brew --prefix mpfr)" \
|
|
|
|
--disable-nls \
|
|
|
|
${TRY_USE_LOCAL_TOOLCHAIN:+"--quiet"} || exit 1
|
2022-05-07 15:50:41 +00:00
|
|
|
else
|
2022-03-31 23:06:48 +00:00
|
|
|
buildstep "gdb/configure" "$DIR"/Tarballs/$GDB_NAME/configure --prefix="$PREFIX" \
|
|
|
|
--target="$TARGET" \
|
|
|
|
--with-sysroot="$SYSROOT" \
|
|
|
|
--enable-shared \
|
|
|
|
--disable-nls \
|
|
|
|
${TRY_USE_LOCAL_TOOLCHAIN:+"--quiet"} || exit 1
|
|
|
|
fi
|
|
|
|
|
2021-09-06 23:14:32 +00:00
|
|
|
echo "XXX build gdb"
|
2022-11-11 18:07:26 +00:00
|
|
|
buildstep "gdb/build" "$MAKE" MAKEINFO=true -j "$MAKEJOBS" || exit 1
|
|
|
|
buildstep "gdb/install" "$MAKE" MAKEINFO=true install || exit 1
|
2021-09-06 23:14:32 +00:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2021-04-16 18:42:18 +00:00
|
|
|
rm -rf binutils
|
|
|
|
mkdir -p binutils
|
|
|
|
|
2019-04-15 13:16:47 +00:00
|
|
|
pushd binutils
|
2020-08-01 13:32:04 +00:00
|
|
|
echo "XXX configure binutils"
|
2022-03-12 10:19:18 +00:00
|
|
|
|
|
|
|
# We don't need the documentation that is being built, so
|
|
|
|
# don't force people to install makeinfo just for that.
|
|
|
|
export ac_cv_prog_MAKEINFO=true
|
|
|
|
|
2021-04-18 00:35:16 +00:00
|
|
|
buildstep "binutils/configure" "$DIR"/Tarballs/$BINUTILS_NAME/configure --prefix="$PREFIX" \
|
2020-10-12 09:52:58 +00:00
|
|
|
--target="$TARGET" \
|
|
|
|
--with-sysroot="$SYSROOT" \
|
|
|
|
--enable-shared \
|
|
|
|
--disable-nls \
|
|
|
|
${TRY_USE_LOCAL_TOOLCHAIN:+"--quiet"} || exit 1
|
2021-04-18 12:45:26 +00:00
|
|
|
if [ "$SYSTEM_NAME" = "Darwin" ]; then
|
2019-12-28 16:53:14 +00:00
|
|
|
# under macOS generated makefiles are not resolving the "intl"
|
|
|
|
# dependency properly to allow linking its own copy of
|
|
|
|
# libintl when building with --enable-shared.
|
2021-04-18 12:46:52 +00:00
|
|
|
buildstep "binutils/build" "$MAKE" -j "$MAKEJOBS" || true
|
2019-12-28 16:53:14 +00:00
|
|
|
pushd intl
|
2021-04-18 12:46:52 +00:00
|
|
|
buildstep "binutils/build" "$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"
|
2022-11-04 23:25:26 +00:00
|
|
|
buildstep "binutils/build" "$MAKE" MAKEINFO=true -j "$MAKEJOBS" || exit 1
|
|
|
|
buildstep "binutils/install" "$MAKE" MAKEINFO=true install || exit 1
|
2019-04-15 13:16:47 +00:00
|
|
|
popd
|
|
|
|
|
2022-09-05 23:01:21 +00:00
|
|
|
echo "XXX serenity libc headers"
|
2021-04-16 18:42:18 +00:00
|
|
|
mkdir -p "$BUILD"
|
|
|
|
pushd "$BUILD"
|
|
|
|
mkdir -p Root/usr/include/
|
|
|
|
SRC_ROOT=$($REALPATH "$DIR"/..)
|
2022-02-25 21:28:06 +00:00
|
|
|
FILES=$(find \
|
|
|
|
"$SRC_ROOT"/AK \
|
|
|
|
"$SRC_ROOT"/Kernel/API \
|
|
|
|
"$SRC_ROOT"/Kernel/Arch \
|
|
|
|
"$SRC_ROOT"/Userland/Libraries/LibC \
|
|
|
|
-name '*.h' -print)
|
2021-04-16 18:42:18 +00:00
|
|
|
for header in $FILES; do
|
2022-02-25 21:28:06 +00:00
|
|
|
target=$(echo "$header" | sed \
|
|
|
|
-e "s@$SRC_ROOT/AK/@AK/@" \
|
|
|
|
-e "s@$SRC_ROOT/Userland/Libraries/LibC@@" \
|
|
|
|
-e "s@$SRC_ROOT/Kernel/@Kernel/@")
|
2021-04-18 00:35:16 +00:00
|
|
|
buildstep "system_headers" $INSTALL -D "$header" "Root/usr/include/$target"
|
2021-04-16 18:42:18 +00:00
|
|
|
done
|
|
|
|
unset SRC_ROOT
|
|
|
|
popd
|
2020-01-02 02:06:14 +00:00
|
|
|
|
2021-04-18 12:45:26 +00:00
|
|
|
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
|
2021-04-16 18:42:18 +00:00
|
|
|
perl -pi -e 's/-no-pie/-nopie/g' "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/configure"
|
|
|
|
fi
|
2020-05-20 12:23:30 +00:00
|
|
|
|
2021-07-06 10:36:18 +00:00
|
|
|
rm -rf gcc
|
|
|
|
mkdir -p gcc
|
|
|
|
|
|
|
|
pushd gcc
|
|
|
|
echo "XXX configure gcc and libgcc"
|
|
|
|
buildstep "gcc/configure" "$DIR/Tarballs/gcc-$GCC_VERSION/configure" --prefix="$PREFIX" \
|
|
|
|
--target="$TARGET" \
|
|
|
|
--with-sysroot="$SYSROOT" \
|
|
|
|
--disable-nls \
|
|
|
|
--enable-shared \
|
|
|
|
--enable-languages=c,c++ \
|
|
|
|
--enable-default-pie \
|
|
|
|
--enable-lto \
|
|
|
|
--enable-threads=posix \
|
2022-01-19 18:12:50 +00:00
|
|
|
--enable-initfini-array \
|
2022-01-19 18:18:10 +00:00
|
|
|
--with-linker-hash-style=gnu \
|
2021-07-06 10:36:18 +00:00
|
|
|
${TRY_USE_LOCAL_TOOLCHAIN:+"--quiet"} || exit 1
|
|
|
|
|
|
|
|
echo "XXX build gcc and libgcc"
|
|
|
|
buildstep "gcc/build" "$MAKE" -j "$MAKEJOBS" all-gcc || exit 1
|
|
|
|
buildstep "libgcc/build" "$MAKE" -j "$MAKEJOBS" all-target-libgcc || exit 1
|
|
|
|
echo "XXX install gcc and libgcc"
|
|
|
|
buildstep "gcc+libgcc/install" "$MAKE" install-gcc install-target-libgcc || exit 1
|
|
|
|
|
|
|
|
echo "XXX build libstdc++"
|
|
|
|
buildstep "libstdc++/build" "$MAKE" -j "$MAKEJOBS" all-target-libstdc++-v3 || exit 1
|
|
|
|
echo "XXX install libstdc++"
|
|
|
|
buildstep "libstdc++/install" "$MAKE" install-target-libstdc++-v3 || exit 1
|
|
|
|
popd
|
|
|
|
|
2019-04-29 13:09:57 +00:00
|
|
|
popd
|
|
|
|
|
2022-01-19 19:54:34 +00:00
|
|
|
pushd "$DIR/Local/$ARCH/$ARCH-pc-serenity/bin"
|
|
|
|
buildstep "mold_symlink" ln -s ../../../mold/bin/mold ld.mold
|
|
|
|
popd
|
|
|
|
|
2020-03-07 16:38:16 +00:00
|
|
|
|
|
|
|
# == SAVE TO CACHE ==
|
|
|
|
|
|
|
|
pushd "$DIR"
|
|
|
|
if [ "${TRY_USE_LOCAL_TOOLCHAIN}" = "y" ] ; then
|
2020-11-03 19:43:23 +00:00
|
|
|
echo "::endgroup::"
|
|
|
|
echo "Building cache tar:"
|
|
|
|
|
|
|
|
rm -f "${CACHED_TOOLCHAIN_ARCHIVE}" # Just in case
|
|
|
|
|
|
|
|
tar czf "${CACHED_TOOLCHAIN_ARCHIVE}" Local/
|
|
|
|
|
|
|
|
echo "Cache (after):"
|
|
|
|
ls -l Cache
|
2020-03-07 16:38:16 +00:00
|
|
|
fi
|
|
|
|
popd
|