# Copyright © SixtyFPS GmbH # SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 # cSpell: ignore CLANGCC CLANGCXX CXXFLAGS lname MULTIARCH noninteractive readlink SDKTARGETSYSROOT Yocto # Ubuntu 22.04 sysroot with the target libraries for the clang cross-build # below. Its glibc 2.35 is the oldest glibc the binaries built here run on. # apt installs the foreign-architecture (multiarch) packages without # emulation; the target files are then copied into /sysroot. FROM ubuntu:22.04 AS sysroot RUN sed -i 's/^deb http/deb [arch=amd64] http/' /etc/apt/sources.list && \ for suite in jammy jammy-updates jammy-security; do \ echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $suite main universe" >> /etc/apt/sources.list; \ done && \ dpkg --add-architecture arm64 && \ apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes --no-install-recommends \ libc6-dev:arm64 libgcc-12-dev:arm64 libstdc++-12-dev:arm64 \ libfontconfig1-dev:arm64 libxcb1-dev:arm64 libxcb-render0-dev:arm64 libxcb-shape0-dev:arm64 libxcb-xfixes0-dev:arm64 \ libxkbcommon-dev:arm64 libinput-dev:arm64 libudev-dev:arm64 libgbm-dev:arm64 libseat-dev:arm64 libssl-dev:arm64 # Absolute symlinks are made relative so that they resolve inside /sysroot. RUN mkdir -p /sysroot/usr/lib /sysroot/usr/share && \ cp -a /usr/include /sysroot/usr/ && \ cp -a /usr/lib/aarch64-linux-gnu /usr/lib/gcc /usr/lib/ld-linux-aarch64.so.1 /sysroot/usr/lib/ && \ cp -a /usr/share/pkgconfig /sysroot/usr/share/ && \ mkdir -p /sysroot/var/lib/dpkg && cp /var/lib/dpkg/status /sysroot/var/lib/dpkg/ && \ ln -s usr/lib /sysroot/lib && \ find /sysroot -type l -lname '/*' -exec sh -c 'ln -sfr "/sysroot$(readlink "$1")" "$1"' _ {} \; # Ubuntu 26.04 for a recent clang and a git that is new enough for the Skia # source build. FROM ubuntu:26.04 # clang cross-compiles against the sysroot, with lld linking the # foreign-architecture binaries; ninja and python3 are for the Skia source # build, cmake is for aws-lc-sys. zstd is for the rust-cache action when this # image is used as a job container. RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes clang lld llvm gcc libclang-dev pkg-config libfontconfig-dev cmake ninja-build python3 git curl ca-certificates zstd && \ # The skia-bindings build clones git repos into the mounted, differently # owned cargo home. git config --global safe.directory '*' COPY --from=sysroot /sysroot /sysroot # For adding more target packages to the sysroot, see the script. COPY docker/sysroot-apt-install.sh /usr/local/bin/sysroot-apt-install ENV SYSROOT_DEB_ARCH=arm64 \ SYSROOT_APT_URI=http://ports.ubuntu.com/ubuntu-ports ENV CROSS_SYSROOT=/sysroot \ CROSS_MULTIARCH=aarch64-linux-gnu \ CROSS_CLANG_TARGET=aarch64-unknown-linux-gnu \ CROSS_CMAKE_SYSTEM_PROCESSOR=aarch64 ARG CROSS="--target=$CROSS_CLANG_TARGET --sysroot=$CROSS_SYSROOT $CROSS_CLANG_FLAGS" # clang runs the target-prefixed ld when it exists, so this makes lld the # linker for every clang invocation for the target, including the ones # Corrosion and CMake make. RUN ln -s "$(command -v ld.lld)" /usr/local/bin/aarch64-unknown-linux-gnu-ld # The link flags live in a linker wrapper rather than in the rustflags: tools # like napi overwrite RUSTFLAGS, which takes precedence over the # CARGO_TARGET_*_RUSTFLAGS variable and would drop them. RUN printf '#!/bin/sh\nexec clang %s "$@"\n' "$CROSS" > /usr/local/bin/aarch64-unknown-linux-gnu-clang && \ chmod +x /usr/local/bin/aarch64-unknown-linux-gnu-clang # For C++ builds (the -cpp image) and for the cmake crate. COPY docker/cross-toolchain.cmake /opt/toolchain.cmake ENV CMAKE_TOOLCHAIN_FILE_aarch64_unknown_linux_gnu=/opt/toolchain.cmake # SDKTARGETSYSROOT and CLANGCC/CLANGCXX are skia-bindings' Yocto-style cross # setup for the gn build. ENV SDKTARGETSYSROOT=/sysroot ENV CLANGCC="clang $CROSS" ENV CLANGCXX="clang++ $CROSS" ENV PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_gnu=/sysroot ENV PKG_CONFIG_LIBDIR_aarch64_unknown_linux_gnu=/sysroot/usr/lib/aarch64-linux-gnu/pkgconfig:/sysroot/usr/share/pkgconfig ENV CC_aarch64_unknown_linux_gnu=clang ENV CXX_aarch64_unknown_linux_gnu=clang++ ENV AR_aarch64_unknown_linux_gnu=llvm-ar ENV CFLAGS_aarch64_unknown_linux_gnu="$CROSS" ENV CXXFLAGS_aarch64_unknown_linux_gnu="$CROSS" ENV BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu="$CROSS" ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-unknown-linux-gnu-clang