mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
Toolchain: Don't use GNU objcopy in the LLVM toolchain
Our build of LLVM's objcopy now supports the single missing feature (--update-section) that previously forced us to use the one from GNU Binutils. This means that there is no reason anymore to build Binutils alongside LLVM's tools.
This commit is contained in:
parent
b19cc3cdcb
commit
b3dbf204fc
3 changed files with 4 additions and 65 deletions
|
@ -14,7 +14,6 @@ ARCHS="$USERLAND_ARCHS aarch64"
|
||||||
|
|
||||||
MD5SUM="md5sum"
|
MD5SUM="md5sum"
|
||||||
REALPATH="realpath"
|
REALPATH="realpath"
|
||||||
MAKE="make"
|
|
||||||
NPROC="nproc"
|
NPROC="nproc"
|
||||||
INSTALL="install"
|
INSTALL="install"
|
||||||
SED="sed"
|
SED="sed"
|
||||||
|
@ -24,18 +23,15 @@ SYSTEM_NAME="$(uname -s)"
|
||||||
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
|
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
|
||||||
MD5SUM="md5 -q"
|
MD5SUM="md5 -q"
|
||||||
REALPATH="readlink -f"
|
REALPATH="readlink -f"
|
||||||
MAKE="gmake"
|
|
||||||
NPROC="sysctl -n hw.ncpuonline"
|
NPROC="sysctl -n hw.ncpuonline"
|
||||||
export CC=egcc
|
export CC=egcc
|
||||||
export CXX=eg++
|
export CXX=eg++
|
||||||
export LDFLAGS=-Wl,-z,notext
|
export LDFLAGS=-Wl,-z,notext
|
||||||
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
|
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
|
||||||
MD5SUM="md5 -q"
|
MD5SUM="md5 -q"
|
||||||
MAKE="gmake"
|
|
||||||
NPROC="sysctl -n hw.ncpu"
|
NPROC="sysctl -n hw.ncpu"
|
||||||
elif [ "$SYSTEM_NAME" = "Darwin" ]; then
|
elif [ "$SYSTEM_NAME" = "Darwin" ]; then
|
||||||
MD5SUM="md5 -q"
|
MD5SUM="md5 -q"
|
||||||
MAKE="make"
|
|
||||||
NPROC="sysctl -n hw.ncpu"
|
NPROC="sysctl -n hw.ncpu"
|
||||||
REALPATH="grealpath" # GNU coreutils
|
REALPATH="grealpath" # GNU coreutils
|
||||||
INSTALL="ginstall" # GNU coreutils
|
INSTALL="ginstall" # GNU coreutils
|
||||||
|
@ -80,13 +76,6 @@ LLVM_NAME="llvm-project-$LLVM_VERSION.src"
|
||||||
LLVM_PKG="$LLVM_NAME.tar.xz"
|
LLVM_PKG="$LLVM_NAME.tar.xz"
|
||||||
LLVM_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/$LLVM_PKG"
|
LLVM_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/$LLVM_PKG"
|
||||||
|
|
||||||
# We need GNU binutils because we use a feature that llvm-objdump doesn't support yet.
|
|
||||||
BINUTILS_VERSION="2.37"
|
|
||||||
BINUTILS_MD5SUM="1e55743d73c100b7a0d67ffb32398cdb"
|
|
||||||
BINUTILS_NAME="binutils-$BINUTILS_VERSION"
|
|
||||||
BINUTILS_PKG="${BINUTILS_NAME}.tar.gz"
|
|
||||||
BINUTILS_BASE_URL="https://ftp.gnu.org/gnu/binutils"
|
|
||||||
|
|
||||||
buildstep() {
|
buildstep() {
|
||||||
NAME=$1
|
NAME=$1
|
||||||
shift
|
shift
|
||||||
|
@ -106,9 +95,9 @@ buildstep_ninja() {
|
||||||
|
|
||||||
# === DEPENDENCIES ===
|
# === DEPENDENCIES ===
|
||||||
|
|
||||||
buildstep dependencies echo "Checking whether 'make' is available..."
|
buildstep dependencies echo "Checking whether Ninja is available..."
|
||||||
if ! command -v ${MAKE:-make} >/dev/null; then
|
if ! command -v ninja >/dev/null; then
|
||||||
buildstep dependencies echo "Please make sure to install GNU Make (for the '${MAKE:-make}' tool)."
|
buildstep dependencies echo "Please make sure to install Ninja."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -216,39 +205,6 @@ pushd "$DIR/Tarballs"
|
||||||
fi
|
fi
|
||||||
$MD5SUM "$DIR/Patches/llvm.patch" "$DIR/Patches/llvm-backport-objcopy-update-section.patch" > .patch.applied
|
$MD5SUM "$DIR/Patches/llvm.patch" "$DIR/Patches/llvm-backport-objcopy-update-section.patch" > .patch.applied
|
||||||
popd
|
popd
|
||||||
|
|
||||||
md5=""
|
|
||||||
if [ -e "$BINUTILS_PKG" ]; then
|
|
||||||
md5="$($MD5SUM $BINUTILS_PKG | cut -f1 -d' ')"
|
|
||||||
echo "bu md5='$md5'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$md5" != "$BINUTILS_MD5SUM" ]; then
|
|
||||||
rm -f "$BINUTILS_PKG"
|
|
||||||
curl -LO "$BINUTILS_BASE_URL/$BINUTILS_PKG"
|
|
||||||
else
|
|
||||||
echo "Skipped downloading GNU binutils"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d "$BINUTILS_NAME" ]; then
|
|
||||||
rm -rf "$BINUTILS_NAME"
|
|
||||||
rm -rf "$DIR/Build/clang/binutils"
|
|
||||||
fi
|
|
||||||
echo "Extracting GNU binutils"
|
|
||||||
|
|
||||||
|
|
||||||
tar -xzf "$BINUTILS_PKG"
|
|
||||||
pushd "$BINUTILS_NAME"
|
|
||||||
if [ "$dev" = "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
|
|
||||||
$MD5SUM "$DIR/Patches/binutils.patch" > .patch.applied
|
|
||||||
popd
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# === COPY HEADERS ===
|
# === COPY HEADERS ===
|
||||||
|
@ -307,21 +263,6 @@ pushd "$DIR/Build/clang"
|
||||||
buildstep "llvm/install" ninja install/strip
|
buildstep "llvm/install" ninja install/strip
|
||||||
popd
|
popd
|
||||||
|
|
||||||
mkdir -p binutils
|
|
||||||
pushd binutils
|
|
||||||
buildstep "binutils/configure" "$DIR/Tarballs/$BINUTILS_NAME/configure" --prefix="$PREFIX" \
|
|
||||||
--enable-targets="$(echo "$ARCHS" | "$SED" -E "s@(\S)(\s|$)@\1-pc-serenity,@g")" \
|
|
||||||
--program-prefix="gnu-" \
|
|
||||||
--disable-nls \
|
|
||||||
--disable-gas \
|
|
||||||
--disable-gold \
|
|
||||||
--disable-ld \
|
|
||||||
--disable-gprof \
|
|
||||||
--enable-shared
|
|
||||||
buildstep "binutils/build" "$MAKE" -j "$MAKEJOBS"
|
|
||||||
buildstep "binutils/install" "$MAKE" install
|
|
||||||
popd
|
|
||||||
|
|
||||||
for arch in $ARCHS; do
|
for arch in $ARCHS; do
|
||||||
mkdir -p runtimes/"$arch"
|
mkdir -p runtimes/"$arch"
|
||||||
pushd runtimes/"$arch"
|
pushd runtimes/"$arch"
|
||||||
|
|
|
@ -71,7 +71,6 @@ echo SYSROOT is "$SYSROOT"
|
||||||
|
|
||||||
mkdir -p "$DIR/Tarballs"
|
mkdir -p "$DIR/Tarballs"
|
||||||
|
|
||||||
# Note: The version number and hash in BuildClang.sh needs to be kept in sync with this.
|
|
||||||
BINUTILS_VERSION="2.37"
|
BINUTILS_VERSION="2.37"
|
||||||
BINUTILS_MD5SUM="1e55743d73c100b7a0d67ffb32398cdb"
|
BINUTILS_MD5SUM="1e55743d73c100b7a0d67ffb32398cdb"
|
||||||
BINUTILS_NAME="binutils-$BINUTILS_VERSION"
|
BINUTILS_NAME="binutils-$BINUTILS_VERSION"
|
||||||
|
|
|
@ -25,8 +25,7 @@ set(CMAKE_RANLIB ${TOOLCHAIN_PATH}/llvm-ranlib)
|
||||||
set(CMAKE_STRIP ${TOOLCHAIN_PATH}/llvm-strip)
|
set(CMAKE_STRIP ${TOOLCHAIN_PATH}/llvm-strip)
|
||||||
set(CMAKE_AR ${TOOLCHAIN_PATH}/llvm-ar)
|
set(CMAKE_AR ${TOOLCHAIN_PATH}/llvm-ar)
|
||||||
set(SERENITY_CXXFILT ${TOOLCHAIN_PATH}/llvm-cxxfilt)
|
set(SERENITY_CXXFILT ${TOOLCHAIN_PATH}/llvm-cxxfilt)
|
||||||
# FIXME: Persuade LLVM maintainers to add `--update-section` to llvm-objcopy, as it's required for the kernel symbol map.
|
set(CMAKE_OBJCOPY ${TOOLCHAIN_PATH}/llvm-objcopy)
|
||||||
set(CMAKE_OBJCOPY ${TOOLCHAIN_PATH}/gnu-objcopy)
|
|
||||||
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,max-page-size=0x1000,-z,separate-code")
|
set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,max-page-size=0x1000,-z,separate-code")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue