3rdparty/cross-compiler: Various fixes and multi-host arch support

Change-Id: I57e8a0be75950c767d115131b838006036d4bc0e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8796
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Alexander von Gluck 2024-12-28 14:14:08 +00:00
parent 8ecc31ca7b
commit b2474d284f
2 changed files with 23 additions and 9 deletions

View File

@ -1,7 +1,7 @@
FROM debian:bookworm-slim FROM debian:bookworm-slim
# docker build --no-cache --tag docker.io/haiku/cross-compiler:x86_64 . # docker build --no-cache --tag ghcr.io/haiku/cross-compiler:x86_64 .
# docker push docker.io/haiku/cross-compiler:x86_64 # docker push ghcr.io/haiku/cross-compiler:x86_64
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \ autoconf \
@ -14,7 +14,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
file \ file \
flex \ flex \
g++ \ g++ \
g++-multilib \
gawk \ gawk \
git \ git \
libcurl4-openssl-dev \ libcurl4-openssl-dev \
@ -28,7 +27,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
vim \ vim \
wget \ wget \
xz-utils \ xz-utils \
zlib1g-dev zlib1g-dev; \
if [ $(uname -m) = "x86_64" ]; then apt-get install -y g++-multilib; fi
# source revision to build # source revision to build
ARG BUILDTOOLS_REV=master ARG BUILDTOOLS_REV=master

View File

@ -32,10 +32,15 @@ git clone --depth=1 --branch $BUILDTOOLS_REV https://review.haiku-os.org/buildto
# The Haiku build requires the ability to find a hrev tag. In case a specific branch is selected # The Haiku build requires the ability to find a hrev tag. In case a specific branch is selected
# (like `r1beta4`)`, we will get the entire history just to be sure that the tag will exist. # (like `r1beta4`)`, we will get the entire history just to be sure that the tag will exist.
cd haiku cd haiku
if ! `git describe --dirty --tags --match=hrev* --abbrev=1`; then if [ ! "$(git describe --dirty --tags --match=hrev* --abbrev=1)" ]; then
git fetch --unshallow git fetch --unshallow
fi fi
# Scale up cores to speed up, but don't go crazy since Jam starts
# to lose its mind at 8+
NCPU=$(nproc)
if [ $NCPU -gt 8 ]; then NCPU=8; fi
# Build a cross-compiler # Build a cross-compiler
cd $BUILDTOOLS/jam cd $BUILDTOOLS/jam
make && ./jam0 install make && ./jam0 install
@ -57,14 +62,23 @@ if [ -n "$SECONDARY_ARCH" ]; then
fi fi
# Build needed packages and tools for the cross-compiler # Build needed packages and tools for the cross-compiler
jam -q haiku.hpkg haiku_devel.hpkg '<build>package' jam -j$NCPU -q haiku.hpkg haiku_devel.hpkg '<build>package'
if [ -n "$SECONDARY_ARCH" ]; then if [ -n "$SECONDARY_ARCH" ]; then
jam -q haiku_${SECONDARY_ARCH}.hpkg haiku_${SECONDARY_ARCH}_devel.hpkg jam -j$NCPU -q haiku_${SECONDARY_ARCH}.hpkg haiku_${SECONDARY_ARCH}_devel.hpkg
fi fi
# Set up our sysroot # Set up our sysroot
cp $OUTPUT/objects/linux/lib/*.so /lib/x86_64-linux-gnu HOST_ARCH=$(uname -m)
cp $OUTPUT/objects/linux/x86_64/release/tools/package/package /bin/ case $HOST_ARCH in
aarch64)
HOST_ARCH=arm64
;;
*)
;;
esac
cp $OUTPUT/objects/linux/lib/*.so /lib/$(uname -m)-linux-gnu
cp $OUTPUT/objects/linux/$HOST_ARCH/release/tools/package/package /bin/
for file in $SYSROOT/../bin/*; do for file in $SYSROOT/../bin/*; do
ln -s $file /bin/$(basename $file) ln -s $file /bin/$(basename $file)
done done