2020-01-02 05:06:14 +03:00
|
|
|
#!/usr/bin/env bash
|
2021-05-27 09:02:57 +03:00
|
|
|
set -eo pipefail
|
2019-11-02 19:34:54 +03:00
|
|
|
# This file will need to be run in bash, for now.
|
|
|
|
|
2020-03-07 19:38:16 +03:00
|
|
|
|
|
|
|
# === CONFIGURATION AND SETUP ===
|
|
|
|
|
2019-04-15 16:16:47 +03:00
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2019-11-02 19:34:54 +03:00
|
|
|
echo "$DIR"
|
2019-04-15 17:34:41 +03:00
|
|
|
|
2022-10-02 20:55:22 +03:00
|
|
|
ARCH=${ARCH:-"x86_64"}
|
2019-12-18 00:42:42 +03:00
|
|
|
TARGET="$ARCH-pc-serenity"
|
2020-12-29 06:38:52 +03:00
|
|
|
PREFIX="$DIR/Local/$ARCH"
|
2021-03-07 22:37:29 +03:00
|
|
|
BUILD="$DIR/../Build/$ARCH"
|
2020-05-06 18:40:06 +03:00
|
|
|
SYSROOT="$BUILD/Root"
|
2019-04-15 16:16:47 +03:00
|
|
|
|
2020-03-22 07:25:17 +03:00
|
|
|
MAKE="make"
|
|
|
|
MD5SUM="md5sum"
|
|
|
|
NPROC="nproc"
|
2020-12-29 02:36:15 +03:00
|
|
|
REALPATH="realpath"
|
2020-01-02 05:06:14 +03:00
|
|
|
|
2020-07-09 00:57:51 +03:00
|
|
|
if command -v ginstall &>/dev/null; then
|
|
|
|
INSTALL=ginstall
|
|
|
|
else
|
|
|
|
INSTALL=install
|
|
|
|
fi
|
|
|
|
|
2021-04-18 15:45:26 +03:00
|
|
|
SYSTEM_NAME="$(uname -s)"
|
|
|
|
|
2021-04-17 22:28:02 +03: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 14:22:39 +03:00
|
|
|
export CFLAGS="-g0 -O2 -mtune=native"
|
|
|
|
export CXXFLAGS="-g0 -O2 -mtune=native"
|
2021-04-17 22:28:02 +03:00
|
|
|
|
2021-04-18 15:45:26 +03:00
|
|
|
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
|
2020-01-02 05:06:14 +03:00
|
|
|
MAKE=gmake
|
|
|
|
MD5SUM="md5 -q"
|
|
|
|
NPROC="sysctl -n hw.ncpuonline"
|
2020-12-29 02:36:15 +03:00
|
|
|
REALPATH="readlink -f"
|
2020-01-02 05:06:14 +03:00
|
|
|
export CC=egcc
|
|
|
|
export CXX=eg++
|
|
|
|
export with_gmp=/usr/local
|
|
|
|
export LDFLAGS=-Wl,-z,notext
|
2021-04-18 15:45:26 +03:00
|
|
|
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
|
2020-03-21 11:46:30 +03:00
|
|
|
MAKE=gmake
|
|
|
|
MD5SUM="md5 -q"
|
|
|
|
NPROC="sysctl -n hw.ncpu"
|
2020-10-17 23:25:13 +03:00
|
|
|
export with_gmp=/usr/local
|
|
|
|
export with_mpfr=/usr/local
|
2023-01-09 03:08:28 +03:00
|
|
|
elif [ "$SYSTEM_NAME" = "Darwin" ]; then
|
|
|
|
MD5SUM="md5 -q"
|
|
|
|
NPROC="sysctl -n hw.ncpu"
|
2020-01-02 05:06:14 +03:00
|
|
|
fi
|
|
|
|
|
2020-12-29 02:36:15 +03: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 11:03:27 +03:00
|
|
|
git_patch=
|
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
case $1 in
|
|
|
|
--dev ) git_patch=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2019-11-02 19:34:54 +03:00
|
|
|
echo PREFIX is "$PREFIX"
|
|
|
|
echo SYSROOT is "$SYSROOT"
|
2019-05-08 16:50:24 +03:00
|
|
|
|
2019-04-15 16:16:47 +03:00
|
|
|
mkdir -p "$DIR/Tarballs"
|
2019-04-25 20:28:10 +03:00
|
|
|
|
2023-03-27 17:55:10 +03:00
|
|
|
BINUTILS_VERSION="2.40"
|
|
|
|
BINUTILS_MD5SUM="b200db2cdd2f49019ced4016e1f9bfe7"
|
2019-12-18 00:42:42 +03:00
|
|
|
BINUTILS_NAME="binutils-$BINUTILS_VERSION"
|
|
|
|
BINUTILS_PKG="${BINUTILS_NAME}.tar.gz"
|
2021-10-03 23:56:30 +03:00
|
|
|
BINUTILS_BASE_URL="https://ftp.gnu.org/gnu/binutils"
|
2019-12-18 00:42:42 +03:00
|
|
|
|
2023-04-01 03:15:39 +03:00
|
|
|
GDB_VERSION="13.1"
|
|
|
|
GDB_MD5SUM="92b70971e81a450f6b3e1cf568671cfa"
|
2021-09-07 02:14:32 +03:00
|
|
|
GDB_NAME="gdb-$GDB_VERSION"
|
|
|
|
GDB_PKG="${GDB_NAME}.tar.gz"
|
2021-10-03 23:56:30 +03:00
|
|
|
GDB_BASE_URL="https://ftp.gnu.org/gnu/gdb"
|
2021-09-07 02:14:32 +03:00
|
|
|
|
2021-04-27 10:25:02 +03: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 09:51:40 +03:00
|
|
|
GCC_VERSION="12.2.0"
|
|
|
|
GCC_MD5SUM="d7644b494246450468464ffc2c2b19c3"
|
2019-12-18 00:42:42 +03:00
|
|
|
GCC_NAME="gcc-$GCC_VERSION"
|
|
|
|
GCC_PKG="${GCC_NAME}.tar.gz"
|
2021-10-03 23:56:30 +03:00
|
|
|
GCC_BASE_URL="https://ftp.gnu.org/gnu/gcc"
|
2019-12-18 00:42:42 +03:00
|
|
|
|
2021-04-18 03:35:16 +03:00
|
|
|
buildstep() {
|
|
|
|
NAME=$1
|
|
|
|
shift
|
2021-04-18 18:25:46 +03:00
|
|
|
"$@" 2>&1 | sed $'s|^|\x1b[34m['"${NAME}"$']\x1b[39m |'
|
2021-04-18 03:35:16 +03:00
|
|
|
}
|
|
|
|
|
2023-04-02 11:15:08 +03:00
|
|
|
has_gdb() {
|
|
|
|
ARCH=$1
|
|
|
|
ARCH_DASH="${ARCH//_/-}"
|
2023-04-09 14:23:24 +03:00
|
|
|
if command -v gdb >/dev/null && gdb -ex 'set architecture' -ex 'quit' 2>&1 | grep "$ARCH_DASH"; then
|
2023-04-02 11:15:08 +03:00
|
|
|
return 0
|
|
|
|
else
|
|
|
|
command -v "$ARCH"-elf-gdb >/dev/null
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
NEEDS_GDB=1
|
|
|
|
if has_gdb "$ARCH"; then
|
|
|
|
NEEDS_GDB=0
|
|
|
|
fi
|
|
|
|
|
2021-05-30 11:48:47 +03: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 19:38:16 +03:00
|
|
|
# === CHECK CACHE AND REUSE ===
|
|
|
|
|
|
|
|
pushd "$DIR"
|
|
|
|
if [ "${TRY_USE_LOCAL_TOOLCHAIN}" = "y" ] ; then
|
2020-11-03 22:43:23 +03: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 21:03:15 +03:00
|
|
|
echo "Cache at ${CACHED_TOOLCHAIN_ARCHIVE} exists!"
|
2020-03-07 19:38:16 +03:00
|
|
|
echo "Extracting toolchain from cache:"
|
2020-10-19 21:03:15 +03:00
|
|
|
if tar xzf "${CACHED_TOOLCHAIN_ARCHIVE}" ; then
|
|
|
|
echo "Done 'building' the toolchain."
|
2020-11-03 22:43:23 +03:00
|
|
|
echo "Cache unchanged."
|
2020-10-19 21:03:15 +03:00
|
|
|
exit 0
|
|
|
|
else
|
2020-11-03 22:43:23 +03: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 21:03:15 +03:00
|
|
|
rm -f "${CACHED_TOOLCHAIN_ARCHIVE}"
|
|
|
|
fi
|
2020-03-07 19:38:16 +03:00
|
|
|
else
|
2020-10-19 21:03:15 +03:00
|
|
|
echo "Cache at ${CACHED_TOOLCHAIN_ARCHIVE} does not exist."
|
2020-03-07 19:38:16 +03:00
|
|
|
echo "Will rebuild toolchain from scratch, and save the result."
|
|
|
|
fi
|
2020-11-03 22:43:23 +03:00
|
|
|
echo "::group::Actually building Toolchain"
|
2020-03-07 19:38:16 +03:00
|
|
|
fi
|
|
|
|
popd
|
|
|
|
|
|
|
|
|
|
|
|
# === DOWNLOAD AND PATCH ===
|
|
|
|
|
2019-04-15 16:16:47 +03:00
|
|
|
pushd "$DIR/Tarballs"
|
2023-04-02 11:15:08 +03:00
|
|
|
# Build gdb for cross-debugging support
|
|
|
|
if [ $NEEDS_GDB -eq 1 ]; then
|
|
|
|
echo "GDB not found for $ARCH. Will build it from source."
|
2021-09-07 02:14:32 +03:00
|
|
|
md5=""
|
|
|
|
if [ -e "$GDB_PKG" ]; then
|
|
|
|
md5="$($MD5SUM $GDB_PKG | cut -f1 -d' ')"
|
2022-08-23 10:05:33 +03:00
|
|
|
echo "gdb md5='$md5'"
|
2021-09-07 02:14:32 +03: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 09:02:57 +03:00
|
|
|
md5=""
|
|
|
|
if [ -e "$BINUTILS_PKG" ]; then
|
|
|
|
md5="$($MD5SUM $BINUTILS_PKG | cut -f1 -d' ')"
|
2022-08-23 09:52:23 +03:00
|
|
|
echo "binutils md5='$md5'"
|
2021-05-27 09:02:57 +03:00
|
|
|
fi
|
|
|
|
if [ "$md5" != ${BINUTILS_MD5SUM} ] ; then
|
2019-12-18 00:42:42 +03:00
|
|
|
rm -f $BINUTILS_PKG
|
2020-06-18 17:31:12 +03:00
|
|
|
curl -LO "$BINUTILS_BASE_URL/$BINUTILS_PKG"
|
2019-04-15 17:34:41 +03:00
|
|
|
else
|
|
|
|
echo "Skipped downloading binutils"
|
2019-04-15 16:16:47 +03:00
|
|
|
fi
|
|
|
|
|
2021-05-27 09:02:57 +03:00
|
|
|
md5=""
|
|
|
|
if [ -e "$GCC_PKG" ]; then
|
|
|
|
md5="$($MD5SUM ${GCC_PKG} | cut -f1 -d' ')"
|
2022-08-23 09:51:40 +03:00
|
|
|
echo "gcc md5='$md5'"
|
2021-05-27 09:02:57 +03:00
|
|
|
fi
|
|
|
|
if [ "$md5" != ${GCC_MD5SUM} ] ; then
|
2019-12-18 00:42:42 +03:00
|
|
|
rm -f $GCC_PKG
|
2020-06-18 17:31:12 +03:00
|
|
|
curl -LO "$GCC_BASE_URL/$GCC_NAME/$GCC_PKG"
|
2019-04-15 17:34:41 +03:00
|
|
|
else
|
|
|
|
echo "Skipped downloading gcc"
|
2019-04-15 16:16:47 +03:00
|
|
|
fi
|
|
|
|
|
2023-04-02 11:15:08 +03:00
|
|
|
if [ $NEEDS_GDB -eq 1 ]; then
|
2021-09-07 02:14:32 +03:00
|
|
|
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
|
2023-04-01 03:16:14 +03:00
|
|
|
git am "${DIR}"/Patches/gdb/*.patch > /dev/null
|
2021-09-07 02:14:32 +03:00
|
|
|
else
|
2023-04-01 03:16:14 +03:00
|
|
|
for patch in "${DIR}"/Patches/gdb/*.patch; do
|
|
|
|
patch -p1 < "${patch}" > /dev/null
|
|
|
|
done
|
2021-09-07 02:14:32 +03:00
|
|
|
fi
|
2023-04-01 03:16:14 +03:00
|
|
|
$MD5SUM "$DIR"/Patches/gdb/*.patch > .patch.applied
|
2021-09-07 02:14:32 +03:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2022-09-27 00:28:31 +03: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 21:20:29 +03:00
|
|
|
fi
|
2022-09-27 00:28:31 +03: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 16:16:47 +03:00
|
|
|
fi
|
2022-09-27 00:28:31 +03: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 21:20:29 +03:00
|
|
|
fi
|
2022-09-27 00:28:31 +03:00
|
|
|
echo "Extracting gcc..."
|
|
|
|
tar -xzf ${GCC_PKG}
|
2019-12-25 17:21:23 +03:00
|
|
|
|
2022-09-27 00:28:31 +03: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 17:21:23 +03:00
|
|
|
popd
|
2022-09-27 00:28:31 +03:00
|
|
|
else
|
|
|
|
echo "Using existing GCC source directory"
|
2019-12-25 17:21:23 +03:00
|
|
|
fi
|
2019-04-15 16:16:47 +03:00
|
|
|
popd
|
|
|
|
|
|
|
|
|
2020-03-07 19:38:16 +03:00
|
|
|
# === COMPILE AND INSTALL ===
|
|
|
|
|
2021-04-16 21:42:18 +03:00
|
|
|
rm -rf "$PREFIX"
|
2020-03-07 19:38:16 +03:00
|
|
|
mkdir -p "$PREFIX"
|
2019-04-15 16:16:47 +03:00
|
|
|
|
2019-05-15 21:08:23 +03:00
|
|
|
if [ -z "$MAKEJOBS" ]; then
|
2020-01-02 05:06:14 +03:00
|
|
|
MAKEJOBS=$($NPROC)
|
2019-05-15 21:08:23 +03:00
|
|
|
fi
|
|
|
|
|
2021-04-16 21:42:18 +03:00
|
|
|
mkdir -p "$DIR/Build/$ARCH"
|
|
|
|
|
2020-12-29 06:38:52 +03:00
|
|
|
pushd "$DIR/Build/$ARCH"
|
2019-04-15 16:16:47 +03:00
|
|
|
unset PKG_CONFIG_LIBDIR # Just in case
|
|
|
|
|
2023-04-02 11:15:08 +03:00
|
|
|
if [ $NEEDS_GDB -eq 1 ]; then
|
2021-09-07 02:14:32 +03:00
|
|
|
rm -rf gdb
|
|
|
|
mkdir -p gdb
|
|
|
|
|
|
|
|
pushd gdb
|
|
|
|
echo "XXX configure gdb"
|
2022-04-01 02:06:48 +03: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 18:50:41 +03:00
|
|
|
else
|
2022-04-01 02:06:48 +03:00
|
|
|
buildstep "gdb/configure" "$DIR"/Tarballs/$GDB_NAME/configure --prefix="$PREFIX" \
|
|
|
|
--target="$TARGET" \
|
|
|
|
--with-sysroot="$SYSROOT" \
|
|
|
|
--enable-shared \
|
2022-12-30 17:19:22 +03:00
|
|
|
--disable-werror \
|
2022-04-01 02:06:48 +03:00
|
|
|
--disable-nls \
|
|
|
|
${TRY_USE_LOCAL_TOOLCHAIN:+"--quiet"} || exit 1
|
|
|
|
fi
|
|
|
|
|
2021-09-07 02:14:32 +03:00
|
|
|
echo "XXX build gdb"
|
2022-11-11 21:07:26 +03:00
|
|
|
buildstep "gdb/build" "$MAKE" MAKEINFO=true -j "$MAKEJOBS" || exit 1
|
|
|
|
buildstep "gdb/install" "$MAKE" MAKEINFO=true install || exit 1
|
2021-09-07 02:14:32 +03:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2021-04-16 21:42:18 +03:00
|
|
|
rm -rf binutils
|
|
|
|
mkdir -p binutils
|
|
|
|
|
2019-04-15 16:16:47 +03:00
|
|
|
pushd binutils
|
2020-08-01 16:32:04 +03:00
|
|
|
echo "XXX configure binutils"
|
2022-03-12 13:19:18 +03: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 03:35:16 +03:00
|
|
|
buildstep "binutils/configure" "$DIR"/Tarballs/$BINUTILS_NAME/configure --prefix="$PREFIX" \
|
2020-10-12 12:52:58 +03:00
|
|
|
--target="$TARGET" \
|
|
|
|
--with-sysroot="$SYSROOT" \
|
|
|
|
--enable-shared \
|
|
|
|
--disable-nls \
|
|
|
|
${TRY_USE_LOCAL_TOOLCHAIN:+"--quiet"} || exit 1
|
2021-04-18 15:45:26 +03:00
|
|
|
if [ "$SYSTEM_NAME" = "Darwin" ]; then
|
2019-12-28 19:53:14 +03: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 15:46:52 +03:00
|
|
|
buildstep "binutils/build" "$MAKE" -j "$MAKEJOBS" || true
|
2019-12-28 19:53:14 +03:00
|
|
|
pushd intl
|
2021-04-18 15:46:52 +03:00
|
|
|
buildstep "binutils/build" "$MAKE" all-yes
|
2019-12-28 19:53:14 +03:00
|
|
|
popd
|
|
|
|
fi
|
2020-08-01 16:32:04 +03:00
|
|
|
echo "XXX build binutils"
|
2022-11-05 02:25:26 +03:00
|
|
|
buildstep "binutils/build" "$MAKE" MAKEINFO=true -j "$MAKEJOBS" || exit 1
|
|
|
|
buildstep "binutils/install" "$MAKE" MAKEINFO=true install || exit 1
|
2019-04-15 16:16:47 +03:00
|
|
|
popd
|
|
|
|
|
2022-09-06 02:01:21 +03:00
|
|
|
echo "XXX serenity libc headers"
|
2021-04-16 21:42:18 +03:00
|
|
|
mkdir -p "$BUILD"
|
|
|
|
pushd "$BUILD"
|
|
|
|
mkdir -p Root/usr/include/
|
|
|
|
SRC_ROOT=$($REALPATH "$DIR"/..)
|
2022-02-26 00:28:06 +03: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 21:42:18 +03:00
|
|
|
for header in $FILES; do
|
2022-02-26 00:28:06 +03:00
|
|
|
target=$(echo "$header" | sed \
|
2023-03-13 21:55:15 +03:00
|
|
|
-e "s|$SRC_ROOT/AK/|AK/|" \
|
|
|
|
-e "s|$SRC_ROOT/Userland/Libraries/LibC||" \
|
|
|
|
-e "s|$SRC_ROOT/Kernel/|Kernel/|")
|
2023-01-09 03:08:51 +03:00
|
|
|
buildstep "system_headers" mkdir -p "$(dirname "Root/usr/include/$target")"
|
|
|
|
buildstep "system_headers" $INSTALL "$header" "Root/usr/include/$target"
|
2021-04-16 21:42:18 +03:00
|
|
|
done
|
|
|
|
unset SRC_ROOT
|
|
|
|
popd
|
2020-01-02 05:06:14 +03:00
|
|
|
|
2021-04-18 15:45:26 +03:00
|
|
|
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
|
2021-04-16 21:42:18 +03:00
|
|
|
perl -pi -e 's/-no-pie/-nopie/g' "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/configure"
|
|
|
|
fi
|
2020-05-20 15:23:30 +03:00
|
|
|
|
2021-07-06 13:36:18 +03: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 21:12:50 +03:00
|
|
|
--enable-initfini-array \
|
2022-01-19 21:18:10 +03:00
|
|
|
--with-linker-hash-style=gnu \
|
2021-07-06 13:36:18 +03: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 16:09:57 +03:00
|
|
|
popd
|
|
|
|
|
2022-01-19 22:54:34 +03:00
|
|
|
pushd "$DIR/Local/$ARCH/$ARCH-pc-serenity/bin"
|
|
|
|
buildstep "mold_symlink" ln -s ../../../mold/bin/mold ld.mold
|
|
|
|
popd
|
|
|
|
|
2020-03-07 19:38:16 +03:00
|
|
|
|
|
|
|
# == SAVE TO CACHE ==
|
|
|
|
|
|
|
|
pushd "$DIR"
|
|
|
|
if [ "${TRY_USE_LOCAL_TOOLCHAIN}" = "y" ] ; then
|
2020-11-03 22:43:23 +03: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 19:38:16 +03:00
|
|
|
fi
|
|
|
|
popd
|