2021-07-31 13:54:48 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eo pipefail
|
|
|
|
|
|
|
|
# === CONFIGURATION AND SETUP ===
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2023-04-24 18:24:22 +00:00
|
|
|
# shellcheck source=/dev/null
|
|
|
|
. "${DIR}/../Meta/shell_include.sh"
|
|
|
|
|
|
|
|
exit_if_running_as_root "Do not run BuildClang.sh as root, parts of your Toolchain directory will become root-owned"
|
|
|
|
|
2021-07-31 13:54:48 +00:00
|
|
|
echo "$DIR"
|
|
|
|
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
PREFIX="$DIR/Local/clang/"
|
|
|
|
BUILD="$DIR/../Build/"
|
2022-10-03 23:48:37 +00:00
|
|
|
USERLAND_ARCHS="x86_64"
|
2023-08-10 18:34:47 +00:00
|
|
|
ARCHS="$USERLAND_ARCHS aarch64 riscv64"
|
2021-07-31 13:54:48 +00:00
|
|
|
|
|
|
|
MD5SUM="md5sum"
|
|
|
|
REALPATH="realpath"
|
2022-01-02 21:02:00 +00:00
|
|
|
INSTALL="install"
|
|
|
|
SED="sed"
|
2021-07-31 13:54:48 +00:00
|
|
|
|
|
|
|
SYSTEM_NAME="$(uname -s)"
|
|
|
|
|
|
|
|
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
|
|
|
|
MD5SUM="md5 -q"
|
|
|
|
REALPATH="readlink -f"
|
|
|
|
export CC=egcc
|
|
|
|
export CXX=eg++
|
|
|
|
export LDFLAGS=-Wl,-z,notext
|
|
|
|
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
|
|
|
|
MD5SUM="md5 -q"
|
2022-01-02 21:02:00 +00:00
|
|
|
elif [ "$SYSTEM_NAME" = "Darwin" ]; then
|
|
|
|
MD5SUM="md5 -q"
|
|
|
|
REALPATH="grealpath" # GNU coreutils
|
|
|
|
INSTALL="ginstall" # GNU coreutils
|
|
|
|
SED="gsed" # GNU sed
|
2021-07-31 13:54:48 +00:00
|
|
|
fi
|
|
|
|
|
2023-05-02 19:05:04 +00:00
|
|
|
NPROC=$(get_number_of_processing_units)
|
|
|
|
[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
|
2021-07-31 13:54:48 +00:00
|
|
|
|
|
|
|
if [ ! -d "$BUILD" ]; then
|
|
|
|
mkdir -p "$BUILD"
|
|
|
|
fi
|
|
|
|
BUILD=$($REALPATH "$BUILD")
|
|
|
|
|
|
|
|
dev=
|
2021-09-21 10:28:35 +00:00
|
|
|
ci=
|
|
|
|
|
2021-07-31 13:54:48 +00:00
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
case $1 in
|
|
|
|
--dev ) dev=1
|
|
|
|
;;
|
2021-09-21 10:28:35 +00:00
|
|
|
--ci ) ci=1
|
|
|
|
;;
|
2021-07-31 13:54:48 +00:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2021-09-21 10:28:35 +00:00
|
|
|
if [ "$dev" = "1" ] && [ "$ci" = "1" ]; then
|
|
|
|
echo "Please only set one of --dev or --ci."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-07-31 13:54:48 +00:00
|
|
|
echo PREFIX is "$PREFIX"
|
|
|
|
|
|
|
|
mkdir -p "$DIR/Tarballs"
|
|
|
|
|
2023-04-26 11:39:28 +00:00
|
|
|
LLVM_VERSION="16.0.6"
|
|
|
|
LLVM_MD5SUM="dc13938a604f70379d3b38d09031de98"
|
2021-07-31 13:54:48 +00:00
|
|
|
LLVM_NAME="llvm-project-$LLVM_VERSION.src"
|
|
|
|
LLVM_PKG="$LLVM_NAME.tar.xz"
|
|
|
|
LLVM_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/$LLVM_PKG"
|
|
|
|
|
|
|
|
buildstep() {
|
|
|
|
NAME=$1
|
|
|
|
shift
|
2022-01-02 21:02:00 +00:00
|
|
|
"$@" 2>&1 | "$SED" $'s|^|\e[34m['"${NAME}"$']\e[39m |'
|
2021-09-06 21:43:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
buildstep_ninja() {
|
|
|
|
# When ninja writes to a pipe, it strips ANSI escape codes and prints one line per buildstep.
|
|
|
|
# Instead, use NINJA_STATUS so that we get colored output from LLVM's build and fewer lines of output when running in a tty.
|
|
|
|
# ANSI escape codes in NINJA_STATUS are slightly janky (ninja thinks that "\e[34m" needs 5 output characters instead of 5, so
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
# its middle elision is slightly off; also it would happily elide the "\e39m" which messes up the output if the terminal is too
|
2021-09-06 21:43:26 +00:00
|
|
|
# narrow), but it's still working better than the alternative.
|
|
|
|
NAME=$1
|
|
|
|
shift
|
|
|
|
env NINJA_STATUS=$'\e[34m['"${NAME}"$']\e[39m [%f/%t] ' "$@"
|
2021-07-31 13:54:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# === DEPENDENCIES ===
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
|
2022-01-07 16:01:06 +00:00
|
|
|
buildstep dependencies echo "Checking whether Ninja is available..."
|
|
|
|
if ! command -v ninja >/dev/null; then
|
|
|
|
buildstep dependencies echo "Please make sure to install Ninja."
|
2021-07-31 13:54:48 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
buildstep dependencies echo "Checking whether CMake is available..."
|
|
|
|
if ! command -v cmake >/dev/null; then
|
|
|
|
buildstep dependencies echo "Please make sure to install CMake."
|
|
|
|
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."
|
|
|
|
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
|
|
|
|
|
|
|
|
buildstep dependencies echo "Checking whether your C++ compiler works..."
|
|
|
|
if ! ${CXX:-c++} -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
|
|
|
|
|
2022-01-08 11:59:14 +00:00
|
|
|
link_lld=
|
|
|
|
buildstep dependencies echo "Checking whether the LLD linker is available..."
|
|
|
|
if ${CXX:-c++} -o /dev/null -fuse-ld=lld -xc - >/dev/null 2>/dev/null << 'PROGRAM'
|
|
|
|
int main() {}
|
|
|
|
PROGRAM
|
|
|
|
then
|
|
|
|
link_lld=1
|
|
|
|
buildstep dependencies echo "Using LLD for linking LLVM."
|
|
|
|
else
|
|
|
|
buildstep dependencies echo "LLD not found. Using the default linker."
|
|
|
|
fi
|
|
|
|
|
2022-04-08 21:28:25 +00:00
|
|
|
buildstep setup echo "Determining if LLVM should be built with -march=native..."
|
|
|
|
if [ "$ci" = "1" ]; then
|
|
|
|
# The toolchain cache is shared among all runners, which might have different CPUs.
|
|
|
|
buildstep setup echo "On a CI runner. Using the default compiler settings."
|
|
|
|
elif [ -z "${CFLAGS+x}" ] && [ -z "${CXXFLAGS+x}" ]; then
|
|
|
|
if ${CXX:-c++} -o /dev/null -march=native -xc - >/dev/null 2>/dev/null << 'PROGRAM'
|
|
|
|
int main() {}
|
|
|
|
PROGRAM
|
|
|
|
then
|
|
|
|
export CFLAGS="-march=native"
|
|
|
|
export CXXFLAGS="-march=native"
|
|
|
|
buildstep setup echo "Using -march=native for compiling LLVM."
|
|
|
|
else
|
|
|
|
buildstep setup echo "-march=native is not supported by the compiler. Using the default settings."
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
buildstep setup echo "Using user-provided CFLAGS/CXXFLAGS."
|
|
|
|
fi
|
|
|
|
|
2021-08-05 21:45:07 +00:00
|
|
|
# === CHECK CACHE AND REUSE ===
|
|
|
|
|
|
|
|
pushd "$DIR"
|
|
|
|
if [ "$TRY_USE_LOCAL_TOOLCHAIN" = "y" ]; then
|
|
|
|
mkdir -p Cache
|
|
|
|
echo "Cache (before):"
|
|
|
|
ls -l Cache
|
|
|
|
CACHED_TOOLCHAIN_ARCHIVE="Cache/ToolchainBinariesGithubActions.tar.gz"
|
|
|
|
if [ -r "${CACHED_TOOLCHAIN_ARCHIVE}" ] ; then
|
|
|
|
echo "Cache at ${CACHED_TOOLCHAIN_ARCHIVE} exists!"
|
|
|
|
echo "Extracting toolchain from cache:"
|
|
|
|
if tar xzf "${CACHED_TOOLCHAIN_ARCHIVE}" ; then
|
|
|
|
echo "Done 'building' the toolchain."
|
|
|
|
echo "Cache unchanged."
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
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
|
|
|
|
rm -f "${CACHED_TOOLCHAIN_ARCHIVE}"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Cache at ${CACHED_TOOLCHAIN_ARCHIVE} does not exist."
|
|
|
|
echo "Will rebuild toolchain from scratch, and save the result."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "::group::Actually building Toolchain"
|
|
|
|
popd
|
|
|
|
|
2021-07-31 13:54:48 +00:00
|
|
|
# === DOWNLOAD AND PATCH ===
|
|
|
|
|
|
|
|
pushd "$DIR/Tarballs"
|
|
|
|
md5=""
|
|
|
|
if [ -e "$LLVM_PKG" ]; then
|
|
|
|
md5="$($MD5SUM ${LLVM_PKG} | cut -f1 -d' ')"
|
|
|
|
echo "llvm md5='$md5'"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$md5" != "$LLVM_MD5SUM" ] ; then
|
|
|
|
rm -f "$LLVM_PKG"
|
|
|
|
curl -LO "$LLVM_URL"
|
|
|
|
else
|
|
|
|
echo "Skipped downloading LLVM"
|
|
|
|
fi
|
|
|
|
|
2022-04-08 21:28:25 +00:00
|
|
|
patch_md5="$($MD5SUM "$DIR"/Patches/llvm/*.patch)"
|
|
|
|
|
|
|
|
if [ ! -d "$LLVM_NAME" ] || [ "$(cat $LLVM_NAME/.patch.applied)" != "$patch_md5" ]; then
|
|
|
|
if [ -d "$LLVM_NAME" ]; then
|
|
|
|
# Drop the previously patched extracted dir
|
|
|
|
rm -rf "${LLVM_NAME}"
|
|
|
|
fi
|
|
|
|
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
rm -rf "$DIR/Build/clang"
|
2022-04-08 21:28:25 +00:00
|
|
|
|
|
|
|
echo "Extracting LLVM..."
|
|
|
|
tar -xJf "$LLVM_PKG"
|
|
|
|
|
|
|
|
pushd "$LLVM_NAME"
|
|
|
|
if [ "$dev" = "1" ]; then
|
|
|
|
git init > /dev/null
|
|
|
|
git add . > /dev/null
|
|
|
|
git commit -am "BASE" > /dev/null
|
2022-03-05 00:45:04 +00:00
|
|
|
git am --keep-non-patch "$DIR"/Patches/llvm/*.patch > /dev/null
|
2022-04-08 21:28:25 +00:00
|
|
|
else
|
|
|
|
for patch in "$DIR"/Patches/llvm/*.patch; do
|
|
|
|
patch -p1 < "$patch" > /dev/null
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
echo "$patch_md5" > .patch.applied
|
|
|
|
popd
|
|
|
|
else
|
|
|
|
echo "Using existing LLVM source directory"
|
2021-07-31 13:54:48 +00:00
|
|
|
fi
|
|
|
|
popd
|
|
|
|
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
# === COPY HEADERS ===
|
2021-07-31 13:54:48 +00:00
|
|
|
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
SRC_ROOT=$($REALPATH "$DIR"/..)
|
2023-04-29 20:50:54 +00:00
|
|
|
FILES=$(find \
|
|
|
|
"$SRC_ROOT"/Kernel/API \
|
2023-07-15 16:09:28 +00:00
|
|
|
"$SRC_ROOT"/Kernel/Arch \
|
2023-04-29 20:50:54 +00:00
|
|
|
"$SRC_ROOT"/Userland/Libraries/LibC \
|
2023-04-30 15:07:21 +00:00
|
|
|
"$SRC_ROOT"/Userland/Libraries/LibELF/ELFABI.h \
|
2023-04-29 20:50:54 +00:00
|
|
|
"$SRC_ROOT"/Userland/Libraries/LibRegex/RegexDefs.h \
|
|
|
|
-name '*.h' -print)
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
for arch in $ARCHS; do
|
|
|
|
mkdir -p "$BUILD/${arch}clang"
|
|
|
|
pushd "$BUILD/${arch}clang"
|
|
|
|
mkdir -p Root/usr/include/
|
|
|
|
for header in $FILES; do
|
2023-04-29 20:50:54 +00:00
|
|
|
target=$(echo "$header" | "$SED" \
|
|
|
|
-e "s|$SRC_ROOT/Kernel/|Kernel/|" \
|
2023-07-15 16:09:28 +00:00
|
|
|
-e "s|$SRC_ROOT/Userland/Libraries/LibC||" \
|
2023-04-30 15:07:21 +00:00
|
|
|
-e "s|$SRC_ROOT/Userland/Libraries/LibELF/|LibELF/|" \
|
2023-04-29 20:50:54 +00:00
|
|
|
-e "s|$SRC_ROOT/Userland/Libraries/LibRegex/|LibRegex/|")
|
2022-01-02 21:02:00 +00:00
|
|
|
buildstep "system_headers" "$INSTALL" -D "$header" "Root/usr/include/$target"
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
done
|
|
|
|
popd
|
|
|
|
done
|
|
|
|
unset SRC_ROOT
|
|
|
|
|
|
|
|
# === COPY LIBRARY STUBS ===
|
|
|
|
|
|
|
|
for arch in $USERLAND_ARCHS; do
|
|
|
|
pushd "$BUILD/${arch}clang"
|
|
|
|
mkdir -p Root/usr/lib/
|
|
|
|
for lib in "$DIR/Stubs/${arch}clang/"*".so"; do
|
|
|
|
lib_name=$(basename "$lib")
|
2022-01-07 18:10:10 +00:00
|
|
|
[ ! -f "Root/usr/lib/${lib_name}" ] && cp "$lib" "Root/usr/lib/${lib_name}"
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
done
|
|
|
|
popd
|
|
|
|
done
|
2021-07-31 13:54:48 +00:00
|
|
|
|
|
|
|
# === COMPILE AND INSTALL ===
|
|
|
|
|
|
|
|
rm -rf "$PREFIX"
|
|
|
|
mkdir -p "$PREFIX"
|
|
|
|
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
mkdir -p "$DIR/Build/clang"
|
2021-07-31 13:54:48 +00:00
|
|
|
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
pushd "$DIR/Build/clang"
|
2021-07-31 13:54:48 +00:00
|
|
|
mkdir -p llvm
|
|
|
|
pushd llvm
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
buildstep "llvm/configure" cmake "$DIR/Tarballs/$LLVM_NAME/llvm" \
|
2021-07-31 13:54:48 +00:00
|
|
|
-G Ninja \
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
-DSERENITY_x86_64-pc-serenity_SYSROOT="$BUILD/x86_64clang/Root" \
|
|
|
|
-DSERENITY_aarch64-pc-serenity_SYSROOT="$BUILD/aarch64clang/Root" \
|
2023-08-10 18:34:47 +00:00
|
|
|
-DSERENITY_riscv64-pc-serenity_SYSROOT="$BUILD/riscv64clang/Root" \
|
2021-07-31 13:54:48 +00:00
|
|
|
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
2022-01-03 04:51:27 +00:00
|
|
|
-DSERENITY_MODULE_PATH="$DIR/CMake" \
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
-C "$DIR/CMake/LLVMConfig.cmake" \
|
2022-01-08 11:59:14 +00:00
|
|
|
${link_lld:+"-DLLVM_ENABLE_LLD=ON"} \
|
2021-09-21 10:28:35 +00:00
|
|
|
${dev:+"-DLLVM_CCACHE_BUILD=ON"} \
|
|
|
|
${ci:+"-DLLVM_CCACHE_BUILD=ON"} \
|
|
|
|
${ci:+"-DLLVM_CCACHE_DIR=$LLVM_CCACHE_DIR"} \
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
${ci:+"-DLLVM_CCACHE_MAXSIZE=$LLVM_CCACHE_MAXSIZE"}
|
2021-07-31 13:54:48 +00:00
|
|
|
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
buildstep_ninja "llvm/build" ninja -j "$MAKEJOBS"
|
2022-04-08 21:28:25 +00:00
|
|
|
buildstep_ninja "llvm/install" ninja install/strip
|
2021-07-31 13:54:48 +00:00
|
|
|
popd
|
|
|
|
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
for arch in $ARCHS; do
|
|
|
|
mkdir -p runtimes/"$arch"
|
|
|
|
pushd runtimes/"$arch"
|
|
|
|
buildstep "runtimes/$arch/configure" cmake "$DIR/Tarballs/$LLVM_NAME/runtimes" \
|
|
|
|
-G Ninja \
|
|
|
|
-DSERENITY_TOOLCHAIN_ARCH="$arch" \
|
|
|
|
-DSERENITY_TOOLCHAIN_ROOT="$PREFIX" \
|
|
|
|
-DSERENITY_BUILD_DIR="$BUILD/${arch}clang/" \
|
2022-01-03 04:51:27 +00:00
|
|
|
-DSERENITY_MODULE_PATH="$DIR/CMake" \
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
|
|
|
-C "$DIR/CMake/LLVMRuntimesConfig.cmake"
|
|
|
|
|
2022-04-08 21:28:25 +00:00
|
|
|
buildstep_ninja "runtimes/$arch/build" ninja -j "$MAKEJOBS"
|
|
|
|
buildstep_ninja "runtimes/$arch/install" ninja install
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
popd
|
|
|
|
done
|
|
|
|
popd
|
2021-08-08 21:16:26 +00:00
|
|
|
|
2022-01-19 19:54:34 +00:00
|
|
|
pushd "$DIR/Local/clang/bin/"
|
2022-06-04 17:58:01 +00:00
|
|
|
ln -s ../../mold/bin/mold ld.mold
|
|
|
|
|
|
|
|
for arch in $ARCHS; do
|
|
|
|
ln -s clang "$arch"-pc-serenity-clang
|
|
|
|
ln -s clang++ "$arch"-pc-serenity-clang++
|
2023-03-23 01:12:41 +00:00
|
|
|
ln -s llvm-nm "$arch"-pc-serenity-nm
|
2022-06-04 17:58:01 +00:00
|
|
|
echo "--sysroot=$BUILD/${arch}clang/Root" > "$arch"-pc-serenity.cfg
|
|
|
|
done
|
2022-01-19 19:54:34 +00:00
|
|
|
popd
|
|
|
|
|
2021-08-05 21:45:07 +00:00
|
|
|
# === SAVE TO CACHE ===
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
|
2021-08-05 21:45:07 +00:00
|
|
|
pushd "$DIR"
|
|
|
|
if [ "$TRY_USE_LOCAL_TOOLCHAIN" = "y" ]; then
|
|
|
|
echo "::endgroup::"
|
|
|
|
echo "Building cache tar:"
|
|
|
|
|
|
|
|
echo "Building cache tar:"
|
|
|
|
|
|
|
|
rm -f "${CACHED_TOOLCHAIN_ARCHIVE}" # Just in case
|
|
|
|
|
|
|
|
tar czf "${CACHED_TOOLCHAIN_ARCHIVE}" Local/
|
|
|
|
echo "Cache (after):"
|
|
|
|
ls -l Cache
|
|
|
|
fi
|
|
|
|
popd
|