diff --git a/3rdparty/docker/cross-compiler/Dockerfile b/3rdparty/docker/cross-compiler/Dockerfile index 5cff79248e..268ce04a3a 100644 --- a/3rdparty/docker/cross-compiler/Dockerfile +++ b/3rdparty/docker/cross-compiler/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:buster-slim +FROM debian:bullseye-slim # docker build --no-cache --tag docker.io/haiku/cross-compiler:x86_64 . # docker push docker.io/haiku/cross-compiler:x86_64 @@ -14,20 +14,25 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ file \ flex \ g++ \ + g++-multilib \ gawk \ git \ libcurl4-openssl-dev \ libssl-dev \ + libzstd-dev \ make \ nasm \ ninja-build \ - python \ + python3 \ texinfo \ vim \ wget \ xz-utils \ zlib1g-dev +# source revision to build +ARG BUILDTOOLS_REV=master +ARG HAIKU_REV=master # architectures to build ARG ARCHITECTURE=x86_64 ARG SECONDARY_ARCHITECTURE= @@ -36,6 +41,6 @@ ARG SECONDARY_ARCHITECTURE= WORKDIR /tmp COPY build-toolchain.sh /tmp/ RUN chmod 755 /tmp/build-toolchain.sh -RUN /tmp/build-toolchain.sh $ARCHITECTURE $SECONDARY_ARCHITECTURE +RUN /tmp/build-toolchain.sh $BUILDTOOLS_REV $HAIKU_REV $ARCHITECTURE $SECONDARY_ARCHITECTURE WORKDIR / diff --git a/3rdparty/docker/cross-compiler/README.md b/3rdparty/docker/cross-compiler/README.md index cb5629bcfe..fde2a94cb9 100644 --- a/3rdparty/docker/cross-compiler/README.md +++ b/3rdparty/docker/cross-compiler/README.md @@ -14,3 +14,22 @@ The docker build of this image prepares the environment by: You can then use the $ARCH-unknown-haiku compiler (for example arm-unknown-haiku-gcc) to build your application. All the required files are installed in /tools/cross-tools-$ARCH. + +## Building the image + +The Dockerfile accepts four arguments when building the image: + +* `BUILDTOOLS_REV` is the branch/tag of buildtools that should be built. It defaults to `master`. +* `HAIKU_REV` is the branch/tag of the haiku repository that should be built. It defaults to `master`. +* `ARCHITECTURE` is the primary architecture to build the tools and library for. It defaults to `x86_64` +* `SECONDARY_ARCHITECTURE` is the secondary architecture. Leave it empty in case it is not necessary. + +For example, the r1beta4 images are build with the following commands: + +```bash +# r1beta4 on x86 hybrid, with gcc2 as the primary architecture, and modern gcc as the secondary +podman build --build-arg BUILDTOOLS_REV=r1beta4 --build-arg HAIKU_REV=r1beta4 --build-arg ARCHITECTURE=x86_gcc2 --build-arg SECONDARY_ARCHITECTURE=x86 --tag docker.io/haiku/cross-compiler:x86_gcc2h-r1beta4 . + +# r1beta4 on x86_64 +podman build --build-arg BUILDTOOLS_REV=r1beta4 --build-arg HAIKU_REV=r1beta4 --build-arg ARCHITECTURE=x86_64 --tag docker.io/haiku/cross-compiler:x86_64-r1beta4 . +``` diff --git a/3rdparty/docker/cross-compiler/build-toolchain.sh b/3rdparty/docker/cross-compiler/build-toolchain.sh index 1032de00af..ab78a527d9 100644 --- a/3rdparty/docker/cross-compiler/build-toolchain.sh +++ b/3rdparty/docker/cross-compiler/build-toolchain.sh @@ -11,8 +11,10 @@ set -ex -ARCH=$1 -SECONDARY_ARCH=$2 +BUILDTOOLS_REV=$1 +HAIKU_REV=$2 +ARCH=$3 +SECONDARY_ARCH=$4 TOP=$(pwd) @@ -23,14 +25,23 @@ SYSROOT=$OUTPUT/cross-tools-$ARCH/sysroot SYSROOT_SECONDARY=$OUTPUT/cross-tools-$SECONDARY_ARCH/sysroot PACKAGE_ROOT=/system -# First up, build a cross-compiler -git clone --depth=1 https://git.haiku-os.org/haiku -git clone --depth=1 https://git.haiku-os.org/buildtools +# Get the source trees +git clone --depth=1 --branch $HAIKU_REV https://review.haiku-os.org/haiku +git clone --depth=1 --branch $BUILDTOOLS_REV https://review.haiku-os.org/buildtools + +# 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. +cd haiku +if ! `git describe --dirty --tags --match=hrev* --abbrev=1`; then + git fetch --unshallow +fi + +# Build a cross-compiler cd $BUILDTOOLS/jam make && ./jam0 install mkdir -p $OUTPUT cd $OUTPUT -configureArgs="--build-cross-tools $ARCH $TOP/buildtools" +configureArgs="--build-cross-tools $ARCH --cross-tools-source $TOP/buildtools" if [ -n "$SECONDARY_ARCH" ]; then configureArgs="$configureArgs --build-cross-tools $SECONDARY_ARCH" fi @@ -42,7 +53,7 @@ mkdir -p $PACKAGE_ROOT ln -s $PACKAGE_ROOT $SYSROOT/boot/system if [ -n "$SECONDARY_ARCH" ]; then mkdir -p $SYSROOT_SECONDARY/boot - ln -s $PACKAGEROOT $SYSROOT_SECONDARY/boot/system + ln -s $PACKAGE_ROOT $SYSROOT_SECONDARY/boot/system fi # Build needed packages and tools for the cross-compiler @@ -73,12 +84,6 @@ if [ -n "$SECONDARY_ARCH" ]; then package extract -C $PACKAGE_ROOT $OUTPUT/objects/haiku/$ARCH/packaging/packages/haiku_${SECONDARY_ARCH}_devel.hpkg fi find $OUTPUT/download/ -name '*.hpkg' -exec package extract -C $PACKAGE_ROOT {} \; -cd $PACKAGE_ROOT/develop/lib -ln -s ../../lib/libgcc_s.so libgcc_s.so -if [ -n "$SECONDARY_ARCH" ]; then - cd $PACKAGE_ROOT/develop/lib/$SECONDARY_ARCH - ln -s ../../../lib/$SECONDARY_ARCH/libgcc_s.so libgcc_s.so -fi # Clean up rm -rf $BUILDTOOLS