summaryrefslogtreecommitdiff
path: root/Ports
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-09-24 22:15:38 +0200
committerLinus Groh <mail@linusgroh.de>2021-10-17 17:09:58 +0100
commitdabd8dbedd70ed7f50de99b719403f1867a4bab2 (patch)
tree08aa701354b25b64ade42de416b7a6c1de594406 /Ports
parent928665d3bcba31c9a671cdc506f09b14a8a0a52c (diff)
downloadserenity-dabd8dbedd70ed7f50de99b719403f1867a4bab2.zip
Ports: Make it possible to build (some) ports with Clang
This commit introduces the changes needed in the port build system that will allow us to compile ports with Clang. Note that many ports still don't build, especially due to linker differences. Fixing these is outside the scope of this PR. For now, building bash, ncurses and nano is known to work. Bash runs fine, while nano crashes due to DT_VERSYM not being supported by our dynamic loader.
Diffstat (limited to 'Ports')
-rw-r--r--Ports/.hosted_defs.sh24
-rwxr-xr-xPorts/.port_include.sh1
2 files changed, 19 insertions, 6 deletions
diff --git a/Ports/.hosted_defs.sh b/Ports/.hosted_defs.sh
index f7c3c4d8c0..c430da4012 100644
--- a/Ports/.hosted_defs.sh
+++ b/Ports/.hosted_defs.sh
@@ -1,11 +1,23 @@
#!/usr/bin/env bash
+
export SERENITY_SOURCE_DIR="$(realpath "${SCRIPT}/../")"
-export SERENITY_BUILD_DIR="${SERENITY_SOURCE_DIR}/Build/${SERENITY_ARCH}"
-export CC="${SERENITY_ARCH}-pc-serenity-gcc"
-export CXX="${SERENITY_ARCH}-pc-serenity-g++"
-export AR="${SERENITY_ARCH}-pc-serenity-ar"
-export RANLIB="${SERENITY_ARCH}-pc-serenity-ranlib"
-export PATH="${SERENITY_SOURCE_DIR}/Toolchain/Local/${SERENITY_ARCH}/bin:${HOST_PATH}"
+
+if [ "$SERENITY_TOOLCHAIN" = "Clang" ]; then
+ export SERENITY_BUILD_DIR="${SERENITY_SOURCE_DIR}/Build/${SERENITY_ARCH}clang"
+ export CC="clang --target=${SERENITY_ARCH}-pc-serenity --sysroot=${SERENITY_BUILD_DIR}/Root"
+ export CXX="clang++ --target=${SERENITY_ARCH}-pc-serenity --sysroot=${SERENITY_BUILD_DIR}/Root"
+ export AR="llvm-ar"
+ export RANLIB="llvm-ranlib"
+ export PATH="${SERENITY_SOURCE_DIR}/Toolchain/Local/clang/bin:${HOST_PATH}"
+else
+ export SERENITY_BUILD_DIR="${SERENITY_SOURCE_DIR}/Build/${SERENITY_ARCH}"
+ export CC="${SERENITY_ARCH}-pc-serenity-gcc"
+ export CXX="${SERENITY_ARCH}-pc-serenity-g++"
+ export AR="${SERENITY_ARCH}-pc-serenity-ar"
+ export RANLIB="${SERENITY_ARCH}-pc-serenity-ranlib"
+ export PATH="${SERENITY_SOURCE_DIR}/Toolchain/Local/${SERENITY_ARCH}/bin:${HOST_PATH}"
+fi
+
export PKG_CONFIG_DIR=""
export PKG_CONFIG_SYSROOT_DIR="${SERENITY_BUILD_DIR}/Root"
export PKG_CONFIG_LIBDIR="${PKG_CONFIG_SYSROOT_DIR}/usr/lib/pkgconfig/:${PKG_CONFIG_SYSROOT_DIR}/usr/local/lib/pkgconfig"
diff --git a/Ports/.port_include.sh b/Ports/.port_include.sh
index d2fe8cc4ff..acfab9ec14 100755
--- a/Ports/.port_include.sh
+++ b/Ports/.port_include.sh
@@ -3,6 +3,7 @@ set -eu
SCRIPT="$(dirname "${0}")"
export SERENITY_ARCH="${SERENITY_ARCH:-i686}"
+export SERENITY_TOOLCHAIN="${SERENITY_TOOLCHAIN:-GCC}"
if [ -z "${HOST_CC:=}" ]; then
export HOST_CC="${CC:=cc}"