mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
Meta: Remove SerenityOS components not needed for Ladybird
This commit is contained in:
committed by
Andreas Kling
parent
44bb6e8390
commit
dd1fbd3513
@@ -1,275 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
# === CONFIGURATION AND SETUP ===
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# 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"
|
||||
|
||||
echo "$DIR"
|
||||
|
||||
PREFIX="$DIR/Local/clang/"
|
||||
BUILD="$DIR/../Build/"
|
||||
USERLAND_ARCHS="x86_64"
|
||||
ARCHS="$USERLAND_ARCHS aarch64 riscv64"
|
||||
|
||||
MD5SUM="md5sum"
|
||||
REALPATH="realpath"
|
||||
INSTALL="install"
|
||||
SED="sed"
|
||||
|
||||
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"
|
||||
elif [ "$SYSTEM_NAME" = "Darwin" ]; then
|
||||
MD5SUM="md5 -q"
|
||||
REALPATH="grealpath" # GNU coreutils
|
||||
INSTALL="ginstall" # GNU coreutils
|
||||
fi
|
||||
|
||||
NPROC=$(get_number_of_processing_units)
|
||||
[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
|
||||
|
||||
if [ ! -d "$BUILD" ]; then
|
||||
mkdir -p "$BUILD"
|
||||
fi
|
||||
BUILD=$($REALPATH "$BUILD")
|
||||
|
||||
dev=
|
||||
ci=
|
||||
|
||||
while [ "$1" != "" ]; do
|
||||
case $1 in
|
||||
--dev ) dev=1
|
||||
;;
|
||||
--ci ) ci=1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "$dev" = "1" ] && [ "$ci" = "1" ]; then
|
||||
echo "Please only set one of --dev or --ci."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo PREFIX is "$PREFIX"
|
||||
|
||||
mkdir -p "$DIR/Tarballs"
|
||||
|
||||
LLVM_VERSION="18.1.3"
|
||||
LLVM_MD5SUM="4f2cbf1e35f9c9377c6c89e67364c3fd"
|
||||
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
|
||||
"$@" 2>&1 | "$SED" $'s|^|\e[34m['"${NAME}"$']\e[39m |'
|
||||
}
|
||||
|
||||
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
|
||||
# its middle elision is slightly off; also it would happily elide the "\e39m" which messes up the output if the terminal is too
|
||||
# narrow), but it's still working better than the alternative.
|
||||
NAME=$1
|
||||
shift
|
||||
env NINJA_STATUS=$'\e[34m['"${NAME}"$']\e[39m [%f/%t] ' "$@"
|
||||
}
|
||||
|
||||
# === DEPENDENCIES ===
|
||||
|
||||
buildstep dependencies echo "Checking whether Ninja is available..."
|
||||
if ! command -v ninja >/dev/null; then
|
||||
buildstep dependencies echo "Please make sure to install Ninja."
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
# === 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
|
||||
|
||||
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
|
||||
|
||||
rm -rf "$DIR/Build/clang"
|
||||
|
||||
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
|
||||
git am --keep-non-patch "$DIR"/Patches/llvm/*.patch > /dev/null
|
||||
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"
|
||||
fi
|
||||
popd
|
||||
|
||||
# === COPY HEADERS ===
|
||||
|
||||
SRC_ROOT=$($REALPATH "$DIR"/..)
|
||||
FILES=$(find \
|
||||
"$SRC_ROOT"/Kernel/API \
|
||||
"$SRC_ROOT"/Kernel/Arch \
|
||||
"$SRC_ROOT"/Userland/Libraries/LibC \
|
||||
"$SRC_ROOT"/Userland/Libraries/LibELF/ELFABI.h \
|
||||
"$SRC_ROOT"/Userland/Libraries/LibRegex/RegexDefs.h \
|
||||
-name '*.h' -print)
|
||||
for arch in $ARCHS; do
|
||||
mkdir -p "$BUILD/${arch}clang"
|
||||
pushd "$BUILD/${arch}clang"
|
||||
mkdir -p Root/usr/include/
|
||||
for header in $FILES; do
|
||||
target=$(echo "$header" | "$SED" \
|
||||
-e "s|$SRC_ROOT/Kernel/|Kernel/|" \
|
||||
-e "s|$SRC_ROOT/Userland/Libraries/LibC||" \
|
||||
-e "s|$SRC_ROOT/Userland/Libraries/LibELF/|LibELF/|" \
|
||||
-e "s|$SRC_ROOT/Userland/Libraries/LibRegex/|LibRegex/|")
|
||||
buildstep "system_headers" "$INSTALL" -D "$header" "Root/usr/include/$target"
|
||||
done
|
||||
popd
|
||||
done
|
||||
unset SRC_ROOT
|
||||
|
||||
# === COMPILE AND INSTALL ===
|
||||
|
||||
rm -rf "$PREFIX"
|
||||
mkdir -p "$PREFIX"
|
||||
|
||||
mkdir -p "$DIR/Build/clang"
|
||||
|
||||
pushd "$DIR/Build/clang"
|
||||
mkdir -p llvm
|
||||
pushd llvm
|
||||
buildstep "llvm/configure" cmake "$DIR/Tarballs/$LLVM_NAME/llvm" \
|
||||
-G Ninja \
|
||||
-DSERENITY_x86_64-pc-serenity_SYSROOT="$BUILD/x86_64clang/Root" \
|
||||
-DSERENITY_aarch64-pc-serenity_SYSROOT="$BUILD/aarch64clang/Root" \
|
||||
-DSERENITY_riscv64-pc-serenity_SYSROOT="$BUILD/riscv64clang/Root" \
|
||||
-DSERENITY_x86_64-pc-serenity_STUBS="$DIR/Stubs/x86_64" \
|
||||
-DSERENITY_aarch64-pc-serenity_STUBS="$DIR/Stubs/aarch64" \
|
||||
-DSERENITY_riscv64-pc-serenity_STUBS="$DIR/Stubs/riscv64" \
|
||||
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
||||
-DSERENITY_MODULE_PATH="$DIR/CMake" \
|
||||
-C "$DIR/CMake/LLVMConfig.cmake" \
|
||||
${link_lld:+"-DLLVM_ENABLE_LLD=ON"} \
|
||||
${dev:+"-DLLVM_CCACHE_BUILD=ON"} \
|
||||
${ci:+"-DLLVM_CCACHE_BUILD=ON"} \
|
||||
${ci:+"-DLLVM_CCACHE_DIR=$LLVM_CCACHE_DIR"}
|
||||
|
||||
buildstep_ninja "llvm/build" ninja -j "$MAKEJOBS"
|
||||
buildstep_ninja "llvm/install" ninja install/strip
|
||||
popd
|
||||
popd
|
||||
|
||||
pushd "$DIR/Local/clang/bin/"
|
||||
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++
|
||||
ln -s llvm-nm "$arch"-pc-serenity-nm
|
||||
echo "--sysroot=$BUILD/${arch}clang/Root" > "$arch"-pc-serenity.cfg
|
||||
done
|
||||
popd
|
||||
@@ -1,35 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
# This file will need to be run in bash.
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "${DIR}/../Meta/shell_include.sh"
|
||||
|
||||
exit_if_running_as_root "Do not run BuildFuseExt2.sh as root, parts of your Toolchain directory will become root-owned"
|
||||
|
||||
export PATH="/usr/local/opt/m4/bin:$PATH"
|
||||
|
||||
die() {
|
||||
echo "die: $*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ "$OSTYPE" != "darwin"* ]]; then
|
||||
die "This script makes sense to be run only on macOS"
|
||||
fi
|
||||
|
||||
mkdir -p "$DIR"/Tarballs
|
||||
pushd "$DIR"/Tarballs
|
||||
|
||||
if [ ! -d fuse-ext2 ]; then
|
||||
git clone https://github.com/alperakcan/fuse-ext2.git
|
||||
fi
|
||||
|
||||
cd fuse-ext2
|
||||
./autogen.sh
|
||||
CFLAGS="-I/usr/local/include/osxfuse/ -I/$(brew --prefix e2fsprogs)/include" LDFLAGS="-L$(brew --prefix e2fsprogs)/lib" ./configure
|
||||
make
|
||||
sudo make install
|
||||
popd
|
||||
@@ -1,130 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "${DIR}/../Meta/shell_include.sh"
|
||||
|
||||
exit_if_running_as_root "Do not run BuildGDB.sh as root, parts of your Toolchain directory will become root-owned"
|
||||
|
||||
GDB_VERSION="13.1"
|
||||
GDB_MD5SUM="4aaad768ff2585464173c091947287ec"
|
||||
GDB_NAME="gdb-$GDB_VERSION"
|
||||
GDB_PKG="${GDB_NAME}.tar.xz"
|
||||
GDB_BASE_URL="https://ftpmirror.gnu.org/gnu/gdb"
|
||||
|
||||
ARCH=${1:-"x86_64"}
|
||||
TARGET="$ARCH-pc-serenity"
|
||||
PREFIX="$DIR/Local/$ARCH-gdb"
|
||||
|
||||
echo "Building GDB $GDB_VERSION for $TARGET"
|
||||
|
||||
MD5SUM="md5sum"
|
||||
|
||||
SYSTEM_NAME="$(uname -s)"
|
||||
|
||||
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
|
||||
MD5SUM="md5 -q"
|
||||
export CC=egcc
|
||||
export CXX=eg++
|
||||
export with_gmp=/usr/local
|
||||
export LDFLAGS=-Wl,-z,notext
|
||||
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
|
||||
MD5SUM="md5 -q"
|
||||
export with_gmp=/usr/local
|
||||
export with_mpfr=/usr/local
|
||||
elif [ "$SYSTEM_NAME" = "Darwin" ]; then
|
||||
MD5SUM="md5 -q"
|
||||
fi
|
||||
|
||||
NPROC=$(get_number_of_processing_units)
|
||||
[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
|
||||
|
||||
buildstep() {
|
||||
NAME=$1
|
||||
shift
|
||||
"$@" 2>&1 | sed $'s|^|\x1b[34m['"${NAME}"$']\x1b[39m |'
|
||||
}
|
||||
|
||||
missing_lib() {
|
||||
buildstep dependencies echo "Please make sure to install the $lib library and headers." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
config_args=()
|
||||
for lib in gmp isl mpfr mpc; do
|
||||
buildstep dependencies echo "Checking whether the $lib library and headers are available..."
|
||||
if [ "$SYSTEM_NAME" = "Darwin" ]; then
|
||||
[ "$lib" = "mpc" ] && formula_name="libmpc" || formula_name="$lib"
|
||||
config_args+=("--with-$lib=$(brew --prefix --installed "$formula_name")") || missing_lib $lib
|
||||
else
|
||||
[ "$lib" = "isl" ] && header="isl/version.h" || header="$lib.h"
|
||||
if ! ${CC:-cc} -I /usr/local/include -L /usr/local/lib -l$lib -o /dev/null -xc - >/dev/null <<PROGRAM
|
||||
#include <$header>
|
||||
int main() {}
|
||||
PROGRAM
|
||||
then
|
||||
missing_lib $lib
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$SYSTEM_NAME" = "Darwin" ]; then
|
||||
config_args+=("--with-libgmp-prefix=$(brew --prefix gmp)")
|
||||
fi
|
||||
|
||||
mkdir -p "$DIR/Tarballs"
|
||||
|
||||
pushd "$DIR/Tarballs"
|
||||
md5=""
|
||||
if [ -e "$GDB_PKG" ]; then
|
||||
md5="$($MD5SUM "$GDB_PKG" | cut -f1 -d' ')"
|
||||
fi
|
||||
if [ "$md5" != "$GDB_MD5SUM" ]; then
|
||||
curl -C - -LO "$GDB_BASE_URL/$GDB_PKG"
|
||||
else
|
||||
echo "Skipped downloading $GDB_PKG"
|
||||
fi
|
||||
|
||||
md5="$($MD5SUM "$GDB_PKG" | cut -f1 -d' ')"
|
||||
echo "gdb md5='$md5'"
|
||||
if [ "$md5" != "$GDB_MD5SUM" ] ; then
|
||||
echo "gdb md5 sum mismatching, please run script again."
|
||||
rm -f "$GDB_PKG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If the source directory exists, re-extract it again in case the patches have changed.
|
||||
if [ -d ${GDB_NAME} ]; then
|
||||
rm -rf "${GDB_NAME}"
|
||||
rm -rf "$DIR/Build/$ARCH-gdb"
|
||||
fi
|
||||
echo "Extracting gdb..."
|
||||
tar -xJf "$GDB_PKG"
|
||||
|
||||
pushd "$GDB_NAME"
|
||||
for patch in "${DIR}"/Patches/gdb/*.patch; do
|
||||
patch -p1 < "${patch}" > /dev/null
|
||||
done
|
||||
popd
|
||||
popd
|
||||
|
||||
mkdir -p "$DIR/Build"
|
||||
|
||||
rm -rf "$DIR/Build/$ARCH-gdb"
|
||||
mkdir "$DIR/Build/$ARCH-gdb"
|
||||
|
||||
pushd "$DIR/Build/$ARCH-gdb"
|
||||
unset PKG_CONFIG_LIBDIR # Just in case
|
||||
|
||||
buildstep "gdb/configure" "$DIR"/Tarballs/$GDB_NAME/configure --prefix="$PREFIX" \
|
||||
--target="$TARGET" \
|
||||
--disable-werror \
|
||||
--disable-nls \
|
||||
--with-python \
|
||||
"${config_args[@]}" || exit 1
|
||||
|
||||
buildstep "gdb/build" make MAKEINFO=true -j "$MAKEJOBS" || exit 1
|
||||
buildstep "gdb/install" make MAKEINFO=true install || exit 1
|
||||
popd
|
||||
@@ -1,326 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
# This file will need to be run in bash, for now.
|
||||
|
||||
# === CONFIGURATION AND SETUP ===
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "${DIR}/../Meta/shell_include.sh"
|
||||
|
||||
exit_if_running_as_root "Do not run BuildGNU.sh as root, your Build directory will become root-owned"
|
||||
|
||||
echo "$DIR"
|
||||
|
||||
ARCH=${ARCH:-"x86_64"}
|
||||
TARGET="$ARCH-pc-serenity"
|
||||
PREFIX="$DIR/Local/$ARCH"
|
||||
BUILD="$DIR/../Build/$ARCH"
|
||||
SYSROOT="$BUILD/Root"
|
||||
|
||||
MAKE="make"
|
||||
MD5SUM="md5sum"
|
||||
REALPATH="realpath"
|
||||
|
||||
if command -v ginstall &>/dev/null; then
|
||||
INSTALL=ginstall
|
||||
else
|
||||
INSTALL=install
|
||||
fi
|
||||
|
||||
SYSTEM_NAME="$(uname -s)"
|
||||
|
||||
# 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.
|
||||
export CFLAGS="-g0 -O2 -mtune=native"
|
||||
export CXXFLAGS="-g0 -O2 -mtune=native"
|
||||
|
||||
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
|
||||
MAKE=gmake
|
||||
MD5SUM="md5 -q"
|
||||
REALPATH="readlink -f"
|
||||
export CC=egcc
|
||||
export CXX=eg++
|
||||
export with_gmp=/usr/local
|
||||
export LDFLAGS=-Wl,-z,notext
|
||||
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
|
||||
MAKE=gmake
|
||||
MD5SUM="md5 -q"
|
||||
export with_gmp=/usr/local
|
||||
export with_mpfr=/usr/local
|
||||
elif [ "$SYSTEM_NAME" = "Darwin" ]; then
|
||||
MD5SUM="md5 -q"
|
||||
fi
|
||||
|
||||
# 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")
|
||||
|
||||
git_patch=
|
||||
while [ "$1" != "" ]; do
|
||||
case $1 in
|
||||
--dev ) git_patch=1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
echo PREFIX is "$PREFIX"
|
||||
echo SYSROOT is "$SYSROOT"
|
||||
|
||||
mkdir -p "$DIR/Tarballs"
|
||||
|
||||
BINUTILS_VERSION="2.41"
|
||||
BINUTILS_MD5SUM="256d7e0ad998e423030c84483a7c1e30"
|
||||
BINUTILS_NAME="binutils-$BINUTILS_VERSION"
|
||||
BINUTILS_PKG="${BINUTILS_NAME}.tar.xz"
|
||||
BINUTILS_BASE_URL="https://ftpmirror.gnu.org/gnu/binutils"
|
||||
|
||||
# Note: If you bump the gcc version, you also have to update the matching
|
||||
# GCC_VERSION variable in the project's root CMakeLists.txt
|
||||
GCC_VERSION="13.2.0"
|
||||
GCC_MD5SUM="e0e48554cc6e4f261d55ddee9ab69075"
|
||||
GCC_NAME="gcc-$GCC_VERSION"
|
||||
GCC_PKG="${GCC_NAME}.tar.xz"
|
||||
GCC_BASE_URL="https://ftpmirror.gnu.org/gnu/gcc"
|
||||
|
||||
buildstep() {
|
||||
NAME=$1
|
||||
shift
|
||||
"$@" 2>&1 | sed $'s|^|\x1b[34m['"${NAME}"$']\x1b[39m |'
|
||||
}
|
||||
|
||||
# === 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
|
||||
|
||||
# === DOWNLOAD AND PATCH ===
|
||||
pushd "$DIR/Tarballs"
|
||||
md5=""
|
||||
if [ -e "$BINUTILS_PKG" ]; then
|
||||
md5="$($MD5SUM $BINUTILS_PKG | cut -f1 -d' ')"
|
||||
echo "binutils md5='$md5'"
|
||||
fi
|
||||
if [ "$md5" != ${BINUTILS_MD5SUM} ] ; then
|
||||
rm -f $BINUTILS_PKG
|
||||
curl -LO "$BINUTILS_BASE_URL/$BINUTILS_PKG"
|
||||
else
|
||||
echo "Skipped downloading binutils"
|
||||
fi
|
||||
|
||||
md5=""
|
||||
if [ -e "$GCC_PKG" ]; then
|
||||
md5="$($MD5SUM ${GCC_PKG} | cut -f1 -d' ')"
|
||||
echo "gcc md5='$md5'"
|
||||
fi
|
||||
if [ "$md5" != ${GCC_MD5SUM} ] ; then
|
||||
rm -f $GCC_PKG
|
||||
curl -LO "$GCC_BASE_URL/$GCC_NAME/$GCC_PKG"
|
||||
else
|
||||
echo "Skipped downloading gcc"
|
||||
fi
|
||||
|
||||
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}"
|
||||
fi
|
||||
echo "Extracting binutils..."
|
||||
tar -xJf ${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"
|
||||
fi
|
||||
|
||||
|
||||
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}"
|
||||
fi
|
||||
echo "Extracting gcc..."
|
||||
tar -xJf ${GCC_PKG}
|
||||
|
||||
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
|
||||
popd
|
||||
else
|
||||
echo "Using existing GCC source directory"
|
||||
fi
|
||||
popd
|
||||
|
||||
|
||||
# === COMPILE AND INSTALL ===
|
||||
|
||||
rm -rf "$PREFIX"
|
||||
mkdir -p "$PREFIX"
|
||||
|
||||
NPROC=$(get_number_of_processing_units)
|
||||
[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
|
||||
|
||||
mkdir -p "$DIR/Build/$ARCH"
|
||||
|
||||
pushd "$DIR/Build/$ARCH"
|
||||
unset PKG_CONFIG_LIBDIR # Just in case
|
||||
|
||||
rm -rf binutils
|
||||
mkdir -p binutils
|
||||
|
||||
pushd binutils
|
||||
echo "XXX configure binutils"
|
||||
|
||||
# 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
|
||||
|
||||
buildstep "binutils/configure" "$DIR"/Tarballs/$BINUTILS_NAME/configure --prefix="$PREFIX" \
|
||||
--target="$TARGET" \
|
||||
--with-sysroot="$SYSROOT" \
|
||||
--enable-shared \
|
||||
--disable-nls \
|
||||
${CI:+"--quiet"} || exit 1
|
||||
if [ "$SYSTEM_NAME" = "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.
|
||||
buildstep "binutils/build" "$MAKE" -j "$MAKEJOBS" || true
|
||||
pushd intl
|
||||
buildstep "binutils/build" "$MAKE" all-yes
|
||||
popd
|
||||
fi
|
||||
echo "XXX build binutils"
|
||||
buildstep "binutils/build" "$MAKE" MAKEINFO=true -j "$MAKEJOBS" || exit 1
|
||||
buildstep "binutils/install" "$MAKE" MAKEINFO=true install || exit 1
|
||||
popd
|
||||
|
||||
echo "XXX serenity libc headers"
|
||||
mkdir -p "$BUILD"
|
||||
pushd "$BUILD"
|
||||
mkdir -p Root/usr/include/
|
||||
SRC_ROOT=$($REALPATH "$DIR"/..)
|
||||
FILES=$(find \
|
||||
"$SRC_ROOT"/Kernel/API \
|
||||
"$SRC_ROOT"/Kernel/Arch \
|
||||
"$SRC_ROOT"/Userland/Libraries/LibC \
|
||||
"$SRC_ROOT"/Userland/Libraries/LibELF/ELFABI.h \
|
||||
"$SRC_ROOT"/Userland/Libraries/LibRegex/RegexDefs.h \
|
||||
-name '*.h' -print)
|
||||
for header in $FILES; do
|
||||
target=$(echo "$header" | sed \
|
||||
-e "s|$SRC_ROOT/Userland/Libraries/LibC||" \
|
||||
-e "s|$SRC_ROOT/Kernel/|Kernel/|" \
|
||||
-e "s|$SRC_ROOT/Userland/Libraries/LibELF/|LibELF/|" \
|
||||
-e "s|$SRC_ROOT/Userland/Libraries/LibRegex/|LibRegex/|")
|
||||
buildstep "system_headers" mkdir -p "$(dirname "Root/usr/include/$target")"
|
||||
buildstep "system_headers" $INSTALL "$header" "Root/usr/include/$target"
|
||||
done
|
||||
unset SRC_ROOT
|
||||
popd
|
||||
|
||||
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
|
||||
perl -pi -e 's/-no-pie/-nopie/g' "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/configure"
|
||||
fi
|
||||
|
||||
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 \
|
||||
--disable-libstdcxx-pch \
|
||||
--enable-shared \
|
||||
--enable-languages=c,c++,objc,obj-c++ \
|
||||
--enable-default-pie \
|
||||
--enable-lto \
|
||||
--enable-threads=posix \
|
||||
--enable-initfini-array \
|
||||
--with-linker-hash-style=gnu \
|
||||
${CI:+"--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
|
||||
|
||||
popd
|
||||
|
||||
pushd "$DIR/Local/$ARCH/$ARCH-pc-serenity/bin"
|
||||
buildstep "mold_symlink" ln -s ../../../mold/bin/mold ld.mold
|
||||
popd
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script builds the mold linker that can optionally be used for linking
|
||||
# the SerenityOS userland.
|
||||
set -e
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "${DIR}/../Meta/shell_include.sh"
|
||||
|
||||
exit_if_running_as_root "Do not run BuildMold.sh as root, parts of your Toolchain directory will become root-owned"
|
||||
|
||||
NPROC=$(get_number_of_processing_units)
|
||||
[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
|
||||
|
||||
mkdir -p "$DIR"/Tarballs
|
||||
pushd "$DIR"/Tarballs
|
||||
|
||||
if [ "$1" = "--git" ]; then
|
||||
[ ! -d mold ] && git clone https://github.com/rui314/mold.git
|
||||
|
||||
cd mold
|
||||
|
||||
git pull
|
||||
else
|
||||
VERSION=1.5.1
|
||||
[ ! -e mold-$VERSION.tar.gz ] && curl -L "https://github.com/rui314/mold/archive/refs/tags/v$VERSION.tar.gz" -o mold-$VERSION.tar.gz
|
||||
[ ! -e mold-$VERSION ] && tar -xzf mold-$VERSION.tar.gz
|
||||
cd mold-$VERSION
|
||||
fi
|
||||
|
||||
MOLD_BUILD="$DIR"/Build/mold
|
||||
cmake -B "$MOLD_BUILD" -S. -DCMAKE_INSTALL_PREFIX="$DIR"/Local/mold
|
||||
make -C "$MOLD_BUILD" install -j"$MAKEJOBS"
|
||||
|
||||
popd
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# This file will need to be run in bash, for now.
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "${DIR}/../Meta/shell_include.sh"
|
||||
|
||||
exit_if_running_as_root "Do not run BuildPython.sh as root, parts of your Toolchain directory will become root-owned"
|
||||
|
||||
PREFIX_DIR="$DIR/Local/python"
|
||||
BUILD_DIR="$DIR/Build/python"
|
||||
TARBALLS_DIR="$DIR/Tarballs"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "$DIR/../Ports/python3/version.sh"
|
||||
|
||||
mkdir -p "${TARBALLS_DIR}"
|
||||
|
||||
pushd "${TARBALLS_DIR}"
|
||||
if [ ! -e "${PYTHON_ARCHIVE}" ]; then
|
||||
echo "Downloading Python from ${PYTHON_ARCHIVE_URL}..."
|
||||
curl -O "${PYTHON_ARCHIVE_URL}"
|
||||
else
|
||||
echo "${PYTHON_ARCHIVE} already exists, not downloading archive"
|
||||
fi
|
||||
|
||||
if ! sha256sum --status -c <(echo "${PYTHON_ARCHIVE_SHA256SUM}" "${PYTHON_ARCHIVE}"); then
|
||||
echo "Python archive SHA256 sum mismatch, please run script again"
|
||||
rm -f "${PYTHON_ARCHIVE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "Python-${PYTHON_VERSION}" ]; then
|
||||
echo "Extracting ${PYTHON_ARCHIVE}..."
|
||||
tar -xf "${PYTHON_ARCHIVE}"
|
||||
else
|
||||
echo "Python-${PYTHON_VERSION} already exists, not extracting archive"
|
||||
fi
|
||||
popd
|
||||
|
||||
NPROC=$(get_number_of_processing_units)
|
||||
[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
|
||||
|
||||
mkdir -p "${PREFIX_DIR}"
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
|
||||
pushd "${BUILD_DIR}"
|
||||
"${TARBALLS_DIR}"/Python-"${PYTHON_VERSION}"/configure --prefix="${PREFIX_DIR}"
|
||||
make -j "${MAKEJOBS}"
|
||||
make install
|
||||
popd
|
||||
@@ -1,75 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# This file will need to be run in bash, for now.
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "${DIR}/../Meta/shell_include.sh"
|
||||
|
||||
exit_if_running_as_root "Do not run BuildQemu.sh as root, parts of your Toolchain directory will become root-owned"
|
||||
|
||||
echo "$DIR"
|
||||
|
||||
PREFIX="$DIR/Local/qemu"
|
||||
BUILD=$(realpath "$DIR/../Build")
|
||||
SYSROOT="$BUILD/Root"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "${DIR}/../Ports/qemu/version.sh"
|
||||
|
||||
echo PREFIX is "$PREFIX"
|
||||
echo SYSROOT is "$SYSROOT"
|
||||
|
||||
mkdir -p "$DIR/Tarballs"
|
||||
|
||||
pushd "$DIR/Tarballs"
|
||||
if [ ! -e "${QEMU_ARCHIVE}" ]; then
|
||||
curl -C - -O "${QEMU_ARCHIVE_URL}"
|
||||
else
|
||||
echo "Skipped downloading ${QEMU_ARCHIVE}"
|
||||
fi
|
||||
|
||||
if ! sha256sum --status -c <(echo "${QEMU_ARCHIVE_SHA256SUM}" "${QEMU_ARCHIVE}"); then
|
||||
echo "qemu sha256 sum mismatching, please run script again."
|
||||
rm -f "${QEMU_ARCHIVE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d "qemu-$QEMU_VERSION" ]; then
|
||||
rm -rf "qemu-$QEMU_VERSION"
|
||||
fi
|
||||
|
||||
echo "Extracting qemu..."
|
||||
tar -xf "${QEMU_ARCHIVE}"
|
||||
popd
|
||||
|
||||
mkdir -p "$PREFIX"
|
||||
mkdir -p "$DIR/Build/qemu"
|
||||
|
||||
NPROC=$(get_number_of_processing_units)
|
||||
[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
|
||||
|
||||
EXTRA_ARGS=""
|
||||
if [[ $(uname) == "Darwin" ]]
|
||||
then
|
||||
UI_LIB=cocoa
|
||||
|
||||
# SDL causes a crash on startup: "NSWindow drag regions should only be invalidated on the Main Thread!"
|
||||
EXTRA_ARGS="--disable-sdl"
|
||||
else
|
||||
UI_LIB=gtk
|
||||
fi
|
||||
|
||||
echo Using $UI_LIB based UI
|
||||
|
||||
pushd "$DIR/Build/qemu"
|
||||
"$DIR"/Tarballs/qemu-"${QEMU_VERSION}"/configure --prefix="$PREFIX" \
|
||||
--target-list=aarch64-softmmu,x86_64-softmmu,riscv64-softmmu \
|
||||
--enable-$UI_LIB \
|
||||
--enable-slirp \
|
||||
$EXTRA_ARGS || exit 1
|
||||
make -j "$MAKEJOBS" || exit 1
|
||||
make install || exit 1
|
||||
popd
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# This file will need to be run in bash, for now.
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "${DIR}/../Meta/shell_include.sh"
|
||||
|
||||
exit_if_running_as_root "Do not run BuildRuby.sh as root, parts of your Toolchain directory will become root-owned"
|
||||
|
||||
PREFIX_DIR="$DIR/Local/ruby"
|
||||
BUILD_DIR="$DIR/Build/ruby"
|
||||
TARBALLS_DIR="$DIR/Tarballs"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "$DIR/../Ports/ruby/version.sh"
|
||||
|
||||
mkdir -p "${TARBALLS_DIR}"
|
||||
|
||||
pushd "${TARBALLS_DIR}"
|
||||
if [ ! -e "${RUBY_ARCHIVE}" ]; then
|
||||
echo "Downloading Ruby from ${RUBY_ARCHIVE_URL}..."
|
||||
curl -O "${RUBY_ARCHIVE_URL}"
|
||||
else
|
||||
echo "${RUBY_ARCHIVE} already exists, not downloading archive"
|
||||
fi
|
||||
|
||||
if ! sha256sum --status -c <(echo "${RUBY_ARCHIVE_SHA256SUM}" "${RUBY_ARCHIVE}"); then
|
||||
echo "Ruby archive SHA256 sum mismatch, please run script again"
|
||||
rm -f "${RUBY_ARCHIVE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "ruby-${RUBY_VERSION}" ]; then
|
||||
echo "Extracting ${RUBY_ARCHIVE}..."
|
||||
tar -xf "${RUBY_ARCHIVE}"
|
||||
else
|
||||
echo "ruby-${RUBY_VERSION} already exists, not extracting archive"
|
||||
fi
|
||||
popd
|
||||
|
||||
NPROC=$(get_number_of_processing_units)
|
||||
[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
|
||||
|
||||
mkdir -p "${PREFIX_DIR}"
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
|
||||
pushd "${BUILD_DIR}"
|
||||
"${TARBALLS_DIR}"/ruby-"${RUBY_VERSION}"/configure --prefix="${PREFIX_DIR}"
|
||||
make -j "${MAKEJOBS}"
|
||||
make install
|
||||
popd
|
||||
@@ -1,47 +0,0 @@
|
||||
set(CMAKE_SYSTEM_NAME SerenityOS)
|
||||
set(CMAKE_SYSTEM_PROCESSOR "@SERENITY_ARCH@")
|
||||
|
||||
set(triple @SERENITY_ARCH@-pc-serenity)
|
||||
set(TOOLCHAIN_ROOT @SERENITY_SOURCE_DIR@/Toolchain/Local/clang/)
|
||||
set(TOOLCHAIN_PATH ${TOOLCHAIN_ROOT}/bin)
|
||||
|
||||
# where to read from/write to
|
||||
set(CMAKE_SYSROOT @SERENITY_BUILD_DIR@/Root)
|
||||
set(CMAKE_STAGING_PREFIX @SERENITY_BUILD_DIR@/Root/usr/local)
|
||||
set(CMAKE_INSTALL_PREFIX /usr/local)
|
||||
set(CMAKE_INSTALL_DATAROOTDIR share)
|
||||
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PATH}/clang)
|
||||
set(CMAKE_C_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PATH}/clang++)
|
||||
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PATH}/clang)
|
||||
set(CMAKE_ASM_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_LINKER ${TOOLCHAIN_PATH}/ld.lld)
|
||||
set(CMAKE_AR ${TOOLCHAIN_PATH}/llvm-ar)
|
||||
set(CMAKE_NM ${TOOLCHAIN_PATH}/llvm-nm)
|
||||
set(CMAKE_OBJCOPY ${TOOLCHAIN_PATH}/llvm-objcopy)
|
||||
set(CMAKE_RANLIB ${TOOLCHAIN_PATH}/llvm-ranlib)
|
||||
set(CMAKE_STRIP ${TOOLCHAIN_PATH}/llvm-strip)
|
||||
set(SERENITY_CXXFILT ${TOOLCHAIN_PATH}/llvm-cxxfilt)
|
||||
|
||||
# FIXME: We could eliminate this setting by building LibC and support asm files (crti.o, crtn.o)
|
||||
# in a separate build stage before the main build to ensure that LibC is available
|
||||
# for the try_compile check for the main build.
|
||||
# Note that `set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)` is not a suitable replacement,
|
||||
# since applications might try and use `try_compile()` to detect which library a symbol is in,
|
||||
# which doesn't work when using static linking.
|
||||
# Instead, just tell CMake directly that the compiler works fine, so that it doesn't have to run
|
||||
# a compile check before the build.
|
||||
set(CMAKE_C_COMPILER_WORKS TRUE)
|
||||
set(CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
|
||||
|
||||
# Sets a common default architecture for all toolchains. Be sure to update this in GNUToolchain as well!
|
||||
if("${SERENITY_ARCH}" STREQUAL "riscv64")
|
||||
add_compile_options(-march=rv64gc)
|
||||
endif()
|
||||
@@ -1,44 +0,0 @@
|
||||
set(CMAKE_SYSTEM_NAME SerenityOS)
|
||||
set(CMAKE_SYSTEM_PROCESSOR "@SERENITY_ARCH@")
|
||||
|
||||
set(triple @SERENITY_ARCH@-pc-serenity)
|
||||
set(TOOLCHAIN_PATH @SERENITY_SOURCE_DIR@/Toolchain/Local/@SERENITY_ARCH@/bin)
|
||||
set(TOOLCHAIN_PREFIX ${TOOLCHAIN_PATH}/${triple}-)
|
||||
|
||||
# where to read from/write to
|
||||
set(CMAKE_SYSROOT @SERENITY_BUILD_DIR@/Root)
|
||||
set(CMAKE_STAGING_PREFIX @SERENITY_BUILD_DIR@/Root/usr/local)
|
||||
set(CMAKE_INSTALL_PREFIX /usr/local)
|
||||
set(CMAKE_INSTALL_DATAROOTDIR share)
|
||||
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
|
||||
set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}gcc)
|
||||
set(CMAKE_LINKER ${TOOLCHAIN_PREFIX}ld)
|
||||
set(CMAKE_AR ${TOOLCHAIN_PREFIX}gcc-ar)
|
||||
set(CMAKE_NM ${TOOLCHAIN_PREFIX}gcc-nm)
|
||||
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)
|
||||
set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}gcc-ranlib)
|
||||
set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}strip)
|
||||
set(SERENITY_CXXFILT ${TOOLCHAIN_PREFIX}c++filt)
|
||||
|
||||
# FIXME: We could eliminate this setting by building LibC and support asm files (crti.o, crtn.o)
|
||||
# in a separate build stage before the main build to ensure that LibC is available
|
||||
# for the try_compile check for the main build.
|
||||
# Note that `set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)` is not a suitable replacement,
|
||||
# since applications might try and use `try_compile()` to detect which library a symbol is in,
|
||||
# which doesn't work when using static linking.
|
||||
# Instead, just tell CMake directly that the compiler works fine, so that it doesn't have to run
|
||||
# a compile check before the build.
|
||||
set(CMAKE_C_COMPILER_WORKS TRUE)
|
||||
set(CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
|
||||
|
||||
# Sets a common default architecture for all toolchains. Be sure to update this in ClangToolchain as well!
|
||||
if("${SERENITY_ARCH}" STREQUAL "riscv64")
|
||||
add_compile_options(-march=rv64gc)
|
||||
endif()
|
||||
@@ -1,115 +0,0 @@
|
||||
# This file specifies the options used for building the Clang compiler, LLD linker and the compiler builtins library
|
||||
|
||||
if (CMAKE_VERSION VERSION_EQUAL "3.29.0" OR CMAKE_VERSION VERSION_EQUAL "3.29.1")
|
||||
message(FATAL_ERROR "CMake versions 3.29.0 and 3.29.1 are known to not install LLVM correctly. "
|
||||
"Please either downgrade CMake or update it to 3.29.2+.")
|
||||
endif()
|
||||
|
||||
# Note: We force the cmake module path for all dependent projects to include our custom directory
|
||||
# That has the Platform/SerenityOS.cmake definition
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${SERENITY_MODULE_PATH}" CACHE STRING "Modules for CMake")
|
||||
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
|
||||
|
||||
set(LLVM_TARGETS_TO_BUILD "X86;AArch64;RISCV" CACHE STRING "")
|
||||
|
||||
set(LLVM_ENABLE_PROJECTS "llvm;clang;lld;clang-tools-extra" CACHE STRING "")
|
||||
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libunwind;libcxxabi;libcxx" CACHE STRING "")
|
||||
|
||||
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
|
||||
set(LLVM_ENABLE_BINDINGS OFF CACHE BOOL "")
|
||||
set(LLVM_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
|
||||
set(LLVM_BUILD_UTILS ON CACHE BOOL "")
|
||||
set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
|
||||
set(LLVM_BUILD_LLVM_DYLIB ON CACHE BOOL "")
|
||||
set(LLVM_LINK_LLVM_DYLIB ON CACHE BOOL "")
|
||||
set(LLVM_INSTALL_UTILS ON CACHE BOOL "")
|
||||
set(LLVM_INSTALL_TOOLCHAIN_ONLY OFF CACHE BOOL "Don't install headers, utils, and tools")
|
||||
set(LLVM_INSTALL_BINUTILS_SYMLINKS OFF CACHE BOOL "")
|
||||
|
||||
if(DEFINED ENV{CLANG_ENABLE_CLANGD} AND "$ENV{CLANG_ENABLE_CLANGD}" STREQUAL "ON")
|
||||
message(STATUS "Enabling clangd as a part of toolchain build")
|
||||
set(CLANG_ENABLE_CLANGD ON CACHE BOOL "" FORCE)
|
||||
else()
|
||||
message(STATUS "Disabling clangd as a part of toolchain build")
|
||||
set(CLANG_ENABLE_CLANGD OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
foreach(target x86_64-pc-serenity;aarch64-pc-serenity;riscv64-pc-serenity)
|
||||
list(APPEND targets "${target}")
|
||||
|
||||
set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
|
||||
set(RUNTIMES_${target}_CMAKE_SYSROOT ${SERENITY_${target}_SYSROOT} CACHE PATH "")
|
||||
# Prevent configure checks from trying to link to the not-yet-built startup files & libunwind.
|
||||
set(compiler_flags "-Wno-unused-command-line-argument -nostartfiles -L${SERENITY_${target}_STUBS}")
|
||||
set(RUNTIMES_${target}_CMAKE_C_FLAGS ${compiler_flags} CACHE STRING "")
|
||||
set(RUNTIMES_${target}_CMAKE_CXX_FLAGS ${compiler_flags} CACHE STRING "")
|
||||
set(RUNTIMES_${target}_COMPILER_RT_BUILD_CRT ON CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_COMPILER_RT_BUILD_MEMPROF OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_COMPILER_RT_BUILD_PROFILE ON CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_COMPILER_RT_BUILD_ORC OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME SerenityOS CACHE STRING "")
|
||||
set(RUNTIMES_${target}_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} CACHE STRING "")
|
||||
|
||||
set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
|
||||
set(BUILTINS_${target}_CMAKE_SYSROOT ${SERENITY_${target}_SYSROOT} CACHE PATH "")
|
||||
# Explicitly set these so that host CFLAGS/CXXFLAGS don't get passed to the cross compiler.
|
||||
set(BUILTINS_${target}_CMAKE_C_FLAGS "" CACHE STRING "")
|
||||
set(BUILTINS_${target}_CMAKE_CXX_FLAGS "" CACHE STRING "")
|
||||
set(BUILTINS_${target}_COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN OFF CACHE BOOL "")
|
||||
set(BUILTINS_${target}_CMAKE_SYSTEM_NAME SerenityOS CACHE STRING "")
|
||||
set(BUILTINS_${target}_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} CACHE STRING "")
|
||||
|
||||
set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
|
||||
|
||||
set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
|
||||
|
||||
# Hardcode autodetection results for libm, libdl, and libpthread.
|
||||
# This keeps us from accidentially detecting those libraries as being present
|
||||
# if we build the toolchain with a populated sysroot (which features the
|
||||
# compability linker scripts).
|
||||
# TODO: Figure out if we can always build against the Stubs directory instead.
|
||||
set(RUNTIMES_${target}_LIBCXXABI_HAS_DL_LIB OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBCXXABI_HAS_PTHREAD_LIB OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBCXX_HAS_M_LIB OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBCXX_HAS_PTHREAD_LIB OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBUNWIND_HAS_DL_LIB OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBUNWIND_HAS_PTHREAD_LIB OFF CACHE BOOL "")
|
||||
endforeach()
|
||||
|
||||
set(LLVM_TOOLCHAIN_TOOLS
|
||||
llvm-addr2line
|
||||
llvm-ar
|
||||
llvm-config
|
||||
llvm-cov
|
||||
llvm-cxxfilt
|
||||
llvm-dwarfdump
|
||||
llvm-ifs
|
||||
llvm-lib
|
||||
llvm-nm
|
||||
llvm-objcopy
|
||||
llvm-objdump
|
||||
llvm-profdata
|
||||
llvm-rc
|
||||
llvm-ranlib
|
||||
llvm-readelf
|
||||
llvm-readobj
|
||||
llvm-size
|
||||
llvm-strings
|
||||
llvm-strip
|
||||
llvm-symbolizer
|
||||
CACHE STRING "")
|
||||
|
||||
set(LLVM_TOOLCHAIN_UTILITIES
|
||||
FileCheck
|
||||
CACHE STRING ""
|
||||
)
|
||||
|
||||
set(LLVM_RUNTIME_TARGETS ${targets} CACHE STRING "")
|
||||
set(LLVM_BUILTIN_TARGETS ${targets} CACHE STRING "")
|
||||
@@ -1,16 +0,0 @@
|
||||
[binaries]
|
||||
c = '@SERENITY_ARCH@-pc-serenity-clang'
|
||||
cpp = '@SERENITY_ARCH@-pc-serenity-clang++'
|
||||
ar = 'llvm-ar'
|
||||
ranlib = 'llvm-ranlib'
|
||||
pkgconfig = 'pkg-config'
|
||||
|
||||
[properties]
|
||||
sys_root = '@SERENITY_BUILD_DIR@/Root'
|
||||
needs_exe_wrapper = true
|
||||
|
||||
[host_machine]
|
||||
system = 'serenity'
|
||||
cpu_family = '@SERENITY_ARCH@'
|
||||
cpu = '@SERENITY_ARCH@'
|
||||
endian = 'little'
|
||||
@@ -1,16 +0,0 @@
|
||||
[binaries]
|
||||
c = '@SERENITY_ARCH@-pc-serenity-gcc'
|
||||
cpp = '@SERENITY_ARCH@-pc-serenity-g++'
|
||||
ar = '@SERENITY_ARCH@-pc-serenity-ar'
|
||||
ranlib = '@SERENITY_ARCH@-pc-serenity-ranlib'
|
||||
pkgconfig = 'pkg-config'
|
||||
|
||||
[properties]
|
||||
sys_root = '@SERENITY_BUILD_DIR@/Root'
|
||||
needs_exe_wrapper = true
|
||||
|
||||
[host_machine]
|
||||
system = 'serenity'
|
||||
cpu_family = '@SERENITY_ARCH@'
|
||||
cpu = '@SERENITY_ARCH@'
|
||||
endian = 'little'
|
||||
@@ -1,32 +0,0 @@
|
||||
FROM ubuntu:22.10
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update -y \
|
||||
&& apt-get install -y \
|
||||
build-essential \
|
||||
ccache \
|
||||
cmake \
|
||||
curl \
|
||||
g++-12 \
|
||||
gcc-12 \
|
||||
e2fsprogs \
|
||||
genext2fs \
|
||||
git \
|
||||
imagemagick \
|
||||
libgmp-dev \
|
||||
libgtk-3-dev \
|
||||
libmpc-dev \
|
||||
libmpfr-dev \
|
||||
libpixman-1-dev \
|
||||
libsdl2-dev \
|
||||
libspice-server-dev \
|
||||
ninja-build \
|
||||
qemu-utils \
|
||||
rsync \
|
||||
sudo \
|
||||
texinfo \
|
||||
tzdata \
|
||||
unzip \
|
||||
&& rm -rf /var/lib/apt/lists/ \
|
||||
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 900 --slave /usr/bin/g++ g++ /usr/bin/g++-12
|
||||
@@ -1,308 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Date: Mon, 27 Mar 2023 19:24:04 +1100
|
||||
Subject: [PATCH] Add support for SerenityOS
|
||||
|
||||
Teaches the assembler, BFD, and the linker about the SerenityOS target
|
||||
triple.
|
||||
|
||||
We set '/' to not start a comment in GAS, as the QEMU port uses it for
|
||||
division in constant expressions in assembly files (cf. as --divide).
|
||||
|
||||
`/usr/lib/Loader.so` is set as the default ELF interpreter.
|
||||
|
||||
On AArch64, we set `COMMONPAGESIZE` to enable RELRO support.
|
||||
---
|
||||
bfd/config.bfd | 10 ++++++++++
|
||||
gas/config/tc-i386.c | 3 ++-
|
||||
gas/config/te-serenity.h | 3 +++
|
||||
gas/configure.tgt | 3 +++
|
||||
ld/Makefile.am | 6 ++++++
|
||||
ld/Makefile.in | 9 +++++++++
|
||||
ld/configure.tgt | 9 +++++++++
|
||||
ld/emulparams/aarch64serenity.sh | 5 +++++
|
||||
ld/emulparams/elf64lriscvserenity.sh | 2 ++
|
||||
ld/emulparams/elf_serenity.sh | 1 +
|
||||
ld/emulparams/elf_x86_64_serenity.sh | 2 ++
|
||||
11 files changed, 52 insertions(+), 1 deletion(-)
|
||||
create mode 100644 gas/config/te-serenity.h
|
||||
create mode 100644 ld/emulparams/aarch64serenity.sh
|
||||
create mode 100644 ld/emulparams/elf64lriscvserenity.sh
|
||||
create mode 100644 ld/emulparams/elf_serenity.sh
|
||||
create mode 100644 ld/emulparams/elf_x86_64_serenity.sh
|
||||
|
||||
diff --git a/bfd/config.bfd b/bfd/config.bfd
|
||||
index bdee53957c0ca034161715f86e84fcc950d7b625..dc97a5e4a57709736c62f4f4555dd92c0cabd507 100644
|
||||
--- a/bfd/config.bfd
|
||||
+++ b/bfd/config.bfd
|
||||
@@ -283,6 +283,11 @@ case "${targ}" in
|
||||
targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec"
|
||||
want64=true
|
||||
;;
|
||||
+ aarch64-*-serenity*)
|
||||
+ targ_defvec=aarch64_elf64_le_vec
|
||||
+ targ_selvecs=
|
||||
+ want64=true
|
||||
+ ;;
|
||||
aarch64-*-linux* | aarch64-*-netbsd* | aarch64-*-nto*)
|
||||
targ_defvec=aarch64_elf64_le_vec
|
||||
targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec aarch64_pei_le_vec aarch64_pe_le_vec"
|
||||
@@ -734,6 +739,11 @@ case "${targ}" in
|
||||
targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec"
|
||||
want64=true
|
||||
;;
|
||||
+ x86_64-*-serenity*)
|
||||
+ targ_defvec=x86_64_elf64_vec
|
||||
+ targ_selvecs=i386_elf32_vec
|
||||
+ want64=true
|
||||
+ ;;
|
||||
#endif
|
||||
i[3-7]86-*-lynxos*)
|
||||
targ_defvec=i386_elf32_vec
|
||||
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
|
||||
index de35ee2a2c6952e596e2f5092a22dee5cc54d92c..7f9c91019432a86d4eb1e94bfe7b9ffd6976057a 100644
|
||||
--- a/gas/config/tc-i386.c
|
||||
+++ b/gas/config/tc-i386.c
|
||||
@@ -501,7 +501,8 @@ const char extra_symbol_chars[] = "*%-([{}"
|
||||
&& !defined (TE_Haiku) \
|
||||
&& !defined (TE_FreeBSD) \
|
||||
&& !defined (TE_DragonFly) \
|
||||
- && !defined (TE_NetBSD))
|
||||
+ && !defined (TE_NetBSD) \
|
||||
+ && !defined (TE_SerenityOS))
|
||||
/* This array holds the chars that always start a comment. If the
|
||||
pre-processor is disabled, these aren't very useful. The option
|
||||
--divide will remove '/' from this list. */
|
||||
diff --git a/gas/config/te-serenity.h b/gas/config/te-serenity.h
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f38faf598cba7f561ed9528ee37328228ee55bdc
|
||||
--- /dev/null
|
||||
+++ b/gas/config/te-serenity.h
|
||||
@@ -0,0 +1,3 @@
|
||||
+#include "te-generic.h"
|
||||
+
|
||||
+#define TE_SerenityOS 1
|
||||
diff --git a/gas/configure.tgt b/gas/configure.tgt
|
||||
index 3429f850d05a23783d6736d875c649f5acf48afa..cc83c4d94da21fa278f7f2bdd32b436bd4b540a3 100644
|
||||
--- a/gas/configure.tgt
|
||||
+++ b/gas/configure.tgt
|
||||
@@ -137,6 +137,7 @@ case ${generic_target} in
|
||||
aarch64*-*-nto*) fmt=elf;;
|
||||
aarch64*-*-openbsd*) fmt=elf;;
|
||||
aarch64*-*-pe* | aarch64*-*-mingw*) fmt=coff em=pepaarch64 ;;
|
||||
+ aarch64*-*-serenity*) fmt=elf em=serenity ;;
|
||||
alpha-*-*vms*) fmt=evax ;;
|
||||
alpha-*-osf*) fmt=ecoff ;;
|
||||
alpha-*-linux*ecoff*) fmt=ecoff ;;
|
||||
@@ -265,6 +266,7 @@ case ${generic_target} in
|
||||
i386-*-*nt*) fmt=coff em=pe ;;
|
||||
i386-*-rdos*) fmt=elf ;;
|
||||
i386-*-darwin*) fmt=macho ;;
|
||||
+ i386-*-serenity) fmt=elf em=serenity ;;
|
||||
|
||||
ia16-*-elf*) fmt=elf ;;
|
||||
|
||||
@@ -370,6 +372,7 @@ case ${generic_target} in
|
||||
|
||||
pru-*-*) fmt=elf ;;
|
||||
|
||||
+ riscv64-*-serenity*) fmt=elf endian=little em=serenity ;;
|
||||
riscv*-*-haiku*) fmt=elf endian=little em=haiku ;;
|
||||
riscv*-*-*) fmt=elf ;;
|
||||
|
||||
diff --git a/ld/Makefile.am b/ld/Makefile.am
|
||||
index c3adbb0ccadacb5060988fe0aa24700b7cb489b4..5bbb3a61738a4cce09ba9b8b58d329c3bd5a36ec 100644
|
||||
--- a/ld/Makefile.am
|
||||
+++ b/ld/Makefile.am
|
||||
@@ -390,6 +390,7 @@ ALL_64_EMULATION_SOURCES = \
|
||||
eaarch64linuxb.c \
|
||||
eaarch64nto.c \
|
||||
eaarch64pe.c \
|
||||
+ eaarch64serenity.c \
|
||||
earm64pe.c \
|
||||
eelf32_x86_64.c \
|
||||
eelf32b4300.c \
|
||||
@@ -444,6 +445,7 @@ ALL_64_EMULATION_SOURCES = \
|
||||
eelf64lppc.c \
|
||||
eelf64lppc_fbsd.c \
|
||||
eelf64lriscv.c \
|
||||
+ eelf64lriscvserenity.c \
|
||||
eelf64lriscv_lp64.c \
|
||||
eelf64lriscv_lp64f.c \
|
||||
eelf64ltsmip.c \
|
||||
@@ -459,6 +461,7 @@ ALL_64_EMULATION_SOURCES = \
|
||||
eelf_x86_64_cloudabi.c \
|
||||
eelf_x86_64_fbsd.c \
|
||||
eelf_x86_64_haiku.c \
|
||||
+ eelf_x86_64_serenity.c \
|
||||
eelf_x86_64_sol2.c \
|
||||
ehppa64linux.c \
|
||||
ei386pep.c \
|
||||
@@ -885,6 +888,7 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64linuxb.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64nto.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64pe.Pc@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64serenity.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earm64pe.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32_x86_64.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32b4300.Pc@am__quote@
|
||||
@@ -939,6 +943,7 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc_fbsd.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64loongarch.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv.Pc@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscvserenity.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv_lp64.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv_lp64f.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64ltsmip.Pc@am__quote@
|
||||
@@ -954,6 +959,7 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_cloudabi.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_fbsd.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_haiku.Pc@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_serenity.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_sol2.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ehppa64linux.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ei386pep.Pc@am__quote@
|
||||
diff --git a/ld/Makefile.in b/ld/Makefile.in
|
||||
index d1a5602643787c240b5323c6c09b9d2bbc813e79..b18a0ed9cede77b1665bb0716176091ac02f5fe9 100644
|
||||
--- a/ld/Makefile.in
|
||||
+++ b/ld/Makefile.in
|
||||
@@ -890,6 +890,7 @@ ALL_64_EMULATION_SOURCES = \
|
||||
eaarch64linuxb.c \
|
||||
eaarch64nto.c \
|
||||
eaarch64pe.c \
|
||||
+ eaarch64serenity.c \
|
||||
earm64pe.c \
|
||||
eelf32_x86_64.c \
|
||||
eelf32b4300.c \
|
||||
@@ -944,6 +945,7 @@ ALL_64_EMULATION_SOURCES = \
|
||||
eelf64lppc.c \
|
||||
eelf64lppc_fbsd.c \
|
||||
eelf64lriscv.c \
|
||||
+ eelf64lriscvserenity.c \
|
||||
eelf64lriscv_lp64.c \
|
||||
eelf64lriscv_lp64f.c \
|
||||
eelf64ltsmip.c \
|
||||
@@ -959,6 +961,7 @@ ALL_64_EMULATION_SOURCES = \
|
||||
eelf_x86_64_cloudabi.c \
|
||||
eelf_x86_64_fbsd.c \
|
||||
eelf_x86_64_haiku.c \
|
||||
+ eelf_x86_64_serenity.c \
|
||||
eelf_x86_64_sol2.c \
|
||||
ehppa64linux.c \
|
||||
ei386pep.c \
|
||||
@@ -1271,6 +1274,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64linuxb.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64nto.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64pe.Po@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64serenity.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaix5ppc.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaix5rs6.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaixppc.Po@am__quote@
|
||||
@@ -1447,6 +1451,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc_fbsd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv.Po@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscvserenity.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv_lp64.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv_lp64f.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64ltsmip.Po@am__quote@
|
||||
@@ -1471,6 +1476,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_cloudabi.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_fbsd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_haiku.Po@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_serenity.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_sol2.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eh8300elf.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eh8300elf_linux.Po@am__quote@
|
||||
@@ -2602,6 +2608,7 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64linuxb.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64nto.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64pe.Pc@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64serenity.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earm64pe.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32_x86_64.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32b4300.Pc@am__quote@
|
||||
@@ -2656,6 +2663,7 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc_fbsd.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64loongarch.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv.Pc@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscvserenity.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv_lp64.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv_lp64f.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64ltsmip.Pc@am__quote@
|
||||
@@ -2671,6 +2679,7 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_cloudabi.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_fbsd.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_haiku.Pc@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_serenity.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_sol2.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ehppa64linux.Pc@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ei386pep.Pc@am__quote@
|
||||
diff --git a/ld/configure.tgt b/ld/configure.tgt
|
||||
index c62b9581d9b8bb0bb000ff83247baa6144b9921b..6d0d7b2e0dee06be5c808aa933643e4c9eff0a7a 100644
|
||||
--- a/ld/configure.tgt
|
||||
+++ b/ld/configure.tgt
|
||||
@@ -97,6 +97,9 @@ aarch64-*-freebsd*) targ_emul=aarch64fbsd
|
||||
aarch64-*-fuchsia*) targ_emul=aarch64elf
|
||||
targ_extra_emuls="aarch64elfb armelf armelfb"
|
||||
;;
|
||||
+aarch64-*-serenity*) targ_emul=aarch64serenity
|
||||
+ targ_extra_emuls=aarch64elf
|
||||
+ ;;
|
||||
aarch64_be-*-linux-gnu_ilp32)
|
||||
targ_emul=aarch64linux32b
|
||||
targ_extra_libpath="aarch64linuxb aarch64linux aarch64linux32 armelfb_linux_eabi armelf_linux_eabi"
|
||||
@@ -825,6 +828,9 @@ riscv64*-*-linux*) targ_emul=elf64lriscv
|
||||
targ_extra_emuls="elf64lriscv_lp64f elf64lriscv_lp64 elf32lriscv elf32lriscv_ilp32f elf32lriscv_ilp32 elf64briscv elf64briscv_lp64f elf64briscv_lp64 elf32briscv elf32briscv_ilp32f elf32briscv_ilp32"
|
||||
targ_extra_libpath=$targ_extra_emuls
|
||||
;;
|
||||
+riscv64-*-serenity*) targ_emul=elf64lriscvserenity
|
||||
+ targ_extra_emuls=elf64lriscv
|
||||
+ ;;
|
||||
riscv64be*-*-*) targ_emul=elf64briscv
|
||||
targ_extra_emuls="elf32briscv elf64lriscv elf32lriscv"
|
||||
targ_extra_libpath=$targ_extra_emuls
|
||||
@@ -1011,6 +1017,9 @@ x86_64-*-linux-*) targ_emul=elf_x86_64
|
||||
x86_64-*-redox*) targ_emul=elf_x86_64
|
||||
targ_extra_emuls=elf_i386
|
||||
;;
|
||||
+x86_64-*-serenity*) targ_emul=elf_x86_64_serenity
|
||||
+ targ_extra_emuls="elf_x86_64 elf_i386"
|
||||
+ ;;
|
||||
x86_64-*-solaris2*) targ_emul=elf_x86_64_sol2
|
||||
targ_extra_emuls="elf_x86_64 elf_i386_sol2 elf_i386_ldso elf_i386 elf_iamcu"
|
||||
targ_extra_libpath=$targ_extra_emuls
|
||||
diff --git a/ld/emulparams/aarch64serenity.sh b/ld/emulparams/aarch64serenity.sh
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..23aed1440a033e2ac06536f43c1bacaf98832b92
|
||||
--- /dev/null
|
||||
+++ b/ld/emulparams/aarch64serenity.sh
|
||||
@@ -0,0 +1,5 @@
|
||||
+source_sh ${srcdir}/emulparams/aarch64elf.sh
|
||||
+source_sh ${srcdir}/emulparams/elf_serenity.sh
|
||||
+
|
||||
+COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
|
||||
+unset EMBEDDED
|
||||
diff --git a/ld/emulparams/elf64lriscvserenity.sh b/ld/emulparams/elf64lriscvserenity.sh
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8bcbea812b49363cf4e2e94e1554998277b21cb1
|
||||
--- /dev/null
|
||||
+++ b/ld/emulparams/elf64lriscvserenity.sh
|
||||
@@ -0,0 +1,2 @@
|
||||
+source_sh ${srcdir}/emulparams/elf64lriscv.sh
|
||||
+source_sh ${srcdir}/emulparams/elf_serenity.sh
|
||||
diff --git a/ld/emulparams/elf_serenity.sh b/ld/emulparams/elf_serenity.sh
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c434bacaa7fa16a9bb1c4934ad061230fbf56825
|
||||
--- /dev/null
|
||||
+++ b/ld/emulparams/elf_serenity.sh
|
||||
@@ -0,0 +1 @@
|
||||
+ELF_INTERPRETER_NAME=\"/usr/lib/Loader.so\"
|
||||
diff --git a/ld/emulparams/elf_x86_64_serenity.sh b/ld/emulparams/elf_x86_64_serenity.sh
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..536af1e31d761b22e3e40cafd339d5bf7a285756
|
||||
--- /dev/null
|
||||
+++ b/ld/emulparams/elf_x86_64_serenity.sh
|
||||
@@ -0,0 +1,2 @@
|
||||
+source_sh ${srcdir}/emulparams/elf_x86_64.sh
|
||||
+source_sh ${srcdir}/emulparams/elf_serenity.sh
|
||||
@@ -1,270 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fangrui Song <maskray@google.com>
|
||||
Date: Sat, 22 May 2021 23:10:21 -0700
|
||||
Subject: [PATCH] ld: Add -Bsymbolic-non-weak-functions
|
||||
|
||||
This option is a subset of -Bsymbolic-functions: only STB_GLOBAL are
|
||||
considered. Vague linkage functions are STB_WEAK. A vague linkage
|
||||
function may have different addresses in a -Bsymbolic-functions linked
|
||||
shared object and outside the shared object.
|
||||
-Bsymbolic-non-weak-functions can keep pointer equality while providing
|
||||
most benefits: (a) fewer JUMP_SLOT (symbol lookups) (b) avoid PLT
|
||||
entries for default visibility defined functions.
|
||||
|
||||
PR 27871
|
||||
include/
|
||||
* bfdlink.h (struct bfd_link_info): Add dynamic_weak_functions.
|
||||
ld/
|
||||
* ldlex.h (enum option_values): Add OPTION_SYMBOLIC_NON_WEAK_FUNCTIONS.
|
||||
* lexsup.c (struct ld_options): Add -Bsymbolic-non-weak-functions.
|
||||
(enum symbolic_enum): Add symbolic_non_weak_functions.
|
||||
(parse_args): Handle -Bsymbolic-non-weak-functions.
|
||||
* ld.texi: Document -Bsymbolic-non-weak-functions.
|
||||
* NEWS: Mention -Bsymbolic-non-weak-functions.
|
||||
* testsuite/ld-elf/shared.exp: Add tests.
|
||||
* testsuite/ld-elf/symbolic-non-weak-func.s: New file.
|
||||
* testsuite/ld-elf/symbolic-non-weak-func-a.rd: Likewise.
|
||||
* testsuite/ld-elf/symbolic-non-weak-func-b.rd: Likewise.
|
||||
---
|
||||
bfd/elflink.c | 12 +++++-----
|
||||
include/bfdlink.h | 3 +++
|
||||
ld/NEWS | 2 ++
|
||||
ld/ld.texi | 15 ++++++++++---
|
||||
ld/ldlex.h | 1 +
|
||||
ld/lexsup.c | 17 +++++++++++---
|
||||
ld/testsuite/ld-elf/shared.exp | 22 +++++++++++++++++++
|
||||
.../ld-elf/symbolic-non-weak-func-a.rd | 4 ++++
|
||||
.../ld-elf/symbolic-non-weak-func-b.rd | 4 ++++
|
||||
ld/testsuite/ld-elf/symbolic-non-weak-func.s | 18 +++++++++++++++
|
||||
10 files changed, 85 insertions(+), 13 deletions(-)
|
||||
create mode 100644 ld/testsuite/ld-elf/symbolic-non-weak-func-a.rd
|
||||
create mode 100644 ld/testsuite/ld-elf/symbolic-non-weak-func-b.rd
|
||||
create mode 100644 ld/testsuite/ld-elf/symbolic-non-weak-func.s
|
||||
|
||||
diff --git a/bfd/elflink.c b/bfd/elflink.c
|
||||
index 7217c2f038baf9cf1df122cc5bb82ac99c00a51e..b7f14694f277f91e6a58491548fae52382683ca6 100644
|
||||
--- a/bfd/elflink.c
|
||||
+++ b/bfd/elflink.c
|
||||
@@ -608,14 +608,12 @@ bfd_elf_link_mark_dynamic_symbol (struct bfd_link_info *info,
|
||||
if(h->dynamic || bfd_link_relocatable (info))
|
||||
return;
|
||||
|
||||
+ int type = sym != NULL ? ELF_ST_TYPE (sym->st_info) : STT_NOTYPE;
|
||||
if ((info->dynamic_data
|
||||
- && (h->type == STT_OBJECT
|
||||
- || h->type == STT_COMMON
|
||||
- || (sym != NULL
|
||||
- && (ELF_ST_TYPE (sym->st_info) == STT_OBJECT
|
||||
- || ELF_ST_TYPE (sym->st_info) == STT_COMMON))))
|
||||
- || (d != NULL
|
||||
- && h->non_elf
|
||||
+ && (type == STT_OBJECT || type == STT_COMMON))
|
||||
+ || (info->dynamic_weak_functions && type == STT_FUNC
|
||||
+ && ELF_ST_BIND (sym->st_info) == STB_WEAK)
|
||||
+ || (d != NULL && h->non_elf
|
||||
&& (*d->match) (&d->head, NULL, h->root.root.string)))
|
||||
{
|
||||
h->dynamic = 1;
|
||||
diff --git a/include/bfdlink.h b/include/bfdlink.h
|
||||
index 840790a298c3f8894494c5266b2de0560ceecfd2..632bf8fdd2ec2c4bf1ee8573884c18b3a2c1bb3f 100644
|
||||
--- a/include/bfdlink.h
|
||||
+++ b/include/bfdlink.h
|
||||
@@ -368,6 +368,9 @@ struct bfd_link_info
|
||||
/* TRUE if all data symbols should be dynamic. */
|
||||
unsigned int dynamic_data: 1;
|
||||
|
||||
+ /* TRUE if all weak function symbols should be dynamic. */
|
||||
+ unsigned int dynamic_weak_functions: 1;
|
||||
+
|
||||
/* TRUE if section groups should be resolved. */
|
||||
unsigned int resolve_section_groups: 1;
|
||||
|
||||
diff --git a/ld/NEWS b/ld/NEWS
|
||||
index e1ac20b8a97399136cc04b21e677292dd3bf8c66..5e37f9d0c11f8ef8a4900a9d11ba1df50e26c3d6 100644
|
||||
--- a/ld/NEWS
|
||||
+++ b/ld/NEWS
|
||||
@@ -104,6 +104,8 @@ Changes in 2.37:
|
||||
|
||||
* Add -Bno-symbolic to cancel -Bsymbolic and -Bsymbolic-functions.
|
||||
|
||||
+* Add -Bsymbolic-non-weak-functions as a safe subset of -Bsymbolic-functions.
|
||||
+
|
||||
Changes in 2.36:
|
||||
|
||||
* Add libdep plugin, for linking dependencies of static libraries that
|
||||
diff --git a/ld/ld.texi b/ld/ld.texi
|
||||
index aa8b1aa86eb386358bc18662f1f0b2fce4996763..49b7dfe80d81ba59e7bd86dbae8c4dadc25b9c77 100644
|
||||
--- a/ld/ld.texi
|
||||
+++ b/ld/ld.texi
|
||||
@@ -1739,7 +1739,7 @@ libraries.
|
||||
|
||||
@kindex -Bsymbolic
|
||||
@item -Bsymbolic
|
||||
-When creating a shared library, bind references to global symbols to the
|
||||
+When creating a shared library, bind references to non-local symbols to the
|
||||
definition within the shared library, if any. Normally, it is possible
|
||||
for a program linked against a shared library to override the definition
|
||||
within the shared library. This option is only meaningful on ELF
|
||||
@@ -1747,11 +1747,20 @@ platforms which support shared libraries.
|
||||
|
||||
@kindex -Bsymbolic-functions
|
||||
@item -Bsymbolic-functions
|
||||
-When creating a shared library, bind references to global function
|
||||
-symbols to the definition within the shared library, if any.
|
||||
+When creating a shared library, bind references to non-local function
|
||||
+symbols to the definition within the shared library, if any. A vague linkage
|
||||
+function definition is weak. It may have different addresses in the linked
|
||||
+shared library and outside the shared library.
|
||||
This option is only meaningful on ELF platforms which support shared
|
||||
libraries.
|
||||
|
||||
+@kindex -Bsymbolic-non-weak-functions
|
||||
+@item -Bsymbolic-non-weak-functions
|
||||
+When creating a shared library, bind references to @code{STB_GLOBAL} function
|
||||
+symbols to the definition within the shared library, if any. Noticeably this
|
||||
+option skips C++ vague linkage functions and is thus safe.
|
||||
+This option is only meaningful on ELF platforms which support shared libraries.
|
||||
+
|
||||
@kindex -Bno-symbolic
|
||||
@item -Bno-symbolic
|
||||
This option can cancel previously specified @samp{-Bsymbolic} and
|
||||
diff --git a/ld/ldlex.h b/ld/ldlex.h
|
||||
index 87cac02141d8c8cf090001ec877dd4e458d19c1b..1a571a7ce331487b2d809bbbd562a5ce32d4e6d7 100644
|
||||
--- a/ld/ldlex.h
|
||||
+++ b/ld/ldlex.h
|
||||
@@ -64,6 +64,7 @@ enum option_values
|
||||
OPTION_SORT_SECTION,
|
||||
OPTION_STATS,
|
||||
OPTION_SYMBOLIC,
|
||||
+ OPTION_SYMBOLIC_NON_WEAK_FUNCTIONS,
|
||||
OPTION_SYMBOLIC_FUNCTIONS,
|
||||
OPTION_TASK_LINK,
|
||||
OPTION_TBSS,
|
||||
diff --git a/ld/lexsup.c b/ld/lexsup.c
|
||||
index fe8722313fedf6d72846fc45418831e5c77efab6..128ffadea5e9a8751336bcc86e3243f66a4e7411 100644
|
||||
--- a/ld/lexsup.c
|
||||
+++ b/ld/lexsup.c
|
||||
@@ -315,9 +315,11 @@ static const struct ld_option ld_options[] =
|
||||
{ {"Bno-symbolic", no_argument, NULL, OPTION_NO_SYMBOLIC},
|
||||
'\0', NULL, N_("Don't bind global references locally"), ONE_DASH },
|
||||
{ {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
|
||||
- '\0', NULL, N_("Bind global references locally"), ONE_DASH },
|
||||
+ '\0', NULL, N_("Bind default visibility defined symbols locally for -shared"), ONE_DASH },
|
||||
+ { {"Bsymbolic-non-weak-functions", no_argument, NULL, OPTION_SYMBOLIC_NON_WEAK_FUNCTIONS},
|
||||
+ '\0', NULL, N_("Bind default visibility defined STB_GLOBAL function symbols locally for -shared"), ONE_DASH },
|
||||
{ {"Bsymbolic-functions", no_argument, NULL, OPTION_SYMBOLIC_FUNCTIONS},
|
||||
- '\0', NULL, N_("Bind global function references locally"), ONE_DASH },
|
||||
+ '\0', NULL, N_("Bind default visibility defined function symbols locally for -shared"), ONE_DASH },
|
||||
{ {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS},
|
||||
'\0', NULL, N_("Check section addresses for overlaps (default)"),
|
||||
TWO_DASHES },
|
||||
@@ -647,8 +649,9 @@ parse_args (unsigned argc, char **argv)
|
||||
enum symbolic_enum
|
||||
{
|
||||
symbolic_unset = 0,
|
||||
- symbolic,
|
||||
+ symbolic_non_weak_functions,
|
||||
symbolic_functions,
|
||||
+ symbolic,
|
||||
} opt_symbolic = symbolic_unset;
|
||||
enum dynamic_list_enum
|
||||
{
|
||||
@@ -1372,6 +1375,9 @@ parse_args (unsigned argc, char **argv)
|
||||
case OPTION_SYMBOLIC:
|
||||
opt_symbolic = symbolic;
|
||||
break;
|
||||
+ case OPTION_SYMBOLIC_NON_WEAK_FUNCTIONS:
|
||||
+ opt_symbolic = symbolic_non_weak_functions;
|
||||
+ break;
|
||||
case OPTION_SYMBOLIC_FUNCTIONS:
|
||||
opt_symbolic = symbolic_functions;
|
||||
break;
|
||||
@@ -1996,6 +2002,11 @@ parse_args (unsigned argc, char **argv)
|
||||
link_info.dynamic = true;
|
||||
link_info.dynamic_data = true;
|
||||
break;
|
||||
+ case symbolic_non_weak_functions:
|
||||
+ link_info.dynamic = true;
|
||||
+ link_info.dynamic_data = true;
|
||||
+ link_info.dynamic_weak_functions = true;
|
||||
+ break;
|
||||
}
|
||||
|
||||
/* -z nosectionheader implies --strip-all. */
|
||||
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
|
||||
index cf010e5b0e59576a047476ecaa2d9a74c8cc7ed0..d5508912aa286e4a552b9b0270afa815a7d8a960 100644
|
||||
--- a/ld/testsuite/ld-elf/shared.exp
|
||||
+++ b/ld/testsuite/ld-elf/shared.exp
|
||||
@@ -459,6 +459,28 @@ run_ld_link_tests [list \
|
||||
"symbolic-func.so"] \
|
||||
]
|
||||
|
||||
+if {[istarget "aarch64*-*-*"] || [istarget "powerpc*-*-*"] ||
|
||||
+ [istarget "i?86-*-*"] || [istarget "x86_64-*-*"]} {
|
||||
+ run_ld_link_tests [list \
|
||||
+ [list "-Bsymbolic-non-weak-functions -Bsymbolic" \
|
||||
+ "-shared -Bsymbolic-non-weak-functions -Bsymbolic" "" "$AFLAGS_PIC" \
|
||||
+ {symbolic-non-weak-func.s} {{readelf {-r --wide} symbolic-non-weak-func-a.rd}} \
|
||||
+ "symbolic-non-weak-func-a.so"] \
|
||||
+ ]
|
||||
+ run_ld_link_tests [list \
|
||||
+ [list "-Bsymbolic-non-weak-functions" \
|
||||
+ "-shared -Bsymbolic-non-weak-functions" "" "$AFLAGS_PIC" \
|
||||
+ {symbolic-non-weak-func.s} {{readelf {-r --wide} symbolic-non-weak-func-b.rd}} \
|
||||
+ "symbolic-non-weak-func-b.so"] \
|
||||
+ ]
|
||||
+ run_ld_link_tests [list \
|
||||
+ [list "-Bsymbolic-functions -Bsymbolic-non-weak-functions" \
|
||||
+ "-shared -Bsymbolic-functions -Bsymbolic-non-weak-functions" "" "$AFLAGS_PIC" \
|
||||
+ {symbolic-non-weak-func.s} {{readelf {-r --wide} symbolic-non-weak-func-b.rd}} \
|
||||
+ "symbolic-non-weak-func-b.so"] \
|
||||
+ ]
|
||||
+}
|
||||
+
|
||||
run_ld_link_tests [list \
|
||||
[list "Build pr20995.so" \
|
||||
"-shared" "" "$AFLAGS_PIC" \
|
||||
diff --git a/ld/testsuite/ld-elf/symbolic-non-weak-func-a.rd b/ld/testsuite/ld-elf/symbolic-non-weak-func-a.rd
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ef591840f5c338a55f6d44fc372568569011c430
|
||||
--- /dev/null
|
||||
+++ b/ld/testsuite/ld-elf/symbolic-non-weak-func-a.rd
|
||||
@@ -0,0 +1,4 @@
|
||||
+#...
|
||||
+[0-9a-f]+ +[0-9a-f]+ +R_.*_RELATIVE .*
|
||||
+[0-9a-f]+ +[0-9a-f]+ +R_.*_RELATIVE .*
|
||||
+[0-9a-f]+ +[0-9a-f]+ +R_.*_RELATIVE .*
|
||||
diff --git a/ld/testsuite/ld-elf/symbolic-non-weak-func-b.rd b/ld/testsuite/ld-elf/symbolic-non-weak-func-b.rd
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..34228b0627b226cfdc76e3cedff6f515b7c27872
|
||||
--- /dev/null
|
||||
+++ b/ld/testsuite/ld-elf/symbolic-non-weak-func-b.rd
|
||||
@@ -0,0 +1,4 @@
|
||||
+#...
|
||||
+[0-9a-f]+ +[0-9a-f]+ +R_.*_RELATIVE .*
|
||||
+[0-9a-f]+ +[0-9a-f]+ +R_.*_RELATIVE .*
|
||||
+[0-9a-f]+ +[0-9a-f]+ +R_.* weak_fun.*
|
||||
diff --git a/ld/testsuite/ld-elf/symbolic-non-weak-func.s b/ld/testsuite/ld-elf/symbolic-non-weak-func.s
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e259f12bfc126bf2ef9bf16aba64667ca4e2bfd5
|
||||
--- /dev/null
|
||||
+++ b/ld/testsuite/ld-elf/symbolic-non-weak-func.s
|
||||
@@ -0,0 +1,18 @@
|
||||
+ .text
|
||||
+ .global global_fun
|
||||
+ .type global_fun, %function
|
||||
+global_fun:
|
||||
+ .space 4
|
||||
+ .weak weak_fun
|
||||
+ .type weak_fun, %function
|
||||
+weak_fun:
|
||||
+ .space 4
|
||||
+
|
||||
+ .section .data,"aw",%progbits
|
||||
+ .p2align 3
|
||||
+ .dc.a global_data
|
||||
+ .dc.a global_fun
|
||||
+ .dc.a weak_fun
|
||||
+
|
||||
+ .global global_data
|
||||
+global_data:
|
||||
@@ -1,43 +0,0 @@
|
||||
# Patches for binutils on SerenityOS
|
||||
|
||||
## `0001-Add-support-for-SerenityOS.patch`
|
||||
|
||||
Add support for SerenityOS
|
||||
|
||||
Teaches the assembler, BFD, and the linker about the SerenityOS target
|
||||
triple.
|
||||
|
||||
We set '/' to not start a comment in GAS, as the QEMU port uses it for
|
||||
division in constant expressions in assembly files (cf. as --divide).
|
||||
|
||||
`/usr/lib/Loader.so` is set as the default ELF interpreter.
|
||||
|
||||
On AArch64, we set `COMMONPAGESIZE` to enable RELRO support.
|
||||
|
||||
## `0002-ld-Add-Bsymbolic-non-weak-functions.patch`
|
||||
|
||||
ld: Add -Bsymbolic-non-weak-functions
|
||||
|
||||
This option is a subset of -Bsymbolic-functions: only STB_GLOBAL are
|
||||
considered. Vague linkage functions are STB_WEAK. A vague linkage
|
||||
function may have different addresses in a -Bsymbolic-functions linked
|
||||
shared object and outside the shared object.
|
||||
-Bsymbolic-non-weak-functions can keep pointer equality while providing
|
||||
most benefits: (a) fewer JUMP_SLOT (symbol lookups) (b) avoid PLT
|
||||
entries for default visibility defined functions.
|
||||
|
||||
PR 27871
|
||||
include/
|
||||
* bfdlink.h (struct bfd_link_info): Add dynamic_weak_functions.
|
||||
ld/
|
||||
* ldlex.h (enum option_values): Add OPTION_SYMBOLIC_NON_WEAK_FUNCTIONS.
|
||||
* lexsup.c (struct ld_options): Add -Bsymbolic-non-weak-functions.
|
||||
(enum symbolic_enum): Add symbolic_non_weak_functions.
|
||||
(parse_args): Handle -Bsymbolic-non-weak-functions.
|
||||
* ld.texi: Document -Bsymbolic-non-weak-functions.
|
||||
* NEWS: Mention -Bsymbolic-non-weak-functions.
|
||||
* testsuite/ld-elf/shared.exp: Add tests.
|
||||
* testsuite/ld-elf/symbolic-non-weak-func.s: New file.
|
||||
* testsuite/ld-elf/symbolic-non-weak-func-a.rd: Likewise.
|
||||
* testsuite/ld-elf/symbolic-non-weak-func-b.rd: Likewise.
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Kling <awesomekling@gmail.com>
|
||||
Date: Fri, 5 Apr 2019 03:02:52 +0200
|
||||
Subject: [PATCH] Add a gcc driver for SerenityOS
|
||||
|
||||
This patch adds support for the `*-*-serenity` target to gcc.
|
||||
|
||||
It specifies which flags need to be passed to the linker, defines the
|
||||
__serenity__ macro, sets the correct underlying type of `size_t` and
|
||||
`ptrdiff_t`, and enables IFUNCs.
|
||||
|
||||
Co-Authored-By: Gunnar Beutner <gbeutner@serenityos.org>
|
||||
Co-Authored-By: Itamar <itamar8910@gmail.com>
|
||||
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Co-Authored-By: Nico Weber <thakis@chromium.org>
|
||||
Co-Authored-By: Tim Schumacher <timschumi@gmx.de>
|
||||
Co-Authored-By: Andrew Kaster <andrewdkaster@gmail.com>
|
||||
Co-Authored-By: Brian Gianforcaro <bgianf@serenityos.org>
|
||||
Co-Authored-By: Philip Herron <herron.philip@googlemail.com>
|
||||
Co-Authored-By: Shannon Booth <shannon@serenityos.org>
|
||||
---
|
||||
gcc/config.gcc | 23 ++++++++++++++++++
|
||||
gcc/config/i386/serenity.h | 7 ++++++
|
||||
gcc/config/serenity.h | 48 ++++++++++++++++++++++++++++++++++++++
|
||||
gcc/config/serenity.opt | 35 +++++++++++++++++++++++++++
|
||||
4 files changed, 113 insertions(+)
|
||||
create mode 100644 gcc/config/i386/serenity.h
|
||||
create mode 100644 gcc/config/serenity.h
|
||||
create mode 100644 gcc/config/serenity.opt
|
||||
|
||||
diff --git a/gcc/config.gcc b/gcc/config.gcc
|
||||
index 648b3dc21103e43a315b676c827ff9e6d2923e11..e8a7ea2f50bf908c30b14479bb695cd645261f9e 100644
|
||||
--- a/gcc/config.gcc
|
||||
+++ b/gcc/config.gcc
|
||||
@@ -690,6 +690,18 @@ x86_cpus="generic intel"
|
||||
|
||||
# Common parts for widely ported systems.
|
||||
case ${target} in
|
||||
+*-*-serenity*)
|
||||
+ gas=yes
|
||||
+ gnu_ld=yes
|
||||
+ default_use_cxa_atexit=yes
|
||||
+ extra_options="${extra_options} serenity.opt"
|
||||
+ tmake_file="t-slibgcc"
|
||||
+ case ${target} in
|
||||
+ aarch64*-* | riscv64-* | x86_64-*)
|
||||
+ default_gnu_indirect_function=yes
|
||||
+ ;;
|
||||
+ esac
|
||||
+ ;;
|
||||
*-*-darwin*)
|
||||
tmake_file="t-darwin "
|
||||
tm_file="${tm_file} darwin.h"
|
||||
@@ -1126,6 +1138,17 @@ case ${target} in
|
||||
esac
|
||||
|
||||
case ${target} in
|
||||
+x86_64-*-serenity*)
|
||||
+ tm_file="${tm_file} i386/unix.h i386/att.h elfos.h glibc-stdint.h i386/i386elf.h i386/x86-64.h serenity.h i386/serenity.h"
|
||||
+ ;;
|
||||
+aarch64*-*-serenity*)
|
||||
+ tm_file="${tm_file} elfos.h glibc-stdint.h aarch64/aarch64-elf.h serenity.h"
|
||||
+ tmake_file="${tmake_file} aarch64/t-aarch64"
|
||||
+ ;;
|
||||
+riscv64-*-serenity*)
|
||||
+ tm_file="${tm_file} elfos.h glibc-stdint.h riscv/elf.h serenity.h"
|
||||
+ tmake_file="${tmake_file} riscv/t-riscv"
|
||||
+ ;;
|
||||
aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
|
||||
tm_file="${tm_file} elfos.h newlib-stdint.h"
|
||||
tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-elf-raw.h"
|
||||
diff --git a/gcc/config/i386/serenity.h b/gcc/config/i386/serenity.h
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..53a4b8e93b74b4808a4bfed91c4d5558217c584a
|
||||
--- /dev/null
|
||||
+++ b/gcc/config/i386/serenity.h
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* Ensure that we are using the SIZE_TYPE indicated by SysV */
|
||||
+#undef SIZE_TYPE
|
||||
+#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
|
||||
+
|
||||
+/* Ensure that ptrdiff_t matches the actual pointer size */
|
||||
+#undef PTRDIFF_TYPE
|
||||
+#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
|
||||
diff --git a/gcc/config/serenity.h b/gcc/config/serenity.h
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..10c6f16fbe13eab36bab8f6896f8e2a6ae48df02
|
||||
--- /dev/null
|
||||
+++ b/gcc/config/serenity.h
|
||||
@@ -0,0 +1,50 @@
|
||||
+/* Useful if you wish to make target-specific GCC changes. */
|
||||
+#undef TARGET_SERENITY
|
||||
+#define TARGET_SERENITY 1
|
||||
+
|
||||
+#if defined(HAVE_LD_EH_FRAME_HDR)
|
||||
+#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
|
||||
+#endif
|
||||
+
|
||||
+/* Default arguments you want when running your
|
||||
+ x86_64-serenity-gcc toolchain */
|
||||
+#undef LIB_SPEC
|
||||
+#define LIB_SPEC "-lc" /* link against C standard library */
|
||||
+
|
||||
+/* Files that are linked before user code.
|
||||
+ The %s tells GCC to look for these files in the library directory. */
|
||||
+#undef STARTFILE_SPEC
|
||||
+#define STARTFILE_SPEC "%{!shared:crt0.o%s} crti.o%s %{shared: %{!fbuilding-libgcc:crt0_shared.o%s}} %{shared|static-pie|!no-pie:crtbeginS.o%s; :crtbegin.o%s}"
|
||||
+
|
||||
+/* Files that are linked after user code. */
|
||||
+#undef ENDFILE_SPEC
|
||||
+#define ENDFILE_SPEC "%{shared|static-pie|!no-pie:crtendS.o%s; :crtend.o%s} crtn.o%s"
|
||||
+
|
||||
+#define TARGET_LIBC_PROVIDES_SSP
|
||||
+
|
||||
+#undef LINK_SPEC
|
||||
+#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!static: %{rdynamic:-export-dynamic} -dynamic-linker /usr/lib/Loader.so}"
|
||||
+
|
||||
+#undef CC1_SPEC
|
||||
+#define CC1_SPEC "-fno-semantic-interposition"
|
||||
+
|
||||
+#undef CPP_SPEC
|
||||
+#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
|
||||
+
|
||||
+/* Use --as-needed -lgcc_s for eh support. */
|
||||
+#define USE_LD_AS_NEEDED 1
|
||||
+
|
||||
+/* We don't have a separate math library, it's included within libc. While we do have compatibility
|
||||
+ linker scripts in place, just don't add it to the linker invocation to begin with. */
|
||||
+#define MATH_LIBRARY ""
|
||||
+
|
||||
+/* Additional predefined macros. */
|
||||
+#undef TARGET_OS_CPP_BUILTINS
|
||||
+#define TARGET_OS_CPP_BUILTINS() \
|
||||
+ do { \
|
||||
+ builtin_define ("__serenity__"); \
|
||||
+ builtin_define ("__unix__"); \
|
||||
+ builtin_assert ("system=serenity"); \
|
||||
+ builtin_assert ("system=unix"); \
|
||||
+ builtin_assert ("system=posix"); \
|
||||
+ } while(0);
|
||||
diff --git a/gcc/config/serenity.opt b/gcc/config/serenity.opt
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..2756a5575480449a2c46b9fdfde541ba2787a263
|
||||
--- /dev/null
|
||||
+++ b/gcc/config/serenity.opt
|
||||
@@ -0,0 +1,35 @@
|
||||
+; SerenityOS options.
|
||||
+
|
||||
+; Copyright (C) 2021 Gunnar Beutner <gunnar@beutner.name>
|
||||
+;
|
||||
+; This file is part of GCC.
|
||||
+;
|
||||
+; GCC is free software; you can redistribute it and/or modify it under
|
||||
+; the terms of the GNU General Public License as published by the Free
|
||||
+; Software Foundation; either version 3, or (at your option) any later
|
||||
+; version.
|
||||
+;
|
||||
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
+; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
+; for more details.
|
||||
+;
|
||||
+; You should have received a copy of the GNU General Public License
|
||||
+; along with GCC; see the file COPYING3. If not see
|
||||
+; <http://www.gnu.org/licenses/>.
|
||||
+
|
||||
+; See the GCC internals manual (options.texi) for a description of
|
||||
+; this file's format.
|
||||
+
|
||||
+; Please try to keep this file in ASCII collating order.
|
||||
+
|
||||
+posix
|
||||
+Driver
|
||||
+
|
||||
+pthread
|
||||
+Driver
|
||||
+
|
||||
+rdynamic
|
||||
+Driver
|
||||
+
|
||||
+; This comment is to ensure we retain the blank line above.
|
||||
@@ -1,26 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Kling <awesomekling@gmail.com>
|
||||
Date: Fri, 5 Apr 2019 03:02:52 +0200
|
||||
Subject: [PATCH] fixincludes: Skip for SerenityOS targets
|
||||
|
||||
`fixincludes` is responsible for fixing mistakes in system headers that
|
||||
rely in compiler extensions that GCC doesn't support or cause errors in
|
||||
C++ mode.
|
||||
|
||||
Our headers don't have such problems, so this hack is of no use for us.
|
||||
---
|
||||
fixincludes/mkfixinc.sh | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/fixincludes/mkfixinc.sh b/fixincludes/mkfixinc.sh
|
||||
index df90720b716f2386f343f5ba46a2d8d706188dd5..a45cdd0de6833a1e632292722387be453a079053 100755
|
||||
--- a/fixincludes/mkfixinc.sh
|
||||
+++ b/fixincludes/mkfixinc.sh
|
||||
@@ -11,6 +11,7 @@ target=fixinc.sh
|
||||
|
||||
# Check for special fix rules for particular targets
|
||||
case $machine in
|
||||
+ *-serenity* | \
|
||||
i?86-*-cygwin* | \
|
||||
i?86-*-mingw32* | \
|
||||
x86_64-*-mingw32* | \
|
||||
@@ -1,91 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Kling <awesomekling@gmail.com>
|
||||
Date: Mon, 16 May 2022 15:01:06 +0200
|
||||
Subject: [PATCH] libgcc: Build for SerenityOS
|
||||
|
||||
This patch enables building gcc's own C runtime files, and sets up
|
||||
exception handling support.
|
||||
|
||||
Co-Authored-By: Gunnar Beutner <gbeutner@serenityos.org>
|
||||
Co-Authored-By: Itamar <itamar8910@gmail.com>
|
||||
Co-Authored-By: Nico Weber <thakis@chromium.org>
|
||||
Co-Authored-By: Andrew Kaster <andrewdkaster@gmail.com>
|
||||
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Co-Authored-By: Philip Herron <herron.philip@googlemail.com>
|
||||
Co-Authored-By: Shannon Booth <shannon@serenityos.org>
|
||||
---
|
||||
gcc/configure | 3 +++
|
||||
libgcc/config.host | 21 +++++++++++++++++++++
|
||||
libgcc/unwind-dw2-fde-dip.c | 6 ++++++
|
||||
3 files changed, 30 insertions(+)
|
||||
|
||||
diff --git a/gcc/configure b/gcc/configure
|
||||
index c7b26d1927de62d7b3a49ea9ac0a998979659cf2..5fcfaa3cfff30d2e8d1cdf3f62bf2125e2f99179 100755
|
||||
--- a/gcc/configure
|
||||
+++ b/gcc/configure
|
||||
@@ -31377,6 +31377,9 @@ case "$target" in
|
||||
*-linux-musl*)
|
||||
gcc_cv_target_dl_iterate_phdr=yes
|
||||
;;
|
||||
+ *-serenity*)
|
||||
+ gcc_cv_target_dl_iterate_phdr=yes
|
||||
+ ;;
|
||||
esac
|
||||
|
||||
if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
|
||||
diff --git a/libgcc/config.host b/libgcc/config.host
|
||||
index 9d7212028d063648206b521705601ad2b50620c5..9f3c857a1e0cade7171b371c4e823487a5e3b2f2 100644
|
||||
--- a/libgcc/config.host
|
||||
+++ b/libgcc/config.host
|
||||
@@ -1312,6 +1312,11 @@ riscv*-*-freebsd*)
|
||||
tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
|
||||
extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o"
|
||||
;;
|
||||
+riscv64-*-serenity*)
|
||||
+ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o"
|
||||
+ tmake_file="$tmake_file riscv/t-softfp64 t-softfp riscv/t-elf riscv/t-elf64 t-slibgcc-libgcc t-eh-dw2-dip"
|
||||
+ tmake_file="$tmake_file riscv/t-crtstuff t-crtstuff-pic t-libgcc-pic t-slibgcc t-slibgcc-gld-nover"
|
||||
+ ;;
|
||||
riscv*-*-*)
|
||||
tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address}"
|
||||
extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o"
|
||||
@@ -1525,6 +1530,22 @@ nvptx-*)
|
||||
tmake_file="$tmake_file nvptx/t-nvptx"
|
||||
extra_parts="crt0.o"
|
||||
;;
|
||||
+i[34567]86-*-serenity*)
|
||||
+ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o"
|
||||
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic t-slibgcc t-eh-dw2-dip"
|
||||
+ ;;
|
||||
+x86_64-*-serenity*)
|
||||
+ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o"
|
||||
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic t-slibgcc t-eh-dw2-dip"
|
||||
+ ;;
|
||||
+aarch64-*-serenity*)
|
||||
+ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o"
|
||||
+ extra_parts="$extra_parts crtfastmath.o"
|
||||
+ tmake_file="$tmake_file ${cpu_type}/t-aarch64"
|
||||
+ tmake_file="$tmake_file ${cpu_type}/t-lse t-slibgcc t-slibgcc-libgcc t-slibgcc-gld-nover"
|
||||
+ tmake_file="$tmake_file ${cpu_type}/t-softfp t-softfp t-crtfm"
|
||||
+ md_unwind_header=aarch64/aarch64-unwind.h
|
||||
+ ;;
|
||||
*)
|
||||
echo "*** Configuration ${host} not supported" 1>&2
|
||||
exit 1
|
||||
diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c
|
||||
index 28ea0e64e0e8d8c1faf52194a78cfc98398eceb8..2b139330c045ee01651bececc4d882f09f380cce 100644
|
||||
--- a/libgcc/unwind-dw2-fde-dip.c
|
||||
+++ b/libgcc/unwind-dw2-fde-dip.c
|
||||
@@ -57,6 +57,12 @@
|
||||
# define USE_PT_GNU_EH_FRAME
|
||||
#endif
|
||||
|
||||
+#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
|
||||
+ && defined(TARGET_DL_ITERATE_PHDR) \
|
||||
+ && defined(__serenity__)
|
||||
+# define USE_PT_GNU_EH_FRAME
|
||||
+#endif
|
||||
+
|
||||
#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
|
||||
&& defined(TARGET_DL_ITERATE_PHDR) \
|
||||
&& defined(__linux__)
|
||||
@@ -1,30 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Kling <awesomekling@gmail.com>
|
||||
Date: Mon, 16 May 2022 15:03:14 +0200
|
||||
Subject: [PATCH] libgcc: Do not link libgcc_s to LibC
|
||||
|
||||
The toolchain is built before LibC, so linking to the C runtime library
|
||||
would fail.
|
||||
|
||||
Co-Authored-By: Gunnar Beutner <gbeutner@serenityos.org>
|
||||
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Co-Authored-By: Itamar <itamar8910@gmail.com>
|
||||
Co-Authored-By: Nico Weber <thakis@chromium.org>
|
||||
Co-Authored-By: Philip Herron <herron.philip@googlemail.com>
|
||||
Co-Authored-By: Shannon Booth <shannon@serenityos.org>
|
||||
---
|
||||
libgcc/config/t-slibgcc | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/libgcc/config/t-slibgcc b/libgcc/config/t-slibgcc
|
||||
index 29765bce8021a69980bbd3e283fe812f22c63242..3f18082dd0542c2161637ceeaef9d4738c4f18c4 100644
|
||||
--- a/libgcc/config/t-slibgcc
|
||||
+++ b/libgcc/config/t-slibgcc
|
||||
@@ -26,7 +26,6 @@ SHLIB_MAP = @shlib_map_file@
|
||||
SHLIB_OBJS = @shlib_objs@
|
||||
SHLIB_DIR = @multilib_dir@
|
||||
SHLIB_SLIBDIR_QUAL = @shlib_slibdir_qual@
|
||||
-SHLIB_LC = -lc
|
||||
SHLIB_MAKE_SOLINK = $(LN_S) $(SHLIB_SONAME) $(SHLIB_DIR)/$(SHLIB_SOLINK)
|
||||
SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \
|
||||
$(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
|
||||
@@ -1,27 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Date: Mon, 16 May 2022 15:04:33 +0200
|
||||
Subject: [PATCH] i386: Disable math errno for SerenityOS
|
||||
|
||||
SerenityOS uses exceptions for math error handling, which allows the
|
||||
compiler to do more optimizations on calls to math functions. This patch
|
||||
has the effect of setting -fno-math-errno by default.
|
||||
---
|
||||
gcc/common/config/i386/i386-common.cc | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/gcc/common/config/i386/i386-common.cc b/gcc/common/config/i386/i386-common.cc
|
||||
index c72644cb7db37b18cb22cf1ff02a972a18509d01..cce666b274cd6129796efc81870428dc17a6f229 100644
|
||||
--- a/gcc/common/config/i386/i386-common.cc
|
||||
+++ b/gcc/common/config/i386/i386-common.cc
|
||||
@@ -1854,6 +1854,10 @@ ix86_option_init_struct (struct gcc_options *opts)
|
||||
avoid calling them when that's the only reason we would. */
|
||||
opts->x_flag_errno_math = 0;
|
||||
|
||||
+#ifdef TARGET_SERENITY
|
||||
+ opts->x_flag_errno_math = 0;
|
||||
+#endif
|
||||
+
|
||||
opts->x_flag_pcc_struct_return = 2;
|
||||
opts->x_flag_asynchronous_unwind_tables = 2;
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Kling <awesomekling@gmail.com>
|
||||
Date: Mon, 16 May 2022 15:08:53 +0200
|
||||
Subject: [PATCH] libstdc++: Support SerenityOS
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
During the toolchain build, SerenityOS libraries are not available, so
|
||||
we have to manually tell libstdc++ about what our LibC supports.
|
||||
|
||||
In most places, we take the Newlib code paths.
|
||||
|
||||
Co-Authored-By: Gunnar Beutner <gbeutner@serenityos.org>
|
||||
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Co-Authored-By: Itamar <itamar8910@gmail.com>
|
||||
Co-Authored-By: James Mintram <me@jamesrm.com>
|
||||
Co-Authored-By: Martin Bříza <m@rtinbriza.cz>
|
||||
Co-Authored-By: Nico Weber <thakis@chromium.org>
|
||||
Co-Authored-By: Philip Herron <herron.philip@googlemail.com>
|
||||
Co-Authored-By: Shannon Booth <shannon@serenityos.org>
|
||||
---
|
||||
libstdc++-v3/acinclude.m4 | 4 ++--
|
||||
libstdc++-v3/configure | 11 ++++++++---
|
||||
libstdc++-v3/configure.host | 3 +++
|
||||
libstdc++-v3/crossconfig.m4 | 2 +-
|
||||
4 files changed, 14 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
|
||||
index 49cb0623e4f04665645b7ef2f0132bced452a892..52b0b2ef38457d5a02e1f21a3e65927402296d90 100644
|
||||
--- a/libstdc++-v3/acinclude.m4
|
||||
+++ b/libstdc++-v3/acinclude.m4
|
||||
@@ -1397,7 +1397,7 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
|
||||
ac_has_nanosleep=yes
|
||||
ac_has_sched_yield=yes
|
||||
;;
|
||||
- freebsd*|netbsd*|dragonfly*|rtems*)
|
||||
+ freebsd*|netbsd*|dragonfly*|rtems*|serenity*)
|
||||
ac_has_clock_monotonic=yes
|
||||
ac_has_clock_realtime=yes
|
||||
ac_has_nanosleep=yes
|
||||
@@ -2434,7 +2434,7 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
|
||||
dragonfly* | freebsd*)
|
||||
enable_clocale_flag=dragonfly
|
||||
;;
|
||||
- openbsd*)
|
||||
+ openbsd* | serenity*)
|
||||
enable_clocale_flag=newlib
|
||||
;;
|
||||
*)
|
||||
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
|
||||
index 9b6027775456469940da9c515dad5c0160d3cd3d..bd6c4ed05cb9621f855ed15d8e0825e5fc4d2d8c 100755
|
||||
--- a/libstdc++-v3/configure
|
||||
+++ b/libstdc++-v3/configure
|
||||
@@ -11910,6 +11910,11 @@ else
|
||||
lt_cv_dlopen_libs=
|
||||
;;
|
||||
|
||||
+ serenity*)
|
||||
+ lt_cv_dlopen="dlopen"
|
||||
+ lt_cv_dlopen_libs=""
|
||||
+ ;;
|
||||
+
|
||||
darwin*)
|
||||
# if libdl is installed we need to link against it
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
|
||||
@@ -16514,7 +16519,7 @@ fi
|
||||
dragonfly* | freebsd*)
|
||||
enable_clocale_flag=dragonfly
|
||||
;;
|
||||
- openbsd*)
|
||||
+ openbsd* | serenity*)
|
||||
enable_clocale_flag=newlib
|
||||
;;
|
||||
*)
|
||||
@@ -20675,7 +20680,7 @@ fi
|
||||
ac_has_nanosleep=yes
|
||||
ac_has_sched_yield=yes
|
||||
;;
|
||||
- freebsd*|netbsd*|dragonfly*|rtems*)
|
||||
+ freebsd*|netbsd*|dragonfly*|rtems*|serenity*)
|
||||
ac_has_clock_monotonic=yes
|
||||
ac_has_clock_realtime=yes
|
||||
ac_has_nanosleep=yes
|
||||
@@ -29361,7 +29366,7 @@ case "${host}" in
|
||||
# This is a freestanding configuration; there is nothing to do here.
|
||||
;;
|
||||
|
||||
- avr*-*-*)
|
||||
+ avr*-*-* | *serenity*)
|
||||
$as_echo "#define HAVE_ACOSF 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define HAVE_ASINF 1" >>confdefs.h
|
||||
diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
|
||||
index 9e7c7f02dfd1cce8ec663b3bd337a2ed4d736aad..609c641ff5e9b4f44db9a6909adb876b5e65349e 100644
|
||||
--- a/libstdc++-v3/configure.host
|
||||
+++ b/libstdc++-v3/configure.host
|
||||
@@ -297,6 +297,9 @@ case "${host_os}" in
|
||||
# Use libatomic if necessary and avoid libstdc++ specific atomicity support
|
||||
atomicity_dir="cpu/generic/atomicity_builtins"
|
||||
;;
|
||||
+ serenity*)
|
||||
+ os_include_dir="os/newlib"
|
||||
+ ;;
|
||||
solaris2*)
|
||||
os_include_dir="os/solaris"
|
||||
;;
|
||||
diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
|
||||
index b3269cb88e077425be95bfe6c424b08106cab93f..3bba9653675c98ae76caf6cb77bbc483886dc80b 100644
|
||||
--- a/libstdc++-v3/crossconfig.m4
|
||||
+++ b/libstdc++-v3/crossconfig.m4
|
||||
@@ -9,7 +9,7 @@ case "${host}" in
|
||||
# This is a freestanding configuration; there is nothing to do here.
|
||||
;;
|
||||
|
||||
- avr*-*-*)
|
||||
+ avr*-*-* | *serenity*)
|
||||
AC_DEFINE(HAVE_ACOSF)
|
||||
AC_DEFINE(HAVE_ASINF)
|
||||
AC_DEFINE(HAVE_ATAN2F)
|
||||
@@ -1,29 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Date: Mon, 11 Sep 2023 16:37:27 +0200
|
||||
Subject: [PATCH] libstdc++: Build static library with -fPIC
|
||||
|
||||
We want the libstdc++.a library to contain -fPIC code in order to link
|
||||
it statically into LibC/our shared objects. However, the build system
|
||||
forces no-pic/pie instead.
|
||||
|
||||
This hack is from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58638
|
||||
---
|
||||
libstdc++-v3/configure | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
|
||||
index bd6c4ed05cb9621f855ed15d8e0825e5fc4d2d8c..de0adb98973432cd6ee8e42adeaf5efa74546484 100755
|
||||
--- a/libstdc++-v3/configure
|
||||
+++ b/libstdc++-v3/configure
|
||||
@@ -15624,8 +15624,8 @@ if test "$enable_shared" = yes; then
|
||||
glibcxx_compiler_shared_flag="-D_GLIBCXX_SHARED"
|
||||
|
||||
else
|
||||
- glibcxx_lt_pic_flag=
|
||||
- glibcxx_compiler_pic_flag=
|
||||
+ glibcxx_lt_pic_flag="-prefer-pic"
|
||||
+ glibcxx_compiler_pic_flag="$lt_prog_compiler_pic_CXX"
|
||||
glibcxx_compiler_shared_flag=
|
||||
fi
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
|
||||
Date: Thu, 7 Mar 2024 14:36:03 +0100
|
||||
Subject: [PATCH] Include safe-ctype.h after C++ standard headers, to avoid
|
||||
over-poisoning
|
||||
|
||||
When building gcc's C++ sources against recent libc++, the poisoning of
|
||||
the ctype macros due to including safe-ctype.h before including C++
|
||||
standard headers such as <list>, <map>, etc, causes many compilation
|
||||
errors, similar to:
|
||||
|
||||
In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23:
|
||||
In file included from /home/dim/src/gcc/master/gcc/system.h:233:
|
||||
In file included from /usr/include/c++/v1/vector:321:
|
||||
In file included from
|
||||
/usr/include/c++/v1/__format/formatter_bool.h:20:
|
||||
In file included from
|
||||
/usr/include/c++/v1/__format/formatter_integral.h:32:
|
||||
In file included from /usr/include/c++/v1/locale:202:
|
||||
/usr/include/c++/v1/__locale:546:5: error: '__abi_tag__' attribute
|
||||
only applies to structs, variables, functions, and namespaces
|
||||
546 | _LIBCPP_INLINE_VISIBILITY
|
||||
| ^
|
||||
/usr/include/c++/v1/__config:813:37: note: expanded from macro
|
||||
'_LIBCPP_INLINE_VISIBILITY'
|
||||
813 | # define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
|
||||
| ^
|
||||
/usr/include/c++/v1/__config:792:26: note: expanded from macro
|
||||
'_LIBCPP_HIDE_FROM_ABI'
|
||||
792 |
|
||||
__attribute__((__abi_tag__(_LIBCPP_TOSTRING(
|
||||
_LIBCPP_VERSIONED_IDENTIFIER))))
|
||||
| ^
|
||||
In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23:
|
||||
In file included from /home/dim/src/gcc/master/gcc/system.h:233:
|
||||
In file included from /usr/include/c++/v1/vector:321:
|
||||
In file included from
|
||||
/usr/include/c++/v1/__format/formatter_bool.h:20:
|
||||
In file included from
|
||||
/usr/include/c++/v1/__format/formatter_integral.h:32:
|
||||
In file included from /usr/include/c++/v1/locale:202:
|
||||
/usr/include/c++/v1/__locale:547:37: error: expected ';' at end of
|
||||
declaration list
|
||||
547 | char_type toupper(char_type __c) const
|
||||
| ^
|
||||
/usr/include/c++/v1/__locale:553:48: error: too many arguments
|
||||
provided to function-like macro invocation
|
||||
553 | const char_type* toupper(char_type* __low, const
|
||||
char_type* __high) const
|
||||
| ^
|
||||
/home/dim/src/gcc/master/gcc/../include/safe-ctype.h:146:9: note:
|
||||
macro 'toupper' defined here
|
||||
146 | #define toupper(c) do_not_use_toupper_with_safe_ctype
|
||||
| ^
|
||||
|
||||
This is because libc++ uses different transitive includes than
|
||||
libstdc++, and some of those transitive includes pull in various ctype
|
||||
declarations (typically via <locale>).
|
||||
|
||||
There was already a special case for including <string> before
|
||||
safe-ctype.h, so move the rest of the C++ standard header includes to
|
||||
the same location, to fix the problem.
|
||||
|
||||
gcc/ChangeLog:
|
||||
|
||||
* system.h: Include safe-ctype.h after C++ standard headers.
|
||||
|
||||
Signed-off-by: Dimitry Andric <dimitry@andric.com>
|
||||
(cherry picked from commit 9970b576b7e4ae337af1268395ff221348c4b34a)
|
||||
---
|
||||
gcc/system.h | 39 ++++++++++++++++++---------------------
|
||||
1 file changed, 18 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/gcc/system.h b/gcc/system.h
|
||||
index cf45db3f97ed99dea13f602df76a587800d9b4f4..10f051dcfd7fad7f9b0cc78df8a8cc57d764aa09 100644
|
||||
--- a/gcc/system.h
|
||||
+++ b/gcc/system.h
|
||||
@@ -194,27 +194,8 @@ extern int fprintf_unlocked (FILE *, const char *, ...);
|
||||
#undef fread_unlocked
|
||||
#undef fwrite_unlocked
|
||||
|
||||
-/* Include <string> before "safe-ctype.h" to avoid GCC poisoning
|
||||
- the ctype macros through safe-ctype.h */
|
||||
-
|
||||
-#ifdef __cplusplus
|
||||
-#ifdef INCLUDE_STRING
|
||||
-# include <string>
|
||||
-#endif
|
||||
-#endif
|
||||
-
|
||||
-/* There are an extraordinary number of issues with <ctype.h>.
|
||||
- The last straw is that it varies with the locale. Use libiberty's
|
||||
- replacement instead. */
|
||||
-#include "safe-ctype.h"
|
||||
-
|
||||
-#include <sys/types.h>
|
||||
-
|
||||
-#include <errno.h>
|
||||
-
|
||||
-#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
|
||||
-extern int errno;
|
||||
-#endif
|
||||
+/* Include C++ standard headers before "safe-ctype.h" to avoid GCC
|
||||
+ poisoning the ctype macros through safe-ctype.h */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined (INCLUDE_ALGORITHM) || !defined (HAVE_SWAP_IN_UTILITY)
|
||||
@@ -229,6 +210,9 @@ extern int errno;
|
||||
#ifdef INCLUDE_SET
|
||||
# include <set>
|
||||
#endif
|
||||
+#ifdef INCLUDE_STRING
|
||||
+# include <string>
|
||||
+#endif
|
||||
#ifdef INCLUDE_VECTOR
|
||||
# include <vector>
|
||||
#endif
|
||||
@@ -245,6 +229,19 @@ extern int errno;
|
||||
# include <type_traits>
|
||||
#endif
|
||||
|
||||
+/* There are an extraordinary number of issues with <ctype.h>.
|
||||
+ The last straw is that it varies with the locale. Use libiberty's
|
||||
+ replacement instead. */
|
||||
+#include "safe-ctype.h"
|
||||
+
|
||||
+#include <sys/types.h>
|
||||
+
|
||||
+#include <errno.h>
|
||||
+
|
||||
+#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
|
||||
+extern int errno;
|
||||
+#endif
|
||||
+
|
||||
/* Some of glibc's string inlines cause warnings. Plus we'd rather
|
||||
rely on (and therefore test) GCC's string builtins. */
|
||||
#define __NO_STRING_INLINES
|
||||
@@ -1,135 +0,0 @@
|
||||
# Patches for gcc on SerenityOS
|
||||
|
||||
## `0001-Add-a-gcc-driver-for-SerenityOS.patch`
|
||||
|
||||
Add a gcc driver for SerenityOS
|
||||
|
||||
This patch adds support for the `*-*-serenity` target to gcc.
|
||||
|
||||
It specifies which flags need to be passed to the linker, defines the
|
||||
__serenity__ macro, sets the correct underlying type of `size_t` and
|
||||
`ptrdiff_t`, and enables IFUNCs.
|
||||
|
||||
|
||||
## `0002-fixincludes-Skip-for-SerenityOS-targets.patch`
|
||||
|
||||
fixincludes: Skip for SerenityOS targets
|
||||
|
||||
`fixincludes` is responsible for fixing mistakes in system headers that
|
||||
rely in compiler extensions that GCC doesn't support or cause errors in
|
||||
C++ mode.
|
||||
|
||||
Our headers don't have such problems, so this hack is of no use for us.
|
||||
|
||||
## `0003-libgcc-Build-for-SerenityOS.patch`
|
||||
|
||||
libgcc: Build for SerenityOS
|
||||
|
||||
This patch enables building gcc's own C runtime files, and sets up
|
||||
exception handling support.
|
||||
|
||||
|
||||
## `0004-libgcc-Do-not-link-libgcc_s-to-LibC.patch`
|
||||
|
||||
libgcc: Do not link libgcc_s to LibC
|
||||
|
||||
The toolchain is built before LibC, so linking to the C runtime library
|
||||
would fail.
|
||||
|
||||
|
||||
## `0005-i386-Disable-math-errno-for-SerenityOS.patch`
|
||||
|
||||
i386: Disable math errno for SerenityOS
|
||||
|
||||
SerenityOS uses exceptions for math error handling, which allows the
|
||||
compiler to do more optimizations on calls to math functions. This patch
|
||||
has the effect of setting -fno-math-errno by default.
|
||||
|
||||
## `0006-libstdc-Support-SerenityOS.patch`
|
||||
|
||||
libstdc++: Support SerenityOS
|
||||
|
||||
During the toolchain build, SerenityOS libraries are not available, so
|
||||
we have to manually tell libstdc++ about what our LibC supports.
|
||||
|
||||
In most places, we take the Newlib code paths.
|
||||
|
||||
|
||||
## `0007-libstdc-Build-static-library-with-fPIC.patch`
|
||||
|
||||
libstdc++: Build static library with -fPIC
|
||||
|
||||
We want the libstdc++.a library to contain -fPIC code in order to link
|
||||
it statically into LibC/our shared objects. However, the build system
|
||||
forces no-pic/pie instead.
|
||||
|
||||
This hack is from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58638
|
||||
|
||||
## `0008-Include-safe-ctype.h-after-C-standard-headers-to-avo.patch`
|
||||
|
||||
Include safe-ctype.h after C++ standard headers, to avoid over-poisoning
|
||||
|
||||
When building gcc's C++ sources against recent libc++, the poisoning of
|
||||
the ctype macros due to including safe-ctype.h before including C++
|
||||
standard headers such as <list>, <map>, etc, causes many compilation
|
||||
errors, similar to:
|
||||
|
||||
In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23:
|
||||
In file included from /home/dim/src/gcc/master/gcc/system.h:233:
|
||||
In file included from /usr/include/c++/v1/vector:321:
|
||||
In file included from
|
||||
/usr/include/c++/v1/__format/formatter_bool.h:20:
|
||||
In file included from
|
||||
/usr/include/c++/v1/__format/formatter_integral.h:32:
|
||||
In file included from /usr/include/c++/v1/locale:202:
|
||||
/usr/include/c++/v1/__locale:546:5: error: '__abi_tag__' attribute
|
||||
only applies to structs, variables, functions, and namespaces
|
||||
546 | _LIBCPP_INLINE_VISIBILITY
|
||||
| ^
|
||||
/usr/include/c++/v1/__config:813:37: note: expanded from macro
|
||||
'_LIBCPP_INLINE_VISIBILITY'
|
||||
813 | # define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
|
||||
| ^
|
||||
/usr/include/c++/v1/__config:792:26: note: expanded from macro
|
||||
'_LIBCPP_HIDE_FROM_ABI'
|
||||
792 |
|
||||
__attribute__((__abi_tag__(_LIBCPP_TOSTRING(
|
||||
_LIBCPP_VERSIONED_IDENTIFIER))))
|
||||
| ^
|
||||
In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23:
|
||||
In file included from /home/dim/src/gcc/master/gcc/system.h:233:
|
||||
In file included from /usr/include/c++/v1/vector:321:
|
||||
In file included from
|
||||
/usr/include/c++/v1/__format/formatter_bool.h:20:
|
||||
In file included from
|
||||
/usr/include/c++/v1/__format/formatter_integral.h:32:
|
||||
In file included from /usr/include/c++/v1/locale:202:
|
||||
/usr/include/c++/v1/__locale:547:37: error: expected ';' at end of
|
||||
declaration list
|
||||
547 | char_type toupper(char_type __c) const
|
||||
| ^
|
||||
/usr/include/c++/v1/__locale:553:48: error: too many arguments
|
||||
provided to function-like macro invocation
|
||||
553 | const char_type* toupper(char_type* __low, const
|
||||
char_type* __high) const
|
||||
| ^
|
||||
/home/dim/src/gcc/master/gcc/../include/safe-ctype.h:146:9: note:
|
||||
macro 'toupper' defined here
|
||||
146 | #define toupper(c) do_not_use_toupper_with_safe_ctype
|
||||
| ^
|
||||
|
||||
This is because libc++ uses different transitive includes than
|
||||
libstdc++, and some of those transitive includes pull in various ctype
|
||||
declarations (typically via <locale>).
|
||||
|
||||
There was already a special case for including <string> before
|
||||
safe-ctype.h, so move the rest of the C++ standard header includes to
|
||||
the same location, to fix the problem.
|
||||
|
||||
gcc/ChangeLog:
|
||||
|
||||
* system.h: Include safe-ctype.h after C++ standard headers.
|
||||
|
||||
Signed-off-by: Dimitry Andric <dimitry@andric.com>
|
||||
(cherry picked from commit 9970b576b7e4ae337af1268395ff221348c4b34a)
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
From ae61525fcf456ab395d55c45492a106d1275873a Mon Sep 17 00:00:00 2001
|
||||
From: Simon Marchi <simon.marchi@efficios.com>
|
||||
Date: Thu, 23 Feb 2023 12:35:40 -0500
|
||||
Subject: [PATCH] gdbsupport: ignore -Wenum-constexpr-conversion in
|
||||
enum-flags.h
|
||||
|
||||
When building with clang 16, we get:
|
||||
|
||||
CXX gdb.o
|
||||
In file included from /home/smarchi/src/binutils-gdb/gdb/gdb.c:19:
|
||||
In file included from /home/smarchi/src/binutils-gdb/gdb/defs.h:65:
|
||||
/home/smarchi/src/binutils-gdb/gdb/../gdbsupport/enum-flags.h:95:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]
|
||||
integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
|
||||
^
|
||||
|
||||
The error message does not make it clear in the context of which enum
|
||||
flag this fails (i.e. what is T in this context), but it doesn't really
|
||||
matter, we have similar warning/errors for many of them, if we let the
|
||||
build go through.
|
||||
|
||||
clang is right that the value -1 is invalid for the enum type we cast -1
|
||||
to. However, we do need this expression in order to select an integer
|
||||
type with the appropriate signedness. That is, with the same signedness
|
||||
as the underlying type of the enum.
|
||||
|
||||
I first wondered if that was really needed, if we couldn't use
|
||||
std::underlying_type for that. It turns out that the comment just above
|
||||
says:
|
||||
|
||||
/* Note that std::underlying_type<enum_type> is not what we want here,
|
||||
since that returns unsigned int even when the enum decays to signed
|
||||
int. */
|
||||
|
||||
I was surprised, because std::is_signed<std::underlying_type<enum_type>>
|
||||
returns the right thing. So I tried replacing all this with
|
||||
std::underlying_type, see if that would work. Doing so causes some
|
||||
build failures in unittests/enum-flags-selftests.c:
|
||||
|
||||
CXX unittests/enum-flags-selftests.o
|
||||
/home/smarchi/src/binutils-gdb/gdb/unittests/enum-flags-selftests.c:254:1: error: static assertion failed due to requirement 'gdb::is_same<selftests::enum_flags_tests::check_valid_expr254::archetype<enum_flags<s
|
||||
elftests::enum_flags_tests::RE>, selftests::enum_flags_tests::RE, enum_flags<selftests::enum_flags_tests::RE2>, selftests::enum_flags_tests::RE2, enum_flags<selftests::enum_flags_tests::URE>, selftests::enum_fla
|
||||
gs_tests::URE, int>, selftests::enum_flags_tests::check_valid_expr254::archetype<enum_flags<selftests::enum_flags_tests::RE>, selftests::enum_flags_tests::RE, enum_flags<selftests::enum_flags_tests::RE2>, selfte
|
||||
sts::enum_flags_tests::RE2, enum_flags<selftests::enum_flags_tests::URE>, selftests::enum_flags_tests::URE, unsigned int>>::value == true':
|
||||
CHECK_VALID (true, int, true ? EF () : EF2 ())
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/home/smarchi/src/binutils-gdb/gdb/unittests/enum-flags-selftests.c:91:3: note: expanded from macro 'CHECK_VALID'
|
||||
CHECK_VALID_EXPR_6 (EF, RE, EF2, RE2, UEF, URE, VALID, EXPR_TYPE, EXPR)
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/home/smarchi/src/binutils-gdb/gdb/../gdbsupport/valid-expr.h:105:3: note: expanded from macro 'CHECK_VALID_EXPR_6'
|
||||
CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2, \
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/home/smarchi/src/binutils-gdb/gdb/../gdbsupport/valid-expr.h:66:3: note: expanded from macro 'CHECK_VALID_EXPR_INT'
|
||||
static_assert (gdb::is_detected_exact<archetype<TYPES, EXPR_TYPE>, \
|
||||
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This is a bit hard to decode, but basically enumerations have the
|
||||
following funny property that they decay into a signed int, even if
|
||||
their implicit underlying type is unsigned. This code:
|
||||
|
||||
enum A {};
|
||||
enum B {};
|
||||
|
||||
int main() {
|
||||
std::cout << std::is_signed<std::underlying_type<A>::type>::value
|
||||
<< std::endl;
|
||||
std::cout << std::is_signed<std::underlying_type<B>::type>::value
|
||||
<< std::endl;
|
||||
auto result = true ? A() : B();
|
||||
std::cout << std::is_signed<decltype(result)>::value << std::endl;
|
||||
}
|
||||
|
||||
produces:
|
||||
|
||||
0
|
||||
0
|
||||
1
|
||||
|
||||
So, the "CHECK_VALID" above checks that this property works for enum flags the
|
||||
same way as it would if you were using their underlying enum types. And
|
||||
somehow, changing integer_for_size to use std::underlying_type breaks that.
|
||||
|
||||
Since the current code does what we want, and I don't see any way of doing it
|
||||
differently, ignore -Wenum-constexpr-conversion around it.
|
||||
|
||||
Change-Id: Ibc82ae7bbdb812102ae3f1dd099fc859dc6f3cc2
|
||||
---
|
||||
gdbsupport/enum-flags.h | 3 +++
|
||||
include/diagnostics.h | 9 +++++++++
|
||||
2 files changed, 12 insertions(+)
|
||||
|
||||
diff --git a/gdbsupport/enum-flags.h b/gdbsupport/enum-flags.h
|
||||
index 700037f6126..41ac7838f06 100644
|
||||
--- a/gdbsupport/enum-flags.h
|
||||
+++ b/gdbsupport/enum-flags.h
|
||||
@@ -91,9 +91,12 @@ template<> struct integer_for_size<8, 1> { typedef int64_t type; };
|
||||
template<typename T>
|
||||
struct enum_underlying_type
|
||||
{
|
||||
+ DIAGNOSTIC_PUSH
|
||||
+ DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION
|
||||
typedef typename
|
||||
integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
|
||||
type;
|
||||
+ DIAGNOSTIC_POP
|
||||
};
|
||||
|
||||
namespace enum_flags_detail
|
||||
diff --git a/include/diagnostics.h b/include/diagnostics.h
|
||||
index d3ff27bc008..41e6db65391 100644
|
||||
--- a/include/diagnostics.h
|
||||
+++ b/include/diagnostics.h
|
||||
@@ -76,6 +76,11 @@
|
||||
# define DIAGNOSTIC_ERROR_SWITCH \
|
||||
DIAGNOSTIC_ERROR ("-Wswitch")
|
||||
|
||||
+# if __has_warning ("-Wenum-constexpr-conversion")
|
||||
+# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION \
|
||||
+ DIAGNOSTIC_IGNORE ("-Wenum-constexpr-conversion")
|
||||
+# endif
|
||||
+
|
||||
#elif defined (__GNUC__) /* GCC */
|
||||
|
||||
# define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \
|
||||
@@ -155,4 +160,8 @@
|
||||
# define DIAGNOSTIC_ERROR_SWITCH
|
||||
#endif
|
||||
|
||||
+#ifndef DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION
|
||||
+# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION
|
||||
+#endif
|
||||
+
|
||||
#endif /* DIAGNOSTICS_H */
|
||||
--
|
||||
2.31.1
|
||||
@@ -1,52 +0,0 @@
|
||||
From 59d321f27907434ef9a10defd96d58272a963fd9 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Date: Thu, 24 Mar 2022 19:23:23 +0100
|
||||
Subject: [PATCH] gdb: Add support for SerenityOS
|
||||
|
||||
---
|
||||
bfd/config.bfd | 15 +++++++++++++++
|
||||
1 file changed, 15 insertions(+)
|
||||
|
||||
diff --git a/bfd/config.bfd b/bfd/config.bfd
|
||||
index 30087e3..58e0b80 100644
|
||||
--- a/bfd/config.bfd
|
||||
+++ b/bfd/config.bfd
|
||||
@@ -255,6 +255,11 @@ case "${targ}" in
|
||||
targ_selvecs=aarch64_elf64_be_cloudabi_vec
|
||||
want64=true
|
||||
;;
|
||||
+ aarch64-*-serenity*)
|
||||
+ targ_defvec=aarch64_elf64_le_vec
|
||||
+ targ_selvecs=
|
||||
+ want64=true
|
||||
+ ;;
|
||||
aarch64-*-linux* | aarch64-*-netbsd*)
|
||||
targ_defvec=aarch64_elf64_le_vec
|
||||
targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec"
|
||||
@@ -634,6 +639,11 @@ case "${targ}" in
|
||||
targ_selvecs=
|
||||
targ64_selvecs=x86_64_elf64_vec
|
||||
;;
|
||||
+ i[3-7]86-*-serenity*)
|
||||
+ targ_defvec=i386_elf32_vec
|
||||
+ targ_selvecs=
|
||||
+ targ64_selvecs=x86_64_elf64_vec
|
||||
+ ;;
|
||||
#ifdef BFD64
|
||||
x86_64-*-cloudabi*)
|
||||
targ_defvec=x86_64_elf64_cloudabi_vec
|
||||
@@ -694,6 +704,11 @@ case "${targ}" in
|
||||
targ_selvecs=i386_elf32_vec
|
||||
want64=true
|
||||
;;
|
||||
+ x86_64-*-serenity*)
|
||||
+ targ_defvec=x86_64_elf64_vec
|
||||
+ targ_selvecs=i386_elf32_vec
|
||||
+ want64=true
|
||||
+ ;;
|
||||
#endif
|
||||
i[3-7]86-*-lynxos*)
|
||||
targ_defvec=i386_elf32_vec
|
||||
--
|
||||
2.35.1
|
||||
|
||||
@@ -1,754 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Date: Thu, 14 Apr 2022 10:09:50 +0200
|
||||
Subject: [PATCH] [clang] Add support for SerenityOS
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Adds support for the `$arch-pc-serenity` target to the Clang front end.
|
||||
This makes the compiler look for libraries and headers in the right
|
||||
places, and enables some security mitigations like stack-smashing
|
||||
protection and position-independent code by default.
|
||||
|
||||
Co-authored-by: kleines Filmröllchen <filmroellchen@serenityos.org>
|
||||
Co-authored-by: Andrew Kaster <akaster@serenityos.org>
|
||||
Co-authored-by: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Co-authored-by: Dan Klishch <danilklishch@gmail.com>
|
||||
---
|
||||
clang/lib/Basic/Targets.cpp | 12 +
|
||||
clang/lib/Basic/Targets/OSTargets.h | 17 ++
|
||||
clang/lib/Driver/CMakeLists.txt | 1 +
|
||||
clang/lib/Driver/Driver.cpp | 4 +
|
||||
clang/lib/Driver/ToolChain.cpp | 5 +-
|
||||
clang/lib/Driver/ToolChains/Serenity.cpp | 216 ++++++++++++++++++
|
||||
clang/lib/Driver/ToolChains/Serenity.h | 84 +++++++
|
||||
clang/lib/Lex/InitHeaderSearch.cpp | 1 +
|
||||
.../usr/include/c++/v1/.keep | 0
|
||||
.../include/x86_64-pc-serenity/c++/v1/.keep | 0
|
||||
.../serenity_x86_64_tree/usr/lib/crt0.o | 0
|
||||
.../usr/lib/crt0_shared.o | 0
|
||||
.../serenity_x86_64_tree/usr/lib/crti.o | 0
|
||||
.../serenity_x86_64_tree/usr/lib/crtn.o | 0
|
||||
.../serenity_x86_64_tree/usr/local/.keep | 0
|
||||
clang/test/Driver/pic.c | 6 +
|
||||
clang/test/Driver/save-stats.c | 2 +
|
||||
clang/test/Driver/serenity.cpp | 196 ++++++++++++++++
|
||||
18 files changed, 543 insertions(+), 1 deletion(-)
|
||||
create mode 100644 clang/lib/Driver/ToolChains/Serenity.cpp
|
||||
create mode 100644 clang/lib/Driver/ToolChains/Serenity.h
|
||||
create mode 100644 clang/test/Driver/Inputs/serenity_x86_64_tree/usr/include/c++/v1/.keep
|
||||
create mode 100644 clang/test/Driver/Inputs/serenity_x86_64_tree/usr/include/x86_64-pc-serenity/c++/v1/.keep
|
||||
create mode 100644 clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crt0.o
|
||||
create mode 100644 clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crt0_shared.o
|
||||
create mode 100644 clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crti.o
|
||||
create mode 100644 clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crtn.o
|
||||
create mode 100644 clang/test/Driver/Inputs/serenity_x86_64_tree/usr/local/.keep
|
||||
create mode 100644 clang/test/Driver/serenity.cpp
|
||||
|
||||
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
|
||||
index e3283510c6aa..8cf3fc4fb346 100644
|
||||
--- a/clang/lib/Basic/Targets.cpp
|
||||
+++ b/clang/lib/Basic/Targets.cpp
|
||||
@@ -166,6 +166,9 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
|
||||
case llvm::Triple::OpenBSD:
|
||||
return std::make_unique<OpenBSDTargetInfo<AArch64leTargetInfo>>(Triple,
|
||||
Opts);
|
||||
+ case llvm::Triple::Serenity:
|
||||
+ return std::make_unique<SerenityTargetInfo<AArch64leTargetInfo>>(Triple,
|
||||
+ Opts);
|
||||
case llvm::Triple::Win32:
|
||||
switch (Triple.getEnvironment()) {
|
||||
case llvm::Triple::GNU:
|
||||
@@ -463,6 +466,9 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
|
||||
return std::make_unique<OHOSTargetInfo<RISCV64TargetInfo>>(Triple,
|
||||
Opts);
|
||||
}
|
||||
+ case llvm::Triple::Serenity:
|
||||
+ return std::make_unique<SerenityTargetInfo<RISCV64TargetInfo>>(Triple,
|
||||
+ Opts);
|
||||
default:
|
||||
return std::make_unique<RISCV64TargetInfo>(Triple, Opts);
|
||||
}
|
||||
@@ -586,6 +592,9 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
|
||||
return std::make_unique<MCUX86_32TargetInfo>(Triple, Opts);
|
||||
case llvm::Triple::Hurd:
|
||||
return std::make_unique<HurdTargetInfo<X86_32TargetInfo>>(Triple, Opts);
|
||||
+ case llvm::Triple::Serenity:
|
||||
+ return std::make_unique<SerenityTargetInfo<X86_32TargetInfo>>(Triple,
|
||||
+ Opts);
|
||||
default:
|
||||
return std::make_unique<X86_32TargetInfo>(Triple, Opts);
|
||||
}
|
||||
@@ -646,6 +655,9 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
|
||||
return std::make_unique<PS5OSTargetInfo<X86_64TargetInfo>>(Triple, Opts);
|
||||
case llvm::Triple::Hurd:
|
||||
return std::make_unique<HurdTargetInfo<X86_64TargetInfo>>(Triple, Opts);
|
||||
+ case llvm::Triple::Serenity:
|
||||
+ return std::make_unique<SerenityTargetInfo<X86_64TargetInfo>>(Triple,
|
||||
+ Opts);
|
||||
default:
|
||||
return std::make_unique<X86_64TargetInfo>(Triple, Opts);
|
||||
}
|
||||
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
|
||||
index 4366c1149e40..3528e16d8690 100644
|
||||
--- a/clang/lib/Basic/Targets/OSTargets.h
|
||||
+++ b/clang/lib/Basic/Targets/OSTargets.h
|
||||
@@ -1000,6 +1000,23 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
+// SerenityOS target
|
||||
+template <typename Target>
|
||||
+class LLVM_LIBRARY_VISIBILITY SerenityTargetInfo : public OSTargetInfo<Target> {
|
||||
+protected:
|
||||
+ void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
|
||||
+ MacroBuilder &Builder) const override {
|
||||
+ Builder.defineMacro("__serenity__");
|
||||
+ DefineStd(Builder, "unix", Opts);
|
||||
+ }
|
||||
+
|
||||
+public:
|
||||
+ SerenityTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
|
||||
+ : OSTargetInfo<Target>(Triple, Opts) {
|
||||
+ this->WIntType = TargetInfo::UnsignedInt;
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
} // namespace targets
|
||||
} // namespace clang
|
||||
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_OSTARGETS_H
|
||||
diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
|
||||
index 58427e3f83c4..e8a081bbf728 100644
|
||||
--- a/clang/lib/Driver/CMakeLists.txt
|
||||
+++ b/clang/lib/Driver/CMakeLists.txt
|
||||
@@ -75,6 +75,7 @@ add_clang_library(clangDriver
|
||||
ToolChains/OpenBSD.cpp
|
||||
ToolChains/PS4CPU.cpp
|
||||
ToolChains/RISCVToolchain.cpp
|
||||
+ ToolChains/Serenity.cpp
|
||||
ToolChains/Solaris.cpp
|
||||
ToolChains/SPIRV.cpp
|
||||
ToolChains/TCE.cpp
|
||||
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
|
||||
index 93cddf742d52..8a821456ce28 100644
|
||||
--- a/clang/lib/Driver/Driver.cpp
|
||||
+++ b/clang/lib/Driver/Driver.cpp
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "ToolChains/PS4CPU.h"
|
||||
#include "ToolChains/RISCVToolchain.h"
|
||||
#include "ToolChains/SPIRV.h"
|
||||
+#include "ToolChains/Serenity.h"
|
||||
#include "ToolChains/Solaris.h"
|
||||
#include "ToolChains/TCE.h"
|
||||
#include "ToolChains/VEToolchain.h"
|
||||
@@ -6272,6 +6273,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
|
||||
case llvm::Triple::Fuchsia:
|
||||
TC = std::make_unique<toolchains::Fuchsia>(*this, Target, Args);
|
||||
break;
|
||||
+ case llvm::Triple::Serenity:
|
||||
+ TC = std::make_unique<toolchains::Serenity>(*this, Target, Args);
|
||||
+ break;
|
||||
case llvm::Triple::Solaris:
|
||||
TC = std::make_unique<toolchains::Solaris>(*this, Target, Args);
|
||||
break;
|
||||
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
|
||||
index 388030592b48..02a706da75a4 100644
|
||||
--- a/clang/lib/Driver/ToolChain.cpp
|
||||
+++ b/clang/lib/Driver/ToolChain.cpp
|
||||
@@ -589,6 +589,8 @@ StringRef ToolChain::getOSLibName() const {
|
||||
return "sunos";
|
||||
case llvm::Triple::AIX:
|
||||
return "aix";
|
||||
+ case llvm::Triple::Serenity:
|
||||
+ return "serenity";
|
||||
default:
|
||||
return getOS();
|
||||
}
|
||||
@@ -1081,7 +1083,8 @@ ToolChain::UnwindLibType ToolChain::GetUnwindLibType(
|
||||
else if (LibName == "platform" || LibName == "") {
|
||||
ToolChain::RuntimeLibType RtLibType = GetRuntimeLibType(Args);
|
||||
if (RtLibType == ToolChain::RLT_CompilerRT) {
|
||||
- if (getTriple().isAndroid() || getTriple().isOSAIX())
|
||||
+ if (getTriple().isAndroid() || getTriple().isOSAIX() ||
|
||||
+ getTriple().isOSSerenity())
|
||||
unwindLibType = ToolChain::UNW_CompilerRT;
|
||||
else
|
||||
unwindLibType = ToolChain::UNW_None;
|
||||
diff --git a/clang/lib/Driver/ToolChains/Serenity.cpp b/clang/lib/Driver/ToolChains/Serenity.cpp
|
||||
new file mode 100644
|
||||
index 000000000000..2167758100bc
|
||||
--- /dev/null
|
||||
+++ b/clang/lib/Driver/ToolChains/Serenity.cpp
|
||||
@@ -0,0 +1,216 @@
|
||||
+//===---- Serenity.cpp - SerenityOS ToolChain Implementation ----*- C++ -*-===//
|
||||
+//
|
||||
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
+// See https://llvm.org/LICENSE.txt for license information.
|
||||
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
+//
|
||||
+//===----------------------------------------------------------------------===//
|
||||
+
|
||||
+#include "Serenity.h"
|
||||
+#include "CommonArgs.h"
|
||||
+#include "clang/Config/config.h"
|
||||
+#include "clang/Driver/Compilation.h"
|
||||
+#include "clang/Driver/Driver.h"
|
||||
+#include "clang/Driver/Options.h"
|
||||
+#include "clang/Driver/SanitizerArgs.h"
|
||||
+#include "llvm/Option/ArgList.h"
|
||||
+#include "llvm/Support/VirtualFileSystem.h"
|
||||
+#include <string>
|
||||
+
|
||||
+using namespace clang::driver;
|
||||
+using namespace clang::driver::toolchains;
|
||||
+using namespace clang;
|
||||
+using namespace llvm::opt;
|
||||
+
|
||||
+static bool getPIE(const ArgList &Args, const ToolChain &TC) {
|
||||
+ if (Args.hasArg(options::OPT_static, options::OPT_shared,
|
||||
+ options::OPT_static_pie))
|
||||
+ return false;
|
||||
+ Arg *Last = Args.getLastArg(options::OPT_pie, options::OPT_no_pie);
|
||||
+ return Last ? Last->getOption().matches(options::OPT_pie) : true;
|
||||
+}
|
||||
+
|
||||
+void tools::serenity::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
+ const InputInfo &Output,
|
||||
+ const InputInfoList &Inputs,
|
||||
+ const ArgList &Args,
|
||||
+ const char *LinkingOutput) const {
|
||||
+ const auto &TC = getToolChain();
|
||||
+ const auto &D = TC.getDriver();
|
||||
+ const bool IsShared = Args.hasArg(options::OPT_shared);
|
||||
+ const bool IsStatic =
|
||||
+ Args.hasArg(options::OPT_static) && !Args.hasArg(options::OPT_static_pie);
|
||||
+ const bool IsRdynamic = Args.hasArg(options::OPT_rdynamic);
|
||||
+ const bool IsStaticPIE = Args.hasArg(options::OPT_static_pie);
|
||||
+ const bool IsPIE = getPIE(Args, TC);
|
||||
+ ArgStringList CmdArgs;
|
||||
+
|
||||
+ if (!D.SysRoot.empty())
|
||||
+ CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
|
||||
+
|
||||
+ if (IsPIE || IsStaticPIE)
|
||||
+ CmdArgs.push_back("-pie");
|
||||
+
|
||||
+ if (IsShared)
|
||||
+ CmdArgs.push_back("-shared");
|
||||
+
|
||||
+ if (IsStatic || IsStaticPIE)
|
||||
+ CmdArgs.push_back("-static");
|
||||
+
|
||||
+ if (IsStaticPIE) {
|
||||
+ CmdArgs.push_back("--no-dynamic-linker");
|
||||
+ CmdArgs.push_back("-z");
|
||||
+ CmdArgs.push_back("text");
|
||||
+ }
|
||||
+
|
||||
+ if (!IsStatic && !IsStaticPIE) {
|
||||
+ if (IsRdynamic)
|
||||
+ CmdArgs.push_back("-export-dynamic");
|
||||
+ CmdArgs.push_back("-dynamic-linker");
|
||||
+ CmdArgs.push_back("/usr/lib/Loader.so");
|
||||
+ }
|
||||
+
|
||||
+ CmdArgs.push_back("--eh-frame-hdr");
|
||||
+
|
||||
+ assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
|
||||
+ if (Output.isFilename()) {
|
||||
+ CmdArgs.push_back("-o");
|
||||
+ CmdArgs.push_back(Output.getFilename());
|
||||
+ }
|
||||
+
|
||||
+ CmdArgs.push_back("-z");
|
||||
+ CmdArgs.push_back("pack-relative-relocs");
|
||||
+
|
||||
+ bool HasNoStdLib = Args.hasArg(options::OPT_nostdlib, options::OPT_r);
|
||||
+ bool HasNoStdLibXX = Args.hasArg(options::OPT_nostdlibxx);
|
||||
+ bool HasNoLibC = Args.hasArg(options::OPT_nolibc);
|
||||
+ bool HasNoStartFiles = Args.hasArg(options::OPT_nostartfiles);
|
||||
+ bool HasNoDefaultLibs = Args.hasArg(options::OPT_nodefaultlibs);
|
||||
+
|
||||
+ bool ShouldLinkStartFiles = !HasNoStartFiles && !HasNoStdLib;
|
||||
+ bool ShouldLinkCompilerRuntime = !HasNoDefaultLibs && !HasNoStdLib;
|
||||
+ bool ShouldLinkLibC = !HasNoLibC && !HasNoStdLib && !HasNoDefaultLibs;
|
||||
+ bool ShouldLinkLibCXX = D.CCCIsCXX() && !HasNoStdLibXX && !HasNoStdLib && !HasNoDefaultLibs;
|
||||
+
|
||||
+ if (ShouldLinkStartFiles) {
|
||||
+ CmdArgs.push_back(Args.MakeArgString(
|
||||
+ TC.GetFilePath((IsShared) ? "crt0_shared.o" : "crt0.o")));
|
||||
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crti.o")));
|
||||
+
|
||||
+ std::string crtbegin_path;
|
||||
+ if (TC.GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT) {
|
||||
+ std::string crtbegin =
|
||||
+ TC.getCompilerRT(Args, "crtbegin", ToolChain::FT_Object);
|
||||
+ if (TC.getVFS().exists(crtbegin))
|
||||
+ crtbegin_path = crtbegin;
|
||||
+ }
|
||||
+ if (crtbegin_path.empty()) {
|
||||
+ const char *crtbegin = (IsShared || IsPIE) ? "crtbeginS.o" : "crtbegin.o";
|
||||
+ crtbegin_path = TC.GetFilePath(crtbegin);
|
||||
+ }
|
||||
+ CmdArgs.push_back(Args.MakeArgString(crtbegin_path));
|
||||
+ }
|
||||
+
|
||||
+ Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
|
||||
+
|
||||
+ TC.AddFilePathLibArgs(Args, CmdArgs);
|
||||
+
|
||||
+ if (D.isUsingLTO()) {
|
||||
+ assert(!Inputs.empty() && "Must have at least one input.");
|
||||
+ // Find the first filename InputInfo object.
|
||||
+ auto const* Input = llvm::find_if(
|
||||
+ Inputs, [](const InputInfo &II) -> bool { return II.isFilename(); });
|
||||
+ if (Input == Inputs.end())
|
||||
+ // For a very rare case, all of the inputs to the linker are
|
||||
+ // InputArg. If that happens, just use the first InputInfo.
|
||||
+ Input = Inputs.begin();
|
||||
+
|
||||
+ addLTOOptions(TC, Args, CmdArgs, Output, *Input,
|
||||
+ D.getLTOMode() == LTOK_Thin);
|
||||
+ }
|
||||
+
|
||||
+ Args.addAllArgs(CmdArgs, {options::OPT_T_Group, options::OPT_s,
|
||||
+ options::OPT_t, options::OPT_r});
|
||||
+
|
||||
+ addLinkerCompressDebugSectionsOption(TC, Args, CmdArgs);
|
||||
+
|
||||
+ AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
|
||||
+
|
||||
+ if (ShouldLinkCompilerRuntime) {
|
||||
+ AddRunTimeLibs(TC, D, CmdArgs, Args);
|
||||
+
|
||||
+ // We supply our own sanitizer runtimes that output errors to the
|
||||
+ // Kernel debug log as well as stderr.
|
||||
+ // FIXME: Properly port clang/gcc sanitizers and use those instead.
|
||||
+ const SanitizerArgs &Sanitize = TC.getSanitizerArgs(Args);
|
||||
+ if (Sanitize.needsUbsanRt())
|
||||
+ CmdArgs.push_back("-lubsan");
|
||||
+ }
|
||||
+
|
||||
+ if (ShouldLinkLibCXX) {
|
||||
+ bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
|
||||
+ !Args.hasArg(options::OPT_static);
|
||||
+ CmdArgs.push_back("--push-state");
|
||||
+ CmdArgs.push_back("--as-needed");
|
||||
+ if (OnlyLibstdcxxStatic)
|
||||
+ CmdArgs.push_back("-Bstatic");
|
||||
+ TC.AddCXXStdlibLibArgs(Args, CmdArgs);
|
||||
+ if (OnlyLibstdcxxStatic)
|
||||
+ CmdArgs.push_back("-Bdynamic");
|
||||
+ CmdArgs.push_back("--pop-state");
|
||||
+ }
|
||||
+
|
||||
+ // Silence warnings when linking C code with a C++ '-stdlib' argument.
|
||||
+ Args.ClaimAllArgs(options::OPT_stdlib_EQ);
|
||||
+
|
||||
+ if (ShouldLinkLibC)
|
||||
+ CmdArgs.push_back("-lc");
|
||||
+
|
||||
+ if (ShouldLinkStartFiles) {
|
||||
+ std::string crtend_path;
|
||||
+ if (TC.GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT) {
|
||||
+ std::string crtend =
|
||||
+ TC.getCompilerRT(Args, "crtend", ToolChain::FT_Object);
|
||||
+ if (TC.getVFS().exists(crtend))
|
||||
+ crtend_path = crtend;
|
||||
+ }
|
||||
+ if (crtend_path.empty()) {
|
||||
+ const char *crtend = (IsShared || IsPIE) ? "crtendS.o" : "crtend.o";
|
||||
+ crtend_path = TC.GetFilePath(crtend);
|
||||
+ }
|
||||
+ CmdArgs.push_back(Args.MakeArgString(crtend_path));
|
||||
+
|
||||
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtn.o")));
|
||||
+ }
|
||||
+
|
||||
+ const char *Exec = Args.MakeArgString(TC.GetLinkerPath());
|
||||
+ C.addCommand(std::make_unique<Command>(JA, *this,
|
||||
+ ResponseFileSupport::AtFileCurCP(),
|
||||
+ Exec, CmdArgs, Inputs, Output));
|
||||
+}
|
||||
+
|
||||
+Serenity::Serenity(const Driver &D, const llvm::Triple &Triple,
|
||||
+ const ArgList &Args)
|
||||
+ : Generic_ELF(D, Triple, Args) {
|
||||
+ getFilePaths().push_back(concat(getDriver().SysRoot, "/usr/lib"));
|
||||
+}
|
||||
+
|
||||
+Tool *Serenity::buildLinker() const {
|
||||
+ return new tools::serenity::Linker(*this);
|
||||
+}
|
||||
+
|
||||
+void Serenity::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
||||
+ ArgStringList &CC1Args) const {
|
||||
+ const Driver &D = getDriver();
|
||||
+
|
||||
+ if (DriverArgs.hasArg(options::OPT_nostdinc))
|
||||
+ return;
|
||||
+
|
||||
+ if (!DriverArgs.hasArg(options::OPT_nobuiltininc))
|
||||
+ addSystemInclude(DriverArgs, CC1Args, concat(D.ResourceDir, "/include"));
|
||||
+
|
||||
+ if (DriverArgs.hasArg(options::OPT_nostdlibinc))
|
||||
+ return;
|
||||
+
|
||||
+ addSystemInclude(DriverArgs, CC1Args, concat(D.SysRoot, "/usr/include"));
|
||||
+}
|
||||
diff --git a/clang/lib/Driver/ToolChains/Serenity.h b/clang/lib/Driver/ToolChains/Serenity.h
|
||||
new file mode 100644
|
||||
index 000000000000..2a1f685cb662
|
||||
--- /dev/null
|
||||
+++ b/clang/lib/Driver/ToolChains/Serenity.h
|
||||
@@ -0,0 +1,84 @@
|
||||
+//===---- Serenity.h - SerenityOS ToolChain Implementation ------*- C++ -*-===//
|
||||
+//
|
||||
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
+// See https://llvm.org/LICENSE.txt for license information.
|
||||
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
+//
|
||||
+//===----------------------------------------------------------------------===//
|
||||
+
|
||||
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SERENITY_H
|
||||
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SERENITY_H
|
||||
+
|
||||
+#include "Gnu.h"
|
||||
+#include "clang/Basic/LangOptions.h"
|
||||
+#include "clang/Driver/Tool.h"
|
||||
+#include "clang/Driver/ToolChain.h"
|
||||
+
|
||||
+namespace clang {
|
||||
+namespace driver {
|
||||
+namespace tools {
|
||||
+namespace serenity {
|
||||
+
|
||||
+class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
|
||||
+public:
|
||||
+ Linker(const ToolChain &TC) : Tool("serenity::Linker", "linker", TC) {}
|
||||
+
|
||||
+ bool hasIntegratedCPP() const override { return false; }
|
||||
+ bool isLinkJob() const override { return true; }
|
||||
+
|
||||
+ void ConstructJob(Compilation &C, const JobAction &JA,
|
||||
+ const InputInfo &Output, const InputInfoList &Inputs,
|
||||
+ const llvm::opt::ArgList &TCArgs,
|
||||
+ const char *LinkingOutput) const override;
|
||||
+};
|
||||
+} // end namespace serenity
|
||||
+} // end namespace tools
|
||||
+
|
||||
+namespace toolchains {
|
||||
+
|
||||
+class LLVM_LIBRARY_VISIBILITY Serenity final : public Generic_ELF {
|
||||
+public:
|
||||
+ Serenity(const Driver &D, const llvm::Triple &Triple,
|
||||
+ const llvm::opt::ArgList &Args);
|
||||
+
|
||||
+ void
|
||||
+ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
|
||||
+ llvm::opt::ArgStringList &CC1Args) const override;
|
||||
+
|
||||
+ RuntimeLibType GetDefaultRuntimeLibType() const override {
|
||||
+ return ToolChain::RLT_CompilerRT;
|
||||
+ }
|
||||
+
|
||||
+ CXXStdlibType GetDefaultCXXStdlibType() const override {
|
||||
+ return ToolChain::CST_Libcxx;
|
||||
+ }
|
||||
+
|
||||
+ const char *getDefaultLinker() const override { return "ld.lld"; }
|
||||
+
|
||||
+ bool HasNativeLLVMSupport() const override { return true; }
|
||||
+
|
||||
+ bool isPICDefault() const override { return true; }
|
||||
+ bool isPIEDefault(const llvm::opt::ArgList &) const override { return true; }
|
||||
+ bool isPICDefaultForced() const override { return false; }
|
||||
+
|
||||
+ bool IsMathErrnoDefault() const override { return false; }
|
||||
+
|
||||
+ UnwindTableLevel
|
||||
+ getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override {
|
||||
+ return UnwindTableLevel::Asynchronous;
|
||||
+ }
|
||||
+
|
||||
+ LangOptions::StackProtectorMode
|
||||
+ GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
|
||||
+ return LangOptions::SSPStrong;
|
||||
+ }
|
||||
+
|
||||
+protected:
|
||||
+ Tool *buildLinker() const override;
|
||||
+};
|
||||
+
|
||||
+} // end namespace toolchains
|
||||
+} // end namespace driver
|
||||
+} // end namespace clang
|
||||
+
|
||||
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SERENITY_H
|
||||
diff --git a/clang/lib/Lex/InitHeaderSearch.cpp b/clang/lib/Lex/InitHeaderSearch.cpp
|
||||
index 2218db15013d..36a6cd6425dd 100644
|
||||
--- a/clang/lib/Lex/InitHeaderSearch.cpp
|
||||
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
|
||||
@@ -304,6 +304,7 @@ bool InitHeaderSearch::ShouldAddDefaultIncludePaths(
|
||||
case llvm::Triple::PS4:
|
||||
case llvm::Triple::PS5:
|
||||
case llvm::Triple::RTEMS:
|
||||
+ case llvm::Triple::Serenity:
|
||||
case llvm::Triple::Solaris:
|
||||
case llvm::Triple::WASI:
|
||||
case llvm::Triple::ZOS:
|
||||
diff --git a/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/include/c++/v1/.keep b/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/include/c++/v1/.keep
|
||||
new file mode 100644
|
||||
index 000000000000..e69de29bb2d1
|
||||
diff --git a/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/include/x86_64-pc-serenity/c++/v1/.keep b/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/include/x86_64-pc-serenity/c++/v1/.keep
|
||||
new file mode 100644
|
||||
index 000000000000..e69de29bb2d1
|
||||
diff --git a/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crt0.o b/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crt0.o
|
||||
new file mode 100644
|
||||
index 000000000000..e69de29bb2d1
|
||||
diff --git a/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crt0_shared.o b/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crt0_shared.o
|
||||
new file mode 100644
|
||||
index 000000000000..e69de29bb2d1
|
||||
diff --git a/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crti.o b/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crti.o
|
||||
new file mode 100644
|
||||
index 000000000000..e69de29bb2d1
|
||||
diff --git a/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crtn.o b/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crtn.o
|
||||
new file mode 100644
|
||||
index 000000000000..e69de29bb2d1
|
||||
diff --git a/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/local/.keep b/clang/test/Driver/Inputs/serenity_x86_64_tree/usr/local/.keep
|
||||
new file mode 100644
|
||||
index 000000000000..e69de29bb2d1
|
||||
diff --git a/clang/test/Driver/pic.c b/clang/test/Driver/pic.c
|
||||
index aeddead6dbf8..57ef930b7848 100644
|
||||
--- a/clang/test/Driver/pic.c
|
||||
+++ b/clang/test/Driver/pic.c
|
||||
@@ -330,3 +330,9 @@
|
||||
// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
|
||||
// RUN: %clang -c %s --target=i586-pc-haiku -### 2>&1 \
|
||||
// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
|
||||
+
|
||||
+// Serenity has PIC and PIE by default
|
||||
+// RUN: %clang -c %s --target=x86_64-pc-serenity -### 2>&1 \
|
||||
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
|
||||
+// RUN: %clang -c %s --target=aarch64-pc-serenity -### 2>&1 \
|
||||
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
|
||||
diff --git a/clang/test/Driver/save-stats.c b/clang/test/Driver/save-stats.c
|
||||
index ad7867a99168..94d93dc23920 100644
|
||||
--- a/clang/test/Driver/save-stats.c
|
||||
+++ b/clang/test/Driver/save-stats.c
|
||||
@@ -32,6 +32,8 @@
|
||||
// RUN: %clang --target=x86_64-unknown-haiku -save-stats -flto -o obj/dir/save-stats.exe -Wl,-plugin-opt=-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO
|
||||
// RUN: %clang --target=avr -save-stats -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO
|
||||
// RUN: %clang --target=avr -save-stats -flto -o obj/dir/save-stats.exe -Wl,-plugin-opt=-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO
|
||||
+// RUN: %clang --target=x86_64-pc-serenity -save-stats -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO
|
||||
+// RUN: %clang --target=x86_64-pc-serenity -save-stats -flto -o obj/dir/save-stats.exe -Wl,-plugin-opt=-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO
|
||||
// CHECK-LTO: "-stats-file=save-stats.stats"
|
||||
// CHECK-LTO: "-o" "obj/dir{{/|\\\\}}save-stats.exe"
|
||||
// CHECK-LTO: "-plugin-opt=stats-file=save-stats.stats"
|
||||
diff --git a/clang/test/Driver/serenity.cpp b/clang/test/Driver/serenity.cpp
|
||||
new file mode 100644
|
||||
index 000000000000..48de4c0eb6ec
|
||||
--- /dev/null
|
||||
+++ b/clang/test/Driver/serenity.cpp
|
||||
@@ -0,0 +1,196 @@
|
||||
+// UNSUPPORTED: system-windows
|
||||
+
|
||||
+/// Check default header and linker paths
|
||||
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot=%S/Inputs/serenity_x86_64_tree \
|
||||
+// RUN: -ccc-install-dir %S/Inputs/serenity_x86_64/usr/local/bin -resource-dir=%S/Inputs/resource_dir \
|
||||
+// RUN: 2>&1 | FileCheck %s --check-prefix=PATHS_X86_64
|
||||
+// PATHS_X86_64: "-resource-dir" "[[RESOURCE:[^"]+]]"
|
||||
+// PATHS_X86_64: "-internal-isystem"
|
||||
+// PATHS_X86_64-SAME: {{^}} "[[SYSROOT:[^"]+]]/usr/include/x86_64-pc-serenity/c++/v1"
|
||||
+// PATHS_X86_64-SAME: {{^}} "-internal-isystem" "[[SYSROOT:[^"]+]]/usr/include/c++/v1"
|
||||
+// PATHS_X86_64-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]/include"
|
||||
+// PATHS_X86_64-SAME: {{^}} "-internal-isystem" "[[SYSROOT:[^"]+]]/usr/include"
|
||||
+// PATHS_X86_64: "-L
|
||||
+// PATHS_X86_64-SAME: {{^}}[[SYSROOT]]/usr/lib"
|
||||
+
|
||||
+/// Check default linker args for each supported triple
|
||||
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot= 2>&1 | FileCheck %s --check-prefix=SERENITY_X86_64
|
||||
+// SERENITY_X86_64: "-cc1" "-triple" "x86_64-pc-serenity"
|
||||
+// SERENITY_X86_64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld"
|
||||
+// SERENITY_X86_64: "-pie"
|
||||
+// SERENITY_X86_64: "-dynamic-linker" "/usr/lib/Loader.so" "--eh-frame-hdr"
|
||||
+// SERENITY_X86_64: "-o" "a.out"
|
||||
+// SERENITY_X86_64: "-z" "pack-relative-relocs"
|
||||
+// SERENITY_X86_64: "crt0.o" "crti.o" "crtbeginS.o"
|
||||
+// SERENITY_X86_64: "-lc" "crtendS.o" "crtn.o"
|
||||
+
|
||||
+// RUN: %clang -### %s --target=aarch64-pc-serenity --sysroot= 2>&1 | FileCheck %s --check-prefix=SERENITY_AARCH64
|
||||
+// SERENITY_AARCH64: "-cc1" "-triple" "aarch64-pc-serenity"
|
||||
+// SERENITY_AARCH64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld"
|
||||
+// SERENITY_AARCH64: "-pie"
|
||||
+// SERENITY_AARCH64: "-dynamic-linker" "/usr/lib/Loader.so" "--eh-frame-hdr"
|
||||
+// SERENITY_AARCH64: "-o" "a.out"
|
||||
+// SERENITY_AARCH64: "-z" "pack-relative-relocs"
|
||||
+// SERENITY_AARCH64: "crt0.o" "crti.o" "crtbeginS.o"
|
||||
+// SERENITY_AARCH64: "-lc" "crtendS.o" "crtn.o"
|
||||
+
|
||||
+// RUN: %clang -### %s --target=riscv64-pc-serenity --sysroot= 2>&1 | FileCheck %s --check-prefix=SERENITY_RISCV64
|
||||
+// SERENITY_RISCV64: "-cc1" "-triple" "riscv64-pc-serenity"
|
||||
+// SERENITY_RISCV64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld"
|
||||
+// SERENITY_RISCV64: "-pie"
|
||||
+// SERENITY_RISCV64: "-dynamic-linker" "/usr/lib/Loader.so" "--eh-frame-hdr"
|
||||
+// SERENITY_RISCV64: "-o" "a.out"
|
||||
+// SERENITY_RISCV64: "-z" "pack-relative-relocs"
|
||||
+// SERENITY_RISCV64: "crt0.o" "crti.o" "crtbeginS.o"
|
||||
+// SERENITY_RISCV64: "-lc" "crtendS.o" "crtn.o"
|
||||
+
|
||||
+/// -static-pie suppresses -dynamic-linker
|
||||
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot= \
|
||||
+// -static-pie 2>&1 | FileCheck %s --check-prefix=STATIC_PIE
|
||||
+// STATIC_PIE: "-pie" "-static"
|
||||
+// STATIC_PIE-NOT: "-dynamic-linker"
|
||||
+// STATIC_PIE: "--no-dynamic-linker" "-z" "text"
|
||||
+// STATIC_PIE: "--eh-frame-hdr" "-z" "pack-relative-relocs"
|
||||
+// STATIC_PIE: "crt0.o" "crti.o" "crtbeginS.o"
|
||||
+// STATIC_PIE: "-lc" "crtendS.o" "crtn.o"
|
||||
+
|
||||
+/// -shared forces use of shared crt files
|
||||
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot= \
|
||||
+// -shared 2>&1 | FileCheck %s --check-prefix=SHARED
|
||||
+// SHARED: "-shared"
|
||||
+// SHARED: "--eh-frame-hdr" "-z" "pack-relative-relocs"
|
||||
+// SHARED: "crt0_shared.o" "crti.o" "crtbeginS.o"
|
||||
+// SHARED: "-lc" "crtendS.o" "crtn.o"
|
||||
+
|
||||
+/// -static forces use of static crt files
|
||||
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot= \
|
||||
+// -static 2>&1 | FileCheck %s --check-prefix=STATIC
|
||||
+// STATIC: "-static"
|
||||
+// STATIC: "--eh-frame-hdr" "-z" "pack-relative-relocs"
|
||||
+// STATIC: "crt0.o" "crti.o" "crtbegin.o"
|
||||
+// STATIC: "-lc" "crtend.o" "crtn.o"
|
||||
+
|
||||
+/// -rdynamic passes -export-dynamic
|
||||
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot= \
|
||||
+// -rdynamic 2>&1 | FileCheck %s --check-prefix=RDYNAMIC
|
||||
+// RDYNAMIC: "-pie" "-export-dynamic"
|
||||
+// RDYNAMIC: "-dynamic-linker" "/usr/lib/Loader.so" "--eh-frame-hdr"
|
||||
+// RDYNAMIC: "-o" "a.out"
|
||||
+// RDYNAMIC: "-z" "pack-relative-relocs"
|
||||
+// RDYNAMIC: "crt0.o" "crti.o" "crtbeginS.o"
|
||||
+// RDYNAMIC: "-lc" "crtendS.o" "crtn.o"
|
||||
+
|
||||
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot= \
|
||||
+// -no-pie -rdynamic 2>&1 | FileCheck %s --check-prefix=RDYNAMIC_NOPIE
|
||||
+// RDYNAMIC_NOPIE-NOT: "-pie"
|
||||
+// RDYNAMIC_NOPIE: "-export-dynamic"
|
||||
+// RDYNAMIC_NOPIE: "-dynamic-linker" "/usr/lib/Loader.so" "--eh-frame-hdr"
|
||||
+// RDYNAMIC_NOPIE: "-o" "a.out"
|
||||
+// RDYNAMIC_NOPIE: "-z" "pack-relative-relocs"
|
||||
+// RDYNAMIC_NOPIE: "crt0.o" "crti.o" "crtbeginS.o"
|
||||
+// RDYNAMIC_NOPIE: "-lc" "crtendS.o" "crtn.o"
|
||||
+
|
||||
+/// -nostdlib suppresses default -l and crt*.o
|
||||
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot=%S/Inputs/serenity_x86_64_tree \
|
||||
+// RUN: -ccc-install-dir %S/Inputs/serenity_x86_64_tree/usr/local/bin -resource-dir=%S/Inputs/resource_dir \
|
||||
+// RUN: -nostdlib --rtlib=compiler-rt 2>&1 | FileCheck %s --check-prefix=NOSTDLIB
|
||||
+// NOSTDLIB: "-internal-isystem"
|
||||
+// NOSTDLIB-SAME: {{^}} "[[SYSROOT:[^"]+]]/usr/include/x86_64-pc-serenity/c++/v1"
|
||||
+// NOSTDLIB-NOT: crt{{[^./]+}}.o
|
||||
+// NOSTDLIB: "-L
|
||||
+// NOSTDLIB-SAME: {{^}}[[SYSROOT]]/usr/lib"
|
||||
+// NOSTDLIB-NOT: "-l
|
||||
+// NOSTDLIB-NOT: libclang_rt.builtins-x86_64.a
|
||||
+// NOSTDLIB-NOT: crt{{[^./]+}}.o
|
||||
+
|
||||
+// -nostartfiles suppresses crt*.o, but not default -l
|
||||
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot=%S/Inputs/serenity_x86_64_tree \
|
||||
+// RUN: -ccc-install-dir %S/Inputs/serenity_x86_64_tree/usr/local/bin -resource-dir=%S/Inputs/resource_dir \
|
||||
+// RUN: -nostartfiles --rtlib=compiler-rt 2>&1 | FileCheck %s --check-prefix=NOSTARTFILES
|
||||
+// NOSTARTFILES: "-internal-isystem"
|
||||
+// NOSTARTFILES-SAME: {{^}} "[[SYSROOT:[^"]+]]/usr/include/x86_64-pc-serenity/c++/v1"
|
||||
+// NOSTARTFILES-NOT: crt{{[^./]+}}.o
|
||||
+// NOSTARTFILES: "-L
|
||||
+// NOSTARTFILES-SAME: {{^}}[[SYSROOT]]/usr/lib"
|
||||
+// NOSTARTFILES: "[[RESOURCE:[^"]+]]/lib/serenity/libclang_rt.builtins-x86_64.a"
|
||||
+// NOSTARTFILES: "-lc"
|
||||
+// NOSTARTFILES-NOT: crt{{[^./]+}}.o
|
||||
+
|
||||
+/// -r suppresses -dynamic-linker, default -l, and crt*.o like -nostdlib.
|
||||
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot=%S/Inputs/serenity_x86_64_tree \
|
||||
+// RUN: -ccc-install-dir %S/Inputs/serenity_x86_64_tree/usr/local/bin -resource-dir=%S/Inputs/resource_dir \
|
||||
+// RUN: -r --rtlib=compiler-rt 2>&1 | FileCheck %s --check-prefix=RELOCATABLE
|
||||
+// RELOCATABLE-NOT: "-dynamic-linker"
|
||||
+// RELOCATABLE: "-internal-isystem"
|
||||
+// RELOCATABLE-SAME: {{^}} "[[SYSROOT:[^"]+]]/usr/include/x86_64-pc-serenity/c++/v1"
|
||||
+// RELOCATABLE-NOT: crt{{[^./]+}}.o
|
||||
+// RELOCATABLE: "-L
|
||||
+// RELOCATABLE-SAME: {{^}}[[SYSROOT]]/usr/lib"
|
||||
+// RELOCATABLE-NOT: "-l
|
||||
+// RELOCATABLE-NOT: crt{{[^./]+}}.o
|
||||
+// RELOCATABLE-NOT: libclang_rt.builtins-x86_64.a
|
||||
+
|
||||
+/// -nolibc suppresses -lc but not other default -l
|
||||
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot=%S/Inputs/serenity_x86_64_tree \
|
||||
+// RUN: -ccc-install-dir %S/Inputs/serenity_x86_64_tree/usr/local/bin -resource-dir=%S/Inputs/resource_dir \
|
||||
+// RUN: -nolibc --rtlib=compiler-rt 2>&1 | FileCheck %s --check-prefix=NOLIBC
|
||||
+// NOLIBC: "-internal-isystem"
|
||||
+// NOLIBC-SAME: {{^}} "[[SYSROOT:[^"]+]]/usr/include/x86_64-pc-serenity/c++/v1"
|
||||
+// NOLIBC: "[[SYSROOT:[^"]+]]/usr/lib/crt0.o" "[[SYSROOT:[^"]+]]/usr/lib/crti.o" "crtbeginS.o"
|
||||
+// NOLIBC: "-L
|
||||
+// NOLIBC-SAME: {{^}}[[SYSROOT]]/usr/lib"
|
||||
+// NOLIBC-NOT: "-lc"
|
||||
+// NOLIBC: "[[RESOURCE:[^"]+]]/lib/serenity/libclang_rt.builtins-x86_64.a"
|
||||
+// NOLIBC: "crtendS.o" "[[SYSROOT:[^"]+]]/usr/lib/crtn.o"
|
||||
+
|
||||
+/// -fsanitize=undefined redirects to Serenity-custom UBSAN runtime
|
||||
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot=%S/Inputs/serenity_x86_64_tree \
|
||||
+// RUN: -ccc-install-dir %S/Inputs/serenity_x86_64_tree/usr/local/bin -resource-dir=%S/Inputs/resource_dir \
|
||||
+// RUN: -fsanitize=undefined --rtlib=compiler-rt 2>&1 | FileCheck %s --check-prefix=UBSAN
|
||||
+// UBSAN-NOT: "libclang_rt.ubsan{{[^./]+}}.a"
|
||||
+// UBSAN-NOT: "libclang_rt.ubsan{{[^./]+}}.so"
|
||||
+// UBSAN: "-lubsan"
|
||||
+
|
||||
+/// C++ stdlib behavior
|
||||
+// RUN: %clangxx -### %s --target=x86_64-pc-serenity --sysroot="" \
|
||||
+// RUN: 2>&1 | FileCheck %s --check-prefix=DEFAULT_LIBCXX
|
||||
+// DEFAULT_LIBCXX: "-dynamic-linker" "/usr/lib/Loader.so" "--eh-frame-hdr"
|
||||
+// DEFAULT_LIBCXX: "-z" "pack-relative-relocs"
|
||||
+// DEFAULT_LIBCXX: "crt0.o" "crti.o" "crtbeginS.o"
|
||||
+// DEFAULT_LIBCXX: "--push-state"
|
||||
+// DEFAULT_LIBCXX: "--as-needed"
|
||||
+// DEFAULT_LIBCXX: "-lc++"
|
||||
+// DEFAULT_LIBCXX: "--pop-state"
|
||||
+// DEFAULT_LIBCXX: "-lc" "crtendS.o" "crtn.o"
|
||||
+
|
||||
+// RUN: %clangxx -### %s --target=x86_64-pc-serenity --sysroot="" \
|
||||
+// RUN: -static 2>&1 | FileCheck %s --check-prefix=STATIC_LIBCXX
|
||||
+// STATIC_LIBCXX: "-z" "pack-relative-relocs"
|
||||
+// STATIC_LIBCXX: "crt0.o" "crti.o" "crtbegin.o"
|
||||
+// STATIC_LIBCXX: "--push-state"
|
||||
+// STATIC_LIBCXX: "--as-needed"
|
||||
+// STATIC_LIBCXX: "-lc++"
|
||||
+// STATIC_LIBCXX: "--pop-state"
|
||||
+// STATIC_LIBCXX: "-lc" "crtend.o" "crtn.o"
|
||||
+
|
||||
+// RUN: %clangxx -### %s --target=x86_64-pc-serenity --sysroot="" \
|
||||
+// RUN: -static-libstdc++ 2>&1 | FileCheck %s --check-prefix=STATIC_LIBSTDCXX
|
||||
+// STATIC_LIBSTDCXX: "-z" "pack-relative-relocs"
|
||||
+// STATIC_LIBSTDCXX: "crt0.o" "crti.o" "crtbeginS.o"
|
||||
+// STATIC_LIBSTDCXX: "--push-state"
|
||||
+// STATIC_LIBSTDCXX: "--as-needed"
|
||||
+// STATIC_LIBSTDCXX: "-Bstatic"
|
||||
+// STATIC_LIBSTDCXX: "-lc++"
|
||||
+// STATIC_LIBSTDCXX: "-Bdynamic"
|
||||
+// STATIC_LIBSTDCXX: "--pop-state"
|
||||
+// STATIC_LIBSTDCXX: "-lc" "crtendS.o" "crtn.o"
|
||||
+
|
||||
+// RUN: %clangxx -### %s --target=x86_64-pc-serenity --sysroot="" \
|
||||
+// RUN: -nostdlib++ 2>&1 | FileCheck %s --check-prefix=NO_LIBCXX
|
||||
+// NO_LIBCXX: "-z" "pack-relative-relocs"
|
||||
+// NO_LIBCXX: "crt0.o" "crti.o" "crtbeginS.o"
|
||||
+// NO_LIBCXX-NOT: "--push-state"
|
||||
+// NO_LIBCXX-NOT: "--as-needed"
|
||||
+// NO_LIBCXX-NOT: "-lc++"
|
||||
+// NO_LIBCXX-NOT: "--pop-state"
|
||||
+// NO_LIBCXX: "-lc" "crtendS.o" "crtn.o"
|
||||
--
|
||||
2.44.0
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Date: Thu, 14 Apr 2022 09:54:22 +0200
|
||||
Subject: [PATCH] [llvm] Add support for building LLVM on SerenityOS
|
||||
|
||||
Adds SerenityOS `#ifdef`s for platform-specific code.
|
||||
|
||||
We stub out wait4, as SerenityOS doesn't support querying a child
|
||||
process's resource usage information.
|
||||
|
||||
POSIX shm is not supported by SerenityOS yet, so disable it in Orc.
|
||||
|
||||
Serenity gives each thread a default of 1MiB of stack. Increase the
|
||||
default stack size for llvm applications when running on SerenityOS.
|
||||
|
||||
Co-Authored-By: sin-ack <sin-ack@users.noreply.github.com>
|
||||
Co-Authored-By: Tim Schumacher <timschumi@gmx.de>
|
||||
---
|
||||
llvm/cmake/modules/HandleLLVMOptions.cmake | 3 +++
|
||||
llvm/include/llvm/ADT/bit.h | 2 +-
|
||||
llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp | 3 ++-
|
||||
.../TargetProcess/ExecutorSharedMemoryMapperService.cpp | 3 ++-
|
||||
llvm/lib/Support/Unix/Path.inc | 5 ++++-
|
||||
llvm/lib/Support/Unix/Program.inc | 9 ++++++++-
|
||||
6 files changed, 20 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
|
||||
index 0699a8586fcc..29d0d46fdcb4 100644
|
||||
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
|
||||
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
|
||||
@@ -503,6 +503,9 @@ elseif(MINGW OR CYGWIN)
|
||||
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
append("-Wa,-mbig-obj" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
||||
endif()
|
||||
+elseif(SERENITYOS)
|
||||
+ # SerenityOS sets a very low default stack size value, so increase it to 4MB manually.
|
||||
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,stack-size=4194304")
|
||||
endif()
|
||||
|
||||
option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
|
||||
diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
|
||||
index c42b5e686bdc..ad4ad534f40c 100644
|
||||
--- a/llvm/include/llvm/ADT/bit.h
|
||||
+++ b/llvm/include/llvm/ADT/bit.h
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \
|
||||
defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || \
|
||||
- defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
+ defined(__OpenBSD__) || defined(__DragonFly__) || defined(__serenity__)
|
||||
#include <endian.h>
|
||||
#elif defined(_AIX)
|
||||
#include <sys/machine.h>
|
||||
diff --git a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
|
||||
index 9cfe547c84c3..f43a317064f5 100644
|
||||
--- a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
|
||||
+++ b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
|
||||
@@ -215,7 +215,8 @@ SharedMemoryMapper::Create(ExecutorProcessControl &EPC, SymbolAddrs SAs) {
|
||||
|
||||
void SharedMemoryMapper::reserve(size_t NumBytes,
|
||||
OnReservedFunction OnReserved) {
|
||||
-#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
|
||||
+#if (defined(LLVM_ON_UNIX) && !(defined(__ANDROID__) || defined(__serenity__))) \
|
||||
+ || defined(_WIN32)
|
||||
|
||||
EPC.callSPSWrapperAsync<
|
||||
rt::SPSExecutorSharedMemoryMapperServiceReserveSignature>(
|
||||
diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
|
||||
index e8b0e240ac1f..fcc7bfe1c1cc 100644
|
||||
--- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
|
||||
+++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
|
||||
@@ -47,7 +47,8 @@ static DWORD getWindowsProtectionFlags(MemProt MP) {
|
||||
|
||||
Expected<std::pair<ExecutorAddr, std::string>>
|
||||
ExecutorSharedMemoryMapperService::reserve(uint64_t Size) {
|
||||
-#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
|
||||
+#if (defined(LLVM_ON_UNIX) && !(defined(__ANDROID__) || defined(__serenity__))) \
|
||||
+ || defined(_WIN32)
|
||||
|
||||
#if defined(LLVM_ON_UNIX)
|
||||
|
||||
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
|
||||
index 9f89d63bb0fd..5035b1b05f4d 100644
|
||||
--- a/llvm/lib/Support/Unix/Path.inc
|
||||
+++ b/llvm/lib/Support/Unix/Path.inc
|
||||
@@ -112,7 +112,7 @@ typedef uint_t uint;
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) || \
|
||||
- defined(__MVS__)
|
||||
+ defined(__MVS__) || defined(__serenity__)
|
||||
#define STATVFS_F_FLAG(vfs) (vfs).f_flag
|
||||
#else
|
||||
#define STATVFS_F_FLAG(vfs) (vfs).f_flags
|
||||
@@ -511,6 +511,9 @@ static bool is_local_impl(struct STATVFS &Vfs) {
|
||||
#elif defined(__HAIKU__)
|
||||
// Haiku doesn't expose this information.
|
||||
return false;
|
||||
+#elif defined(__serenity__)
|
||||
+ // Serenity doesn't yet support remote filesystem mounts.
|
||||
+ return false;
|
||||
#elif defined(__sun)
|
||||
// statvfs::f_basetype contains a null-terminated FSType name of the mounted
|
||||
// target
|
||||
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
|
||||
index 5d9757bcc51b..18295dc2229c 100644
|
||||
--- a/llvm/lib/Support/Unix/Program.inc
|
||||
+++ b/llvm/lib/Support/Unix/Program.inc
|
||||
@@ -342,7 +342,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
|
||||
namespace llvm {
|
||||
namespace sys {
|
||||
|
||||
-#if defined(_AIX)
|
||||
+#if defined(_AIX) || defined(__serenity__)
|
||||
static pid_t(wait4)(pid_t pid, int *status, int options, struct rusage *usage);
|
||||
#elif !defined(__Fuchsia__)
|
||||
using ::wait4;
|
||||
@@ -385,6 +385,13 @@ pid_t(llvm::sys::wait4)(pid_t pid, int *status, int options,
|
||||
}
|
||||
#endif
|
||||
|
||||
+#ifdef __serenity__
|
||||
+pid_t (llvm::sys::wait4)(pid_t pid, int *status, int options,
|
||||
+ struct rusage*) {
|
||||
+ return ::waitpid(pid, status, options);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
ProcessInfo llvm::sys::Wait(const ProcessInfo &PI,
|
||||
std::optional<unsigned> SecondsToWait,
|
||||
std::string *ErrMsg,
|
||||
--
|
||||
2.44.0
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Date: Mon, 18 Apr 2022 22:32:29 +0200
|
||||
Subject: [PATCH] [tools] Support building shared libLLVM and libClang for
|
||||
SerenityOS
|
||||
|
||||
This patch tells CMake that the --whole-archive linker option should be
|
||||
used for specifying the archives whose members will constitute these
|
||||
shared libraries.
|
||||
|
||||
Symbol versioning is disabled, as the SerenityOS loader doesn't support
|
||||
it, and the ELF sections that store version data would just waste space.
|
||||
---
|
||||
llvm/cmake/modules/HandleLLVMOptions.cmake | 2 +-
|
||||
llvm/tools/llvm-shlib/CMakeLists.txt | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
|
||||
index 29d0d46fdcb4..df8d63902dfd 100644
|
||||
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
|
||||
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
|
||||
@@ -181,7 +181,7 @@ if(WIN32)
|
||||
elseif(FUCHSIA OR UNIX)
|
||||
set(LLVM_ON_WIN32 0)
|
||||
set(LLVM_ON_UNIX 1)
|
||||
- if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
|
||||
+ if(APPLE OR SERENITYOS OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
|
||||
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
|
||||
else()
|
||||
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
|
||||
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt
|
||||
index b20ac318e768..d3df0de2f694 100644
|
||||
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
|
||||
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
|
||||
@@ -51,7 +51,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
|
||||
|
||||
# GNU ld doesn't resolve symbols in the version script.
|
||||
set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
|
||||
- if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW)
|
||||
+ if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW AND NOT SERENITYOS)
|
||||
# Solaris ld does not accept global: *; so there is no way to version *all* global symbols
|
||||
set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES})
|
||||
endif()
|
||||
--
|
||||
2.44.0
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Kaster <akaster@serenityos.org>
|
||||
Date: Fri, 4 Mar 2022 15:13:42 -0700
|
||||
Subject: [PATCH] [compiler-rt] Enable profile instrumentation for SerenityOS
|
||||
|
||||
Treat SerenityOS the same as other *NIX platforms that behave close
|
||||
enough to linux to use the pre-canned InstrProfiling implementation.
|
||||
---
|
||||
clang/lib/Driver/ToolChains/Serenity.cpp | 3 +++
|
||||
clang/test/Driver/instrprof-ld.c | 20 +++++++++++++++++++
|
||||
compiler-rt/cmake/config-ix.cmake | 2 +-
|
||||
.../lib/profile/InstrProfilingPlatformLinux.c | 2 +-
|
||||
.../lib/profile/InstrProfilingPlatformOther.c | 3 ++-
|
||||
5 files changed, 27 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/clang/lib/Driver/ToolChains/Serenity.cpp b/clang/lib/Driver/ToolChains/Serenity.cpp
|
||||
index 2167758100bc..c132e5c41185 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Serenity.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Serenity.cpp
|
||||
@@ -183,6 +183,9 @@ void tools::serenity::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtn.o")));
|
||||
}
|
||||
|
||||
+ if (ShouldLinkCompilerRuntime)
|
||||
+ TC.addProfileRTLibs(Args, CmdArgs);
|
||||
+
|
||||
const char *Exec = Args.MakeArgString(TC.GetLinkerPath());
|
||||
C.addCommand(std::make_unique<Command>(JA, *this,
|
||||
ResponseFileSupport::AtFileCurCP(),
|
||||
diff --git a/clang/test/Driver/instrprof-ld.c b/clang/test/Driver/instrprof-ld.c
|
||||
index 9a58cd3a0be7..d37de48b9d83 100644
|
||||
--- a/clang/test/Driver/instrprof-ld.c
|
||||
+++ b/clang/test/Driver/instrprof-ld.c
|
||||
@@ -54,6 +54,15 @@
|
||||
// CHECK-OPENBSD-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
|
||||
// CHECK-OPENBSD-X86-64: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}openbsd{{/|\\\\}}libclang_rt.profile-x86_64.a"
|
||||
|
||||
+// RUN: %clang -### %s 2>&1 \
|
||||
+// RUN: --target=x86_64-pc-serenity -fprofile-instr-generate -fuse-ld=ld \
|
||||
+// RUN: -resource-dir=%S/Inputs/resource_dir \
|
||||
+// RUN: --sysroot=%S/Inputs/serenity_x86_64_tree \
|
||||
+// RUN: | FileCheck --check-prefix=CHECK-SERENITY-X86-64 %s
|
||||
+
|
||||
+// CHECK-SERENITY-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld{{(.exe)?}}"
|
||||
+// CHECK-SERENITY-X86-64: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}serenity{{/|\\\\}}libclang_rt.profile-x86_64.a"
|
||||
+
|
||||
// RUN: %clang -### %s 2>&1 \
|
||||
// RUN: -shared \
|
||||
// RUN: --target=i386-unknown-linux -fprofile-instr-generate -fuse-ld=ld \
|
||||
@@ -104,6 +113,17 @@
|
||||
// CHECK-OPENBSD-X86-64-SHARED: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
|
||||
// CHECK-OPENBSD-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}openbsd{{/|\\\\}}libclang_rt.profile-x86_64.a"
|
||||
|
||||
+// RUN: %clang -### %s 2>&1 \
|
||||
+// RUN: -shared \
|
||||
+// RUN: --target=x86_64-pc-serenity -fprofile-instr-generate -fuse-ld=ld \
|
||||
+// RUN: -resource-dir=%S/Inputs/resource_dir \
|
||||
+// RUN: --sysroot=%S/Inputs/serenity_x86_64_tree \
|
||||
+// RUN: | FileCheck --check-prefix=CHECK-SERENITY-X86-64-SHARED %s
|
||||
+
|
||||
+// CHECK-SERENITY-X86-64-SHARED: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld{{(.exe)?}}"
|
||||
+// CHECK-SERENITY-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}serenity{{/|\\\\}}libclang_rt.profile-x86_64.a"
|
||||
+
|
||||
+
|
||||
// RUN: %clang -### %s 2>&1 \
|
||||
// RUN: --target=x86_64-apple-darwin14 -fprofile-instr-generate -fuse-ld=ld \
|
||||
// RUN: -resource-dir=%S/Inputs/resource_dir \
|
||||
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
|
||||
index 2ca18ebb4ad4..e9e00e6fec5c 100644
|
||||
--- a/compiler-rt/cmake/config-ix.cmake
|
||||
+++ b/compiler-rt/cmake/config-ix.cmake
|
||||
@@ -795,7 +795,7 @@ else()
|
||||
endif()
|
||||
|
||||
if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
|
||||
- OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
|
||||
+ OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|SerenityOS")
|
||||
set(COMPILER_RT_HAS_PROFILE TRUE)
|
||||
else()
|
||||
set(COMPILER_RT_HAS_PROFILE FALSE)
|
||||
diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
|
||||
index 19266ab6c6fb..ee7200730f86 100644
|
||||
--- a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
|
||||
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
|
||||
(defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__) || \
|
||||
- defined(_AIX)
|
||||
+ defined(_AIX) || defined(__serenity__)
|
||||
|
||||
#if !defined(_AIX)
|
||||
#include <elf.h>
|
||||
diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
|
||||
index 5319ca813b43..40ff14b75e7c 100644
|
||||
--- a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
|
||||
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__FreeBSD__) && \
|
||||
!defined(__Fuchsia__) && !(defined(__sun__) && defined(__svr4__)) && \
|
||||
- !defined(__NetBSD__) && !defined(_WIN32) && !defined(_AIX)
|
||||
+ !defined(__NetBSD__) && !defined(_WIN32) && !defined(_AIX) && \
|
||||
+ !defined(__serenity__)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
--
|
||||
2.44.0
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Date: Thu, 14 Apr 2022 10:17:13 +0200
|
||||
Subject: [PATCH] [libcxx] Add support for SerenityOS
|
||||
|
||||
This commit teaches libc++ about what features are available in our
|
||||
LibC, namely:
|
||||
* We do not have locale support, so no-op shims should be used in place
|
||||
of the C locale API.
|
||||
* The number of errno constants defined by us is given by the value of
|
||||
the `ELAST` macro.
|
||||
* Multithreading is implemented though the pthread library.
|
||||
* Use libc++'s builtin character type table instead of the one provided
|
||||
by LibC as there's a lot of extra porting work to convince the rest of
|
||||
locale.cpp to use our character type table properly.
|
||||
---
|
||||
libcxx/include/CMakeLists.txt | 1 +
|
||||
libcxx/include/__config | 5 +++--
|
||||
libcxx/include/__locale | 2 ++
|
||||
libcxx/include/__support/serenity/xlocale.h | 24 +++++++++++++++++++++
|
||||
libcxx/include/locale | 2 +-
|
||||
libcxx/src/include/config_elast.h | 2 ++
|
||||
6 files changed, 33 insertions(+), 3 deletions(-)
|
||||
create mode 100644 libcxx/include/__support/serenity/xlocale.h
|
||||
|
||||
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
|
||||
index ed721d467e94..5641e32b1343 100644
|
||||
--- a/libcxx/include/CMakeLists.txt
|
||||
+++ b/libcxx/include/CMakeLists.txt
|
||||
@@ -675,6 +675,7 @@ set(files
|
||||
__support/musl/xlocale.h
|
||||
__support/newlib/xlocale.h
|
||||
__support/openbsd/xlocale.h
|
||||
+ __support/serenity/xlocale.h
|
||||
__support/win32/locale_win32.h
|
||||
__support/xlocale/__nop_locale_mgmt.h
|
||||
__support/xlocale/__posix_l_fallback.h
|
||||
diff --git a/libcxx/include/__config b/libcxx/include/__config
|
||||
index 8b2eaf69d170..53a09f46eaf7 100644
|
||||
--- a/libcxx/include/__config
|
||||
+++ b/libcxx/include/__config
|
||||
@@ -1103,7 +1103,8 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
|
||||
defined(__APPLE__) || \
|
||||
defined(__MVS__) || \
|
||||
defined(_AIX) || \
|
||||
- defined(__EMSCRIPTEN__)
|
||||
+ defined(__EMSCRIPTEN__) || \
|
||||
+ defined(__serenity__)
|
||||
// clang-format on
|
||||
# define _LIBCPP_HAS_THREAD_API_PTHREAD
|
||||
# elif defined(__Fuchsia__)
|
||||
@@ -1176,7 +1177,7 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
|
||||
# endif
|
||||
|
||||
# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \
|
||||
- defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
|
||||
+ defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) || defined(__serenity__)
|
||||
# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
|
||||
# endif
|
||||
|
||||
diff --git a/libcxx/include/__locale b/libcxx/include/__locale
|
||||
index 3ba7ac18b0b3..9a68dade7fef 100644
|
||||
--- a/libcxx/include/__locale
|
||||
+++ b/libcxx/include/__locale
|
||||
@@ -51,6 +51,8 @@
|
||||
# include <__support/musl/xlocale.h>
|
||||
#elif defined(_LIBCPP_HAS_MUSL_LIBC)
|
||||
# include <__support/musl/xlocale.h>
|
||||
+#elif defined(__serenity__)
|
||||
+# include <__support/serenity/xlocale.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
diff --git a/libcxx/include/__support/serenity/xlocale.h b/libcxx/include/__support/serenity/xlocale.h
|
||||
new file mode 100644
|
||||
index 000000000000..67c85bf641e2
|
||||
--- /dev/null
|
||||
+++ b/libcxx/include/__support/serenity/xlocale.h
|
||||
@@ -0,0 +1,24 @@
|
||||
+//===----------------------------------------------------------------------===//
|
||||
+//
|
||||
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
+// See https://llvm.org/LICENSE.txt for license information.
|
||||
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
+//
|
||||
+//===----------------------------------------------------------------------===//
|
||||
+
|
||||
+#ifndef _LIBCPP_SUPPORT_SERENITY_XLOCALE_H
|
||||
+#define _LIBCPP_SUPPORT_SERENITY_XLOCALE_H
|
||||
+
|
||||
+#if defined(__serenity__)
|
||||
+
|
||||
+# include <__support/xlocale/__nop_locale_mgmt.h>
|
||||
+# include <__support/xlocale/__posix_l_fallback.h>
|
||||
+# include <__support/xlocale/__strtonum_fallback.h>
|
||||
+# include <clocale>
|
||||
+# include <cstdlib>
|
||||
+# include <ctype.h>
|
||||
+# include <cwctype>
|
||||
+
|
||||
+#endif // __serenity__
|
||||
+
|
||||
+#endif
|
||||
diff --git a/libcxx/include/locale b/libcxx/include/locale
|
||||
index 9e97eb9f3395..4bcdc13c1967 100644
|
||||
--- a/libcxx/include/locale
|
||||
+++ b/libcxx/include/locale
|
||||
@@ -217,7 +217,7 @@ template <class charT> class messages_byname;
|
||||
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
// Most unix variants have catopen. These are the specific ones that don't.
|
||||
-# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)
|
||||
+# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) && !defined(__serenity__)
|
||||
# define _LIBCPP_HAS_CATOPEN 1
|
||||
# include <nl_types.h>
|
||||
# endif
|
||||
diff --git a/libcxx/src/include/config_elast.h b/libcxx/src/include/config_elast.h
|
||||
index 899e124ad261..11d930bc8a3c 100644
|
||||
--- a/libcxx/src/include/config_elast.h
|
||||
+++ b/libcxx/src/include/config_elast.h
|
||||
@@ -35,6 +35,8 @@
|
||||
# define _LIBCPP_ELAST 4095
|
||||
#elif defined(__APPLE__)
|
||||
// No _LIBCPP_ELAST needed on Apple
|
||||
+#elif defined(__serenity__)
|
||||
+// No _LIBCPP_ELAST needed on SerenityOS
|
||||
#elif defined(__MVS__)
|
||||
# define _LIBCPP_ELAST 1160
|
||||
#elif defined(_LIBCPP_MSVCRT_LIKE)
|
||||
--
|
||||
2.44.0
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Date: Fri, 8 Sep 2023 00:42:17 +0200
|
||||
Subject: [PATCH] [clang] Add -fvisibility-inlines-hidden-function-templates
|
||||
|
||||
---
|
||||
clang/include/clang/Basic/LangOptions.def | 3 +++
|
||||
clang/include/clang/Driver/Options.td | 6 ++++++
|
||||
clang/lib/AST/Decl.cpp | 18 ++++++++++++------
|
||||
clang/lib/Driver/ToolChains/Clang.cpp | 2 ++
|
||||
4 files changed, 23 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
|
||||
index 4942dcaa086e..677ad6273e3a 100644
|
||||
--- a/clang/include/clang/Basic/LangOptions.def
|
||||
+++ b/clang/include/clang/Basic/LangOptions.def
|
||||
@@ -310,6 +310,9 @@ BENIGN_LANGOPT(IgnoreXCOFFVisibility, 1, 0, "All the visibility attributes that
|
||||
BENIGN_LANGOPT(VisibilityInlinesHiddenStaticLocalVar, 1, 0,
|
||||
"hidden visibility for static local variables in inline C++ "
|
||||
"methods when -fvisibility-inlines hidden is enabled")
|
||||
+BENIGN_LANGOPT(VisibilityInlinesHiddenFunctionTemplate, 1, 0,
|
||||
+ "hidden visibility for implicitly instantiated C++ function "
|
||||
+ "templates when -fvisibility-inlines-hidden is enabled")
|
||||
ENUM_LANGOPT(GlobalAllocationFunctionVisibility, VisibilityForcedKinds, 3, VisibilityForcedKinds::ForceDefault,
|
||||
"How to apply visibility to global operator new and delete declarations")
|
||||
LANGOPT(NewInfallible , 1, 0, "Treats throwing global C++ operator new as always returning valid memory (annotates with __attribute__((returns_nonnull)) and throw()). This is detectable in source.")
|
||||
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
|
||||
index 175bedbfb4d0..7cc661956e3a 100644
|
||||
--- a/clang/include/clang/Driver/Options.td
|
||||
+++ b/clang/include/clang/Driver/Options.td
|
||||
@@ -3918,6 +3918,12 @@ defm visibility_inlines_hidden_static_local_var : BoolFOption<"visibility-inline
|
||||
NegFlag<SetFalse, [], [ClangOption], "Disables -fvisibility-inlines-hidden-static-local-var"
|
||||
" (this is the default on non-darwin targets)">, BothFlags<
|
||||
[], [ClangOption, CC1Option]>>;
|
||||
+defm visibility_inlines_hidden_function_template : BoolFOption<"visibility-inlines-hidden-function-template",
|
||||
+ LangOpts<"VisibilityInlinesHiddenFunctionTemplate">, DefaultFalse,
|
||||
+ PosFlag<SetTrue, [], [ClangOption, CC1Option],
|
||||
+ "When -fvisibility-inlines-hidden is enabled, all template functions will be given"
|
||||
+ " hidden visibility by default, even if they are not declared ``inline``">,
|
||||
+ NegFlag<SetFalse>>;
|
||||
def fvisibility_ms_compat : Flag<["-"], "fvisibility-ms-compat">, Group<f_Group>,
|
||||
HelpText<"Give global types 'default' visibility and global functions and "
|
||||
"variables 'hidden' visibility by default">;
|
||||
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
|
||||
index 1ee33fd7576d..b8cb7e5a494b 100644
|
||||
--- a/clang/lib/AST/Decl.cpp
|
||||
+++ b/clang/lib/AST/Decl.cpp
|
||||
@@ -562,13 +562,19 @@ static bool useInlineVisibilityHidden(const NamedDecl *D) {
|
||||
TSK = MSI->getTemplateSpecializationKind();
|
||||
}
|
||||
|
||||
+ if (TSK == TSK_ExplicitInstantiationDeclaration ||
|
||||
+ TSK == TSK_ExplicitInstantiationDefinition)
|
||||
+ return false;
|
||||
+
|
||||
const FunctionDecl *Def = nullptr;
|
||||
- // InlineVisibilityHidden only applies to definitions, and
|
||||
- // isInlined() only gives meaningful answers on definitions
|
||||
- // anyway.
|
||||
- return TSK != TSK_ExplicitInstantiationDeclaration &&
|
||||
- TSK != TSK_ExplicitInstantiationDefinition &&
|
||||
- FD->hasBody(Def) && Def->isInlined() && !Def->hasAttr<GNUInlineAttr>();
|
||||
+ if (!FD->hasBody(Def))
|
||||
+ return false;
|
||||
+
|
||||
+ if (Def->hasAttr<GNUInlineAttr>())
|
||||
+ return false;
|
||||
+
|
||||
+ return Def->isInlined() || (TSK == TSK_ImplicitInstantiation &&
|
||||
+ Opts.VisibilityInlinesHiddenFunctionTemplate);
|
||||
}
|
||||
|
||||
template <typename T> static bool isFirstInExternCContext(T *D) {
|
||||
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
index aa344b3465ab..a9e2a4012fd1 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
@@ -6350,6 +6350,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
|
||||
Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden_static_local_var,
|
||||
options::OPT_fno_visibility_inlines_hidden_static_local_var);
|
||||
+ Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden_function_template,
|
||||
+ options::OPT_fno_visibility_inlines_hidden_function_template);
|
||||
|
||||
// -fvisibility-global-new-delete-hidden is a deprecated spelling of
|
||||
// -fvisibility-global-new-delete=force-hidden.
|
||||
--
|
||||
2.44.0
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
# Patches for llvm on SerenityOS
|
||||
|
||||
## `0001-clang-Add-support-for-SerenityOS.patch`
|
||||
|
||||
Add support for SerenityOS
|
||||
|
||||
Adds support for the `$arch-pc-serenity` target to the Clang front end.
|
||||
This makes the compiler look for libraries and headers in the right
|
||||
places, and enables some security mitigations like stack-smashing
|
||||
protection and position-independent code by default.
|
||||
|
||||
## `0002-llvm-Add-support-for-building-LLVM-on-SerenityOS.patch`
|
||||
|
||||
Add support for building LLVM on SerenityOS
|
||||
|
||||
Adds SerenityOS `#ifdef`s for platform-specific code.
|
||||
|
||||
We stub out wait4, as SerenityOS doesn't support querying a child
|
||||
process's resource usage information.
|
||||
|
||||
POSIX shm is not supported by SerenityOS yet, so disable it in Orc.
|
||||
|
||||
Serenity gives each thread a default of 1MiB of stack. Increase the
|
||||
default stack size for llvm applications when running on SerenityOS.
|
||||
|
||||
## `0003-tools-Support-building-shared-libLLVM-and-libClang-f.patch`
|
||||
|
||||
Support building shared libLLVM and libClang for SerenityOS
|
||||
|
||||
This patch tells CMake that the --whole-archive linker option should be
|
||||
used for specifying the archives whose members will constitute these
|
||||
shared libraries.
|
||||
|
||||
Symbol versioning is disabled, as the SerenityOS loader doesn't support
|
||||
it, and the ELF sections that store version data would just waste space.
|
||||
|
||||
## `0004-compiler-rt-Enable-profile-instrumentation-for-Seren.patch`
|
||||
|
||||
Enable profile instrumentation for SerenityOS
|
||||
|
||||
Treat SerenityOS the same as other *NIX platforms that behave close
|
||||
enough to linux to use the pre-canned InstrProfiling implementation.
|
||||
|
||||
## `0005-libcxx-Add-support-for-SerenityOS.patch`
|
||||
|
||||
Add support for SerenityOS
|
||||
|
||||
This commit teaches libc++ about what features are available in our
|
||||
LibC, namely:
|
||||
* We do not have locale support, so no-op shims should be used in place
|
||||
of the C locale API.
|
||||
* The number of errno constants defined by us is given by the value of
|
||||
the `ELAST` macro.
|
||||
* Multithreading is implemented though the pthread library.
|
||||
* Use libc++'s builtin character type table instead of the one provided
|
||||
by LibC as there's a lot of extra porting work to convince the rest of
|
||||
locale.cpp to use our character type table properly.
|
||||
|
||||
## `0006-clang-Add-fvisibility-inlines-hidden-function-templa.patch`
|
||||
|
||||
Add -fvisibility-inlines-hidden-function-templates
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# Serenity Toolchain
|
||||
|
||||
This directory contains all toolchain related files. E.g. build scripts for
|
||||
the cross compilation toolchain and build toolchain for ports.
|
||||
|
||||
This document previously contained outdated build instructions. [Click here for the latest build instructions.](https://github.com/SerenityOS/serenity/blob/master/Documentation/BuildInstructions.md)
|
||||
@@ -1,35 +0,0 @@
|
||||
# Library stubs
|
||||
|
||||
This directory contains stubs for SerenityOS's LibC that are referenced from the LLVM runtime
|
||||
libraries. These are needed by the linker in order to add the required `DT_NEEDED` entries and to
|
||||
not emit errors regarding undefined libc symbols. Additionally, it provides fake empty libunwind.so
|
||||
and libc++.so for CMake configuration checks to succeed when bootstrapping the OS.
|
||||
|
||||
## Do these need to be updated?
|
||||
|
||||
Most likely no but it depends. Either way, if you are reading this, you are probably qualified
|
||||
enough to figure out if a failing LLVM toolchain configuration or build is caused by an out-of-date
|
||||
LibC stub.
|
||||
|
||||
## How to generate LibC stub?
|
||||
|
||||
First, you need to compile the LLVM toolchain and the SerenityOS's LibC. This will be a bit awkward
|
||||
(see discussion at https://github.com/SerenityOS/serenity/pull/23960) until (unless) we solve the
|
||||
dependency cycle between LibC and libunwind. Then, using the `llvm-ifs` tool,
|
||||
`Userland/Libraries/LibC/libc.so` can be converted into a stripped-down stub form. To do that, run
|
||||
the following command:
|
||||
|
||||
```sh
|
||||
Toolchain/Local/clang/bin/llvm-ifs --output-elf=<path-to-stub> <path-to-original>
|
||||
```
|
||||
|
||||
## How to generate `empty.so`?
|
||||
|
||||
Simple, my friend:
|
||||
|
||||
```sh
|
||||
touch empty.cpp
|
||||
Toolchain/Local/clang/bin/clang++ --target={arch}-pc-serenity -nostdlib -shared empty.cpp -o empty.so
|
||||
# And optionally,
|
||||
Toolchain/Local/clang/bin/llvm-strip empty.so
|
||||
```
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
empty.so
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
empty.so
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
empty.so
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
empty.so
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
empty.so
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
empty.so
|
||||
@@ -1,31 +0,0 @@
|
||||
{ pkgs ? import <nixpkgs> { } }: with pkgs;
|
||||
|
||||
mkShell.override { stdenv = gcc13Stdenv; } {
|
||||
packages = [
|
||||
ccache
|
||||
cmake
|
||||
curl
|
||||
e2fsprogs
|
||||
fuse2fs
|
||||
gcc13
|
||||
gmp
|
||||
# To create port launcher icons
|
||||
imagemagick
|
||||
libmpc
|
||||
mpfr
|
||||
ninja
|
||||
patch
|
||||
pkg-config
|
||||
rsync
|
||||
texinfo
|
||||
unzip
|
||||
# To build the GRUB disk image
|
||||
grub2
|
||||
libxcrypt
|
||||
openssl
|
||||
parted
|
||||
qemu
|
||||
python3
|
||||
];
|
||||
hardeningDisable = [ "format" ];
|
||||
}
|
||||
Reference in New Issue
Block a user