Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LoongArch64 build support #3198

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
82a70fb
Update HarfBuzzSharp.NativeAssets.Linux.csproj
4Darmygeometry Mar 13, 2025
1d32765
Update HarfBuzzSharp.targets
4Darmygeometry Mar 13, 2025
8c3ab8e
Update SkiaSharp.NativeAssets.Linux.NoDependencies.csproj
4Darmygeometry Mar 13, 2025
6052d86
Update SkiaSharp.targets
4Darmygeometry Mar 13, 2025
26ac5d1
Update SkiaSharp.NativeAssets.Linux.csproj
4Darmygeometry Mar 13, 2025
4f66437
Update SkiaSharp.targets
4Darmygeometry Mar 13, 2025
7c51154
Add loongarch64 build support
4Darmygeometry Mar 13, 2025
e388db4
Update build-local.sh
4Darmygeometry Mar 13, 2025
4858d70
Update azure-templates-stages.yml
4Darmygeometry Mar 13, 2025
b2dbd86
Update native-shared.cake
4Darmygeometry Mar 13, 2025
b411e27
Merge branch 'mono:main' into main
4Darmygeometry Mar 13, 2025
6235ded
Rename Dockerfile.txt to Dockerfile
4Darmygeometry Mar 14, 2025
0ce6b8f
Update Dockerfile
4Darmygeometry Mar 14, 2025
fdade1c
Create Dockerfile
4Darmygeometry Mar 14, 2025
ce40ab5
Update build.cake
4Darmygeometry Mar 14, 2025
b4e0bb7
Create _clang-cross-common.sh
4Darmygeometry Mar 14, 2025
16ba67d
Create .dockerignore
4Darmygeometry Mar 14, 2025
155d279
Create build-local.sh
4Darmygeometry Mar 14, 2025
626f2c7
Update build-local.sh
4Darmygeometry Mar 14, 2025
d44aa00
Update azure-templates-stages.yml
4Darmygeometry Mar 14, 2025
912997d
Update azure-templates-stages.yml
4Darmygeometry Mar 14, 2025
f8f531c
Update build.cake
4Darmygeometry Mar 15, 2025
935dfd8
Dockerfile:Update apk.static version
4Darmygeometry Mar 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
<PackageFile Include="..\..\output\native\linux\arm64\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-arm64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\linux\arm\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-arm\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\linux\riscv64\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-riscv64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\linux\loongarch64\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-loongarch64\native\%(Filename)%(Extension)" />
<!-- Musl -->
<PackageFile Include="..\..\output\native\alpine\x64\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-musl-x64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\x86\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-musl-x86\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\arm64\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-musl-arm64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\arm\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-musl-arm\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\riscv64\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-musl-riscv64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\loongarch64\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-musl-loongarch64\native\%(Filename)%(Extension)" />
</ItemGroup>
<Target Name="IncludeAdditionalTfmSpecificPackageFiles">
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<_NativeHarfBuzzSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-riscv64\native\libHarfBuzzSharp*.so">
<Dir>riscv64\</Dir>
</_NativeHarfBuzzSharpFile>
<_NativeHarfBuzzSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-loongarch64\native\libHarfBuzzSharp*.so">
<Dir>loongarch64\</Dir>
</_NativeHarfBuzzSharpFile>

<!-- Musl -->
<_NativeHarfBuzzSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-musl-x86\native\libHarfBuzzSharp*.so">
Expand All @@ -42,6 +45,9 @@
<_NativeHarfBuzzSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-musl-riscv64\native\libHarfBuzzSharp*.so">
<Dir>musl-riscv64\</Dir>
</_NativeHarfBuzzSharpFile>
<_NativeHarfBuzzSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-musl-loongarch64\native\libHarfBuzzSharp*.so">
<Dir>musl-loongarch64\</Dir>
</_NativeHarfBuzzSharpFile>

<!-- include everything -->
<Content Include="@(_NativeHarfBuzzSharpFile)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ The complete dependency list is:
- libdl.so.2
- libm.so.6
- libc.so.6
- ld-linux-x86-64.so.2
- ld-linux-x86-64.so.2 (If architecture is x86_64)
- ld-linux-riscv64-lp64d.so.1 (If architecture is riscv64)
- ld-linux-loongarch-lp64d.so.1 (If architecture is loongarch64)

The excluded dependencies are:
- Fontconfig</PackageNotes>
Expand All @@ -22,17 +24,19 @@ The excluded dependencies are:
<PackageFile Include="..\..\output\native\linuxnodeps\arm64\libSkiaSharp*.so" PackagePath="runtimes\linux-arm64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\linuxnodeps\arm\libSkiaSharp*.so" PackagePath="runtimes\linux-arm\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\linuxnodeps\riscv64\libSkiaSharp*.so" PackagePath="runtimes\linux-riscv64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\linuxnodeps\loongarch64\libSkiaSharp*.so" PackagePath="runtimes\linux-loongarch64\native\%(Filename)%(Extension)" />
<!-- Musl -->
<PackageFile Include="..\..\output\native\alpinenodeps\x64\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-x64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpinenodeps\x86\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-x86\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpinenodeps\arm64\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-arm64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpinenodeps\arm\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-arm\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpinenodeps\riscv64\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-riscv64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpinenodeps\loongarch64\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-loongarch64\native\%(Filename)%(Extension)" />
</ItemGroup>
<Target Name="IncludeAdditionalTfmSpecificPackageFiles">
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
<TfmSpecificPackageFile Include="buildTransitive\net4\SkiaSharp.targets" PackagePath="buildTransitive\$(NuGetShortFolderName)\$(PackageId).targets" />
<TfmSpecificPackageFile Include="buildTransitive\net4\SkiaSharp.targets" PackagePath="build\$(NuGetShortFolderName)\$(PackageId).targets" />
</ItemGroup>
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-riscv64\native\libSkiaSharp*.so">
<Dir>riscv64\</Dir>
</_NativeSkiaSharpFile>
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-loongarch64\native\libSkiaSharp*.so">
<Dir>loongarch64\</Dir>
</_NativeSkiaSharpFile>

<!-- Musl -->
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-musl-x86\native\libSkiaSharp*.so">
Expand All @@ -42,6 +45,9 @@
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-musl-riscv64\native\libSkiaSharp*.so">
<Dir>musl-riscv64\</Dir>
</_NativeSkiaSharpFile>
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-musl-loongarch64\native\libSkiaSharp*.so">
<Dir>musl-loongarch64\</Dir>
</_NativeSkiaSharpFile>

<!-- include everything -->
<Content Include="@(_NativeSkiaSharpFile)">
Expand All @@ -52,4 +58,4 @@

</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
<PackageFile Include="..\..\output\native\linux\arm64\libSkiaSharp*.so" PackagePath="runtimes\linux-arm64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\linux\arm\libSkiaSharp*.so" PackagePath="runtimes\linux-arm\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\linux\riscv64\libSkiaSharp*.so" PackagePath="runtimes\linux-riscv64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\linux\loongarch64\libSkiaSharp*.so" PackagePath="runtimes\linux-loongarch64\native\%(Filename)%(Extension)" />
<!-- Musl -->
<PackageFile Include="..\..\output\native\alpine\x64\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-x64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\x86\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-x86\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\arm64\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-arm64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\arm\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-arm\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\riscv64\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-riscv64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\loongarch64\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-loongarch64\native\%(Filename)%(Extension)" />
</ItemGroup>
<Target Name="IncludeAdditionalTfmSpecificPackageFiles">
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-riscv64\native\libSkiaSharp*.so">
<Dir>riscv64\</Dir>
</_NativeSkiaSharpFile>
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-loongarch64\native\libSkiaSharp*.so">
<Dir>loongarch64\</Dir>
</_NativeSkiaSharpFile>

<!-- Musl -->
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-musl-x86\native\libSkiaSharp*.so">
Expand All @@ -42,6 +45,9 @@
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-musl-riscv64\native\libSkiaSharp*.so">
<Dir>musl-riscv64\</Dir>
</_NativeSkiaSharpFile>
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-musl-loongarch64\native\libSkiaSharp*.so">
<Dir>musl-loongarch64\</Dir>
</_NativeSkiaSharpFile>

<!-- include everything -->
<Content Include="@(_NativeSkiaSharpFile)">
Expand Down
17 changes: 12 additions & 5 deletions native/linux-clang-cross/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ if (BUILD_ARCH.Length == 0)

string GetGnArgs(string arch)
{
var (vendor, abi, sysrootarg, linker) = BUILD_VARIANT switch
{
"alpine" or "alpinenodeps" => ("-alpine", "musl", "'--sysroot=/alpine', ", "'-fuse-ld=lld'"),
_ => ("", "gnu", "", ""),
};
var (toolchainArch, targetArch) = arch switch
{
"arm" => ("arm-linux-gnueabihf", "armv7a-linux-gnueabihf"),
"arm64" => ("aarch64-linux-gnu", "aarch64-linux-gnu"),
_ => ($"{arch}-linux-gnu", $"{arch}-linux-gnu"),
"arm" => ($"arm{vendor}-linux-{abi}eabihf", $"armv7a{vendor}-linux-{abi}eabihf"),
"arm64" => ($"aarch64{vendor}-linux-{abi}", $"aarch64{vendor}-linux-{abi}"),
_ => ($"{arch}{vendor}-linux-{abi}", $"{arch}{vendor}-linux-{abi}"),
};

var sysroot = $"/usr/{toolchainArch}";
var init = $"'--target={targetArch}'";
var init = $"{sysrootarg} '--target={targetArch}'";
var bin = $"'-B{sysroot}/bin/' ";
var libs = $"'-L{sysroot}/lib/' ";
var includes =
Expand All @@ -26,7 +31,7 @@ string GetGnArgs(string arch)
return
$"extra_asmflags+=[ {init}, '-no-integrated-as', {bin}, {includes} ] " +
$"extra_cflags+=[ {init}, {bin}, {includes} ] " +
$"extra_ldflags+=[ {init}, {bin}, {libs} ] " +
$"extra_ldflags+=[ {init}, {bin}, {libs}, {linker} ] " +
ADDITIONAL_GN_ARGS;
}

Expand All @@ -38,6 +43,7 @@ Task("libSkiaSharp")
RunCake("../linux/build.cake", "libSkiaSharp", new Dictionary<string, string> {
{ "arch", arch },
{ "gnArgs", GetGnArgs(arch) },
{ "variant", BUILD_VARIANT },
});
}
});
Expand All @@ -50,6 +56,7 @@ Task("libHarfBuzzSharp")
RunCake("../linux/build.cake", "libHarfBuzzSharp", new Dictionary<string, string> {
{ "arch", arch },
{ "gnArgs", GetGnArgs(arch) },
{ "variant", BUILD_VARIANT },
});
}
});
Expand Down
43 changes: 43 additions & 0 deletions scripts/Docker/_clang-cross-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -ex

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
DOCKER_DIR="$1"

# the target architecture to build for
ARCH="${2:-arm}"

# the docker image architecture to use
MACHINE_ARCH="$(uname -m)"
[ "$MACHINE_ARCH" = "arm64" ] && MACHINE_ARCH=aarch64
IMAGE_ARCH="${3:-$([[ "$MACHINE_ARCH" == "aarch64" ]] && echo "arm64v8" || echo "amd64")}"

DISTRO_VERSION=$4
ABI=$5
VENDOR=$6

case $ARCH in
arm) TOOLCHAIN_ARCH=arm$VENDOR-linux-${ABI}eabihf ; TOOLCHAIN_ARCH_SHORT=armhf ; TARGET_MACHINE_ARCH=armhf ;;
arm64) TOOLCHAIN_ARCH=aarch64$VENDOR-linux-$ABI ; TOOLCHAIN_ARCH_SHORT=arm64 ; TARGET_MACHINE_ARCH=aarch64 ;;
loongarch64) TOOLCHAIN_ARCH=loongarch64$VENDOR-linux-$ABI ; TOOLCHAIN_ARCH_SHORT=loong64 ; TARGET_MACHINE_ARCH=loongarch64 ;;
riscv64) TOOLCHAIN_ARCH=riscv64$VENDOR-linux-$ABI ; TOOLCHAIN_ARCH_SHORT=riscv64 ; TARGET_MACHINE_ARCH=riscv64 ;;
x86) TOOLCHAIN_ARCH=i686$VENDOR-linux-$ABI ; TOOLCHAIN_ARCH_SHORT=i386 ; TARGET_MACHINE_ARCH=x86 ;;
x64) TOOLCHAIN_ARCH=x86-64$VENDOR-linux-$ABI ; TOOLCHAIN_ARCH_SHORT=amd64 ; TARGET_MACHINE_ARCH=x86_64 ;;
*) echo "Unsupported architecture: $ARCH" && exit 1 ;;
esac

(cd $DIR && docker build --tag skiasharp-linux-$ABI-cross-$ARCH \
--build-arg TOOLCHAIN_ARCH=$TOOLCHAIN_ARCH \
--build-arg TOOLCHAIN_ARCH_SHORT=$TOOLCHAIN_ARCH_SHORT \
--build-arg IMAGE_ARCH=$IMAGE_ARCH \
--build-arg MACHINE_ARCH=$MACHINE_ARCH \
--build-arg TARGET_MACHINE_ARCH=$TARGET_MACHINE_ARCH \
--build-arg DISTRO_VERSION=$DISTRO_VERSION \
$DOCKER_DIR)

if [ "$VENDOR" = "-alpine" ]; then vendor=alpine; fi

(cd $DIR/../.. &&
docker run --rm --name skiasharp-linux-$ABI-cross-$ARCH --volume $(pwd):/work skiasharp-linux-$ABI-cross-$ARCH /bin/bash -c "\
dotnet tool restore &&
dotnet cake --target=externals-linux-clang-cross --configuration=Release --buildarch=$ARCH --variant=$vendor")
1 change: 1 addition & 0 deletions scripts/Docker/alpine/clang-cross/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build-local.sh
51 changes: 51 additions & 0 deletions scripts/Docker/alpine/clang-cross/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Arguments:
# IMAGE_ARCH - the architecture of the image [ amd64 | arm64v8 | riscv64 | loongarch64 ]
# DOTNET_SDK_VERSION - the version of dotnet for the Cake script [ 9.0 | * ]
# TOOLCHAIN_VERSION - the version of the GCC toolchain [ 14 | * ]
# TOOLCHAIN_ARCH - the architecture of the GCC toolchain [ arm-alpine-linux-musleabihf | aarch64-alpine-linux-musl | riscv64-alpine-linux-musl | loongarch64-alpine-linux-musl ]
# TOOLCHAIN_ARCH_SHORT - the short form architecture of the GCC toolchain [ armhf | arm64 | loong64 ]
# FONTCONFIG_VERSION - the exact version of libfontconfig1 to use [ 2.13.1-2 | * ]

ARG IMAGE_ARCH=amd64
FROM ${IMAGE_ARCH}/debian:12

# Install the required packages
RUN apt-get update \
&& apt-get install -y \
curl python3 git clang-19 lld-19 ninja-build xz-utils curl \
&& rm -rf /var/lib/apt/lists/*

# Install the cross-compilation musl toolchain
ARG DISTRO_VERSION=3.21
ARG TOOLCHAIN_ARCH_SHORT=loong64
ARG MACHINE_ARCH=x86_64
ARG TARGET_MACHINE_ARCH=loongarch64

# obtain apk.static from gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v2.14.6
# apk.static for loongarch64 can be download in http://dl-cdn.alpinelinux.org/alpine/v3.21/main/loongarch64/apk-tools-static-2.14.6-r3.apk.
RUN APK_DIR="$(mktemp -d)" && \
curl -SLO --create-dirs --output-dir "$APK_DIR" "https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.6/$MACHINE_ARCH/apk.static" && \
chmod +x "$APK_DIR/apk.static" && \
"$APK_DIR/apk.static" \
-X "http://dl-cdn.alpinelinux.org/alpine/v$DISTRO_VERSION/main" \
-X "http://dl-cdn.alpinelinux.org/alpine/v$DISTRO_VERSION/community" \
-U --allow-untrusted --root /alpine --arch "$TARGET_MACHINE_ARCH" --initdb add && \
"$APK_DIR/apk.static" \
-X "http://dl-cdn.alpinelinux.org/alpine/v$DISTRO_VERSION/main" \
-X "http://dl-cdn.alpinelinux.org/alpine/v$DISTRO_VERSION/community" \
-U --allow-untrusted --root /alpine --arch "$TARGET_MACHINE_ARCH" --no-scripts \
add fontconfig-dev build-base linux-headers

# Install the .NET SDK
ARG DOTNET_SDK_VERSION=9.0
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT 1
RUN curl https://dot.net/v1/dotnet-install.sh -L -o dotnet-install.sh \
&& bash dotnet-install.sh --channel ${DOTNET_SDK_VERSION} --install-dir /usr/share/dotnet --verbose \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& rm dotnet-install.sh \
&& dotnet help \
&& dotnet --info

ENV CC=clang-19 CXX=clang++-19

WORKDIR /work
16 changes: 16 additions & 0 deletions scripts/Docker/alpine/clang-cross/build-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -ex

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

ARCH=$1
ALPINE_VERSION=$3
if [ -z "$ALPINE_VERSION" ]; then
case $ARCH in
loongarch64) ALPINE_VERSION=3.21 ;;
riscv64) ALPINE_VERSION=3.20 ;;
*) ALPINE_VERSION=3.17 ;;
esac
fi

$DIR/../../_clang-cross-common.sh "$DIR" "$ARCH" "$2" "$ALPINE_VERSION" "musl" "-alpine"
64 changes: 64 additions & 0 deletions scripts/Docker/debian/clang-cross/13/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Arguments:
# IMAGE_ARCH - the architecture of the image [ amd64 | arm64v8 | riscv64 | loongarch64 ]
# DOTNET_SDK_VERSION - the version of dotnet for the Cake script [ 9.0 | * ]
# TOOLCHAIN_VERSION - the version of the GCC toolchain [ 14 | * ]
# TOOLCHAIN_ARCH - the architecture of the GCC toolchain [ arm-linux-gnueabihf | aarch64-linux-gnu | riscv64-linux-gnu | loongarch64-linux-gnu ]
# TOOLCHAIN_ARCH_SHORT - the short form architecture of the GCC toolchain [ armhf | arm64 | loong64 ]
# FONTCONFIG_VERSION - the exact version of libfontconfig1 to use [ 2.15.0-1 | * ]

ARG IMAGE_ARCH=amd64
FROM ${IMAGE_ARCH}/debian:12

# Install the required packages (needs to add ftp.debian.org source)
RUN apt-get update \
&& apt-get install -y \
curl python3 git clang-19 ninja-build xz-utils \
&& rm -rf /var/lib/apt/lists/*

# Install the cross-compilation GCC toolchain (loongarch64 use GCC cross ports)
ARG TOOLCHAIN_VERSION=14
ARG TOOLCHAIN_ARCH=loongarch64-linux-gnu
ARG TOOLCHAIN_ARCH_SHORT=loong64
RUN apt-get update \
&& apt-get install -y \
libstdc++-${TOOLCHAIN_VERSION}-dev-${TOOLCHAIN_ARCH_SHORT}-cross \
libgcc-${TOOLCHAIN_VERSION}-dev-${TOOLCHAIN_ARCH_SHORT}-cross \
binutils-${TOOLCHAIN_ARCH} \
&& rm -rf /var/lib/apt/lists/*

# Make the script more flexible and use "current" instead of the actual version
RUN ln -s /usr/${TOOLCHAIN_ARCH}/include/c++/${TOOLCHAIN_VERSION} /usr/${TOOLCHAIN_ARCH}/include/c++/current \
&& sed -i "s/\/usr\/${TOOLCHAIN_ARCH}\/lib\///g" /usr/${TOOLCHAIN_ARCH}/lib/libpthread.so || true \
&& sed -i "s/\/usr\/${TOOLCHAIN_ARCH}\/lib\///g" /usr/${TOOLCHAIN_ARCH}/lib/libc.so

# Install the cross-compilation skia build dependencies (fontconfig)
ARG FONTCONFIG_VERSION=2.15.0-1.1
RUN (mkdir -p /skia-utils/libfontconfig1-dev \
&& cd /skia-utils/libfontconfig1-dev \
&& curl https://pkg.loongnix.cn/loongnix/25/pool/main/f/fontconfig/libfontconfig-dev_${FONTCONFIG_VERSION}_${TOOLCHAIN_ARCH_SHORT}.deb -L -o libfontconfig1-dev.deb \
&& ar vx libfontconfig1-dev.deb \
&& tar -xJvf data.tar.xz \
&& rm libfontconfig1-dev.deb \
&& cp -R usr/lib/*/* /usr/${TOOLCHAIN_ARCH}/lib/ \
&& cp -R usr/include/* /usr/${TOOLCHAIN_ARCH}/include/ )
RUN (mkdir -p /skia-utils/libfontconfig1 \
&& cd /skia-utils/libfontconfig1 \
&& curl https://pkg.loongnix.cn/loongnix/25/pool/main/f/fontconfig/libfontconfig1_${FONTCONFIG_VERSION}_${TOOLCHAIN_ARCH_SHORT}.deb -L -o libfontconfig1.deb \
&& ar vx libfontconfig1.deb \
&& tar -xJvf data.tar.xz \
&& rm libfontconfig1.deb \
&& cp -R usr/lib/*/* /usr/${TOOLCHAIN_ARCH}/lib/ )

# Install the .NET SDK
ARG DOTNET_SDK_VERSION=9.0
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT 1
RUN curl https://dot.net/v1/dotnet-install.sh -L -o dotnet-install.sh \
&& bash dotnet-install.sh --channel ${DOTNET_SDK_VERSION} --install-dir /usr/share/dotnet --verbose \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& rm dotnet-install.sh \
&& dotnet help \
&& dotnet --info

ENV CC=clang-19 CXX=clang++-19

WORKDIR /work
Loading