Skip to content

Commit ecafe28

Browse files
authored
Add Azure Linux images for .NET 10 (#1263)
Contributes to dotnet/runtime#109939. These images have LLVM 19.1.0, but will be updated to LLVM 20 per the plan, once that is released.
1 parent bde3c9e commit ecafe28

File tree

26 files changed

+1466
-0
lines changed

26 files changed

+1466
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
ARG ANDROID_SDK_ROOT=/usr/local/android-sdk
2+
ARG ANDROID_NDK_VERSION=23.2.8568313
3+
ARG ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION
4+
FROM mcr.microsoft.com/openjdk/jdk:17-mariner AS android-sdk-download
5+
ARG ANDROID_SDK_ROOT
6+
ARG ANDROID_NDK_VERSION
7+
ARG ANDROID_NDK_ROOT
8+
9+
# Dependencies for Android SDK install
10+
RUN tdnf update -y \
11+
&& tdnf install -y \
12+
# Android dependencies
13+
wget \
14+
zip \
15+
unzip
16+
17+
# Grab the necessary Android SDK packages / tools
18+
RUN wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip \
19+
&& echo "2d2d50857e4eb553af5a6dc3ad507a17adf43d115264b1afc116f95c92e5e258 commandlinetools-linux-11076708_latest.zip" | sha256sum -c \
20+
&& mkdir -p /usr/local/cmdline-tools \
21+
&& unzip commandlinetools-linux-11076708_latest.zip -d /usr/local/cmdline-tools \
22+
&& rm -f commandlinetools-linux-11076708_latest.zip \
23+
&& yes | /usr/local/cmdline-tools/cmdline-tools/bin/sdkmanager --sdk_root="${ANDROID_SDK_ROOT}" --licenses
24+
25+
RUN yes | /usr/local/cmdline-tools/cmdline-tools/bin/sdkmanager --licenses
26+
RUN /usr/local/cmdline-tools/cmdline-tools/bin/sdkmanager --sdk_root="${ANDROID_SDK_ROOT}" --install "build-tools;33.0.0" "platforms;android-33" "ndk;${ANDROID_NDK_VERSION}"
27+
28+
# We can't upgrade the NDK version as the runtime repo requires tooling that only exists up to NDK 23
29+
# Remove all components of NDK 23 that are flagged by security scanners
30+
RUN rm -r ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/python3/lib/python3.9/site-packages/ \
31+
&& rm -r ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang-tidy
32+
33+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-llvm-amd64
34+
35+
# Install Microsoft OpenJDK from the Microsoft OpenJDK 17 Mariner image.
36+
ENV LANG=en_US.UTF-8
37+
ENV JAVA_HOME=/usr/lib/jvm/msopenjdk-17
38+
ENV PATH=$JAVA_HOME/bin:$PATH
39+
COPY --from=mcr.microsoft.com/openjdk/jdk:17-mariner $JAVA_HOME $JAVA_HOME
40+
ARG ANDROID_SDK_ROOT
41+
ARG ANDROID_NDK_VERSION
42+
ARG ANDROID_NDK_ROOT
43+
44+
45+
# Dependencies for Android build
46+
RUN tdnf update -y \
47+
&& tdnf install -y \
48+
# Common dependencies
49+
binutils \
50+
# Android dependencies
51+
zip \
52+
unzip \
53+
# linux-bionic build dependencies
54+
openssl-devel
55+
56+
ENV ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT}
57+
ENV ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT}
58+
59+
COPY --from=android-sdk-download $ANDROID_SDK_ROOT $ANDROID_SDK_ROOT
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-android-amd64
2+
3+
RUN tdnf update -y \
4+
&& tdnf install -y \
5+
moby-engine \
6+
moby-cli
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ARG ROOTFS_DIR=/crossrootfs/x64
2+
3+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-builder-amd64 AS builder
4+
ARG ROOTFS_DIR
5+
6+
RUN /scripts/eng/common/cross/build-rootfs.sh x64 alpine3.17 --skipunmount
7+
8+
RUN TARGET_TRIPLE="x86_64-alpine-linux-musl" && \
9+
cmake -S llvm-project.src/runtimes -B runtimes \
10+
-DCMAKE_BUILD_TYPE=Release \
11+
-DCMAKE_ASM_COMPILER=clang \
12+
-DCMAKE_C_COMPILER=clang \
13+
-DCMAKE_CXX_COMPILER=clang++ \
14+
-DCMAKE_ASM_COMPILER_TARGET="$TARGET_TRIPLE" \
15+
-DCMAKE_C_COMPILER_TARGET="$TARGET_TRIPLE" \
16+
-DCMAKE_CXX_COMPILER_TARGET="$TARGET_TRIPLE" \
17+
# We're going to link the static libraries we build here into PIC images, so build the static libraries as PIC.
18+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
19+
-DCMAKE_SYSROOT="$ROOTFS_DIR" \
20+
# Specify linker to use for exes directly for CMake toolchain detection
21+
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
22+
# Don't search for tools in the sysroot as we're cross-compiling
23+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="NEVER" \
24+
-DLLVM_USE_LINKER=lld \
25+
-DLLVM_ENABLE_RUNTIMES="libcxx" \
26+
-DLIBCXX_ENABLE_SHARED=OFF \
27+
-DLIBCXX_HAS_MUSL_LIBC=ON \
28+
-DLIBCXX_CXX_ABI=libstdc++ \
29+
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="$ROOTFS_DIR/usr/include/c++/12.2.1/;$ROOTFS_DIR/usr/include/c++/12.2.1/$TARGET_TRIPLE" && \
30+
cmake --build runtimes -j $(getconf _NPROCESSORS_ONLN) && \
31+
cmake --install runtimes --prefix "$ROOTFS_DIR/usr"
32+
33+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-llvm-amd64
34+
ARG ROOTFS_DIR
35+
36+
COPY --from=builder $ROOTFS_DIR $ROOTFS_DIR
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
ARG ROOTFS_DIR=/crossrootfs/x64
2+
3+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-builder-amd64 AS builder
4+
ARG ROOTFS_DIR
5+
6+
# Use Ubuntu Bionic as the base image for the rootfs
7+
# to get a new enough libstdc++ for the sanitizer runtimes and instrumentation.
8+
RUN /scripts/eng/common/cross/build-rootfs.sh x64 bionic --skipunmount
9+
10+
RUN TARGET_TRIPLE="x86_64-linux-gnu" && \
11+
CLANG_MAJOR_VERSION=$(clang --version | grep -oP "(?<=version )\d+") && \
12+
cmake -S llvm-project.src/runtimes -B runtimes \
13+
-DCMAKE_BUILD_TYPE=Release \
14+
-DCMAKE_ASM_COMPILER=clang \
15+
-DCMAKE_C_COMPILER=clang \
16+
-DCMAKE_CXX_COMPILER=clang++ \
17+
-DCMAKE_ASM_COMPILER_TARGET="$TARGET_TRIPLE" \
18+
-DCMAKE_C_COMPILER_TARGET="$TARGET_TRIPLE" \
19+
-DCMAKE_CXX_COMPILER_TARGET="$TARGET_TRIPLE" \
20+
# We're going to link the static libraries we build here into PIC images, so build the static libraries as PIC.
21+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
22+
-DCMAKE_SYSROOT="$ROOTFS_DIR" \
23+
# Specify linker to use for exes directly for CMake toolchain detection
24+
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
25+
# Don't search for tools in the sysroot as we're cross-compiling
26+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="NEVER" \
27+
-DLLVM_USE_LINKER=lld \
28+
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx" \
29+
-DLIBCXX_ENABLE_SHARED=OFF \
30+
-DLIBCXX_CXX_ABI="libstdc++" \
31+
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="$ROOTFS_DIR/usr/include/c++/7.5.0/;$ROOTFS_DIR/usr/include/$TARGET_TRIPLE" \
32+
-DCOMPILER_RT_CXX_LIBRARY="libcxx" \
33+
-DCOMPILER_RT_STATIC_CXX_LIBRARY=ON \
34+
-DSANITIZER_CXX_ABI_LIBNAME="libstdc++" \
35+
-DCOMPILER_RT_BUILD_MEMPROF=OFF \
36+
# The libfuzzer build in LLVM doesn't correctly forward the required CMake properties to the "fuzzed libc++" build
37+
# so skip it here.
38+
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
39+
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
40+
# Work around error building rtsan (this enables all sanitizers but rtsan)
41+
-DCOMPILER_RT_SANITIZERS_TO_BUILD="asan;dfsan;msan;hwasan;tsan;safestack;cfi;scudo_standalone;ubsan_minimal;gwp_asan;nsan;asan_abi" \
42+
-DCOMPILER_RT_INSTALL_PATH="/usr/local/lib/clang/$CLANG_MAJOR_VERSION" && \
43+
cmake --build runtimes -j && \
44+
cmake --install runtimes --prefix "$ROOTFS_DIR/usr"
45+
46+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-llvm-amd64
47+
ARG ROOTFS_DIR
48+
49+
COPY --from=builder /usr/local/lib/clang /usr/local/lib/clang
50+
COPY --from=builder $ROOTFS_DIR $ROOTFS_DIR
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
ARG ROOTFS_DIR=/crossrootfs/x64
2+
3+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-builder-amd64 AS builder
4+
ARG ROOTFS_DIR
5+
6+
RUN /scripts/eng/common/cross/build-rootfs.sh x64 bionic --skipunmount
7+
8+
RUN TARGET_TRIPLE="x86_64-linux-gnu" && \
9+
CLANG_MAJOR_VERSION=$(clang --version | grep -oP "(?<=version )\d+") && \
10+
cmake -S llvm-project.src/runtimes -B runtimes \
11+
-DCMAKE_BUILD_TYPE=Release \
12+
-DCMAKE_ASM_COMPILER=clang \
13+
-DCMAKE_C_COMPILER=clang \
14+
-DCMAKE_CXX_COMPILER=clang++ \
15+
-DCMAKE_ASM_COMPILER_TARGET="$TARGET_TRIPLE" \
16+
-DCMAKE_C_COMPILER_TARGET="$TARGET_TRIPLE" \
17+
-DCMAKE_CXX_COMPILER_TARGET="$TARGET_TRIPLE" \
18+
# We're going to link the static libraries we build here into PIC images, so build the static libraries as PIC.
19+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
20+
-DCMAKE_SYSROOT="$ROOTFS_DIR" \
21+
# Specify linker to use for exes directly for CMake toolchain detection
22+
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
23+
# Don't search for tools in the sysroot as we're cross-compiling
24+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="NEVER" \
25+
-DLLVM_USE_LINKER=lld \
26+
-DLLVM_ENABLE_RUNTIMES="libcxx;compiler-rt" \
27+
-DLIBCXX_ENABLE_SHARED=OFF \
28+
-DLIBCXX_CXX_ABI=libstdc++ \
29+
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="$ROOTFS_DIR/usr/include/c++/7.5.0/;$ROOTFS_DIR/usr/include/$TARGET_TRIPLE" \
30+
-DCOMPILER_RT_CXX_LIBRARY="libcxx" \
31+
-DCOMPILER_RT_STATIC_CXX_LIBRARY=ON \
32+
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
33+
-DCOMPILER_RT_BUILD_MEMPROF=OFF \
34+
# The libfuzzer build in LLVM doesn't correctly forward the required CMake properties to the "fuzzed libc++" build
35+
# so skip it here.
36+
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
37+
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
38+
-DCOMPILER_RT_INSTALL_PATH="/usr/local/lib/clang/$CLANG_MAJOR_VERSION" && \
39+
cmake --build runtimes -j $(getconf _NPROCESSORS_ONLN) && \
40+
cmake --install runtimes --prefix "$ROOTFS_DIR/usr"
41+
42+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-llvm-amd64
43+
ARG ROOTFS_DIR
44+
45+
COPY --from=builder /usr/local/lib/clang /usr/local/lib/clang/
46+
COPY --from=builder $ROOTFS_DIR $ROOTFS_DIR
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-amd64 AS crossrootx64
2+
3+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-android-amd64
4+
5+
# Copy crossrootfs from AMD64 build image, so we can build Android-targeting code for that arch
6+
COPY --from=crossrootx64 /crossrootfs/x64 /crossrootfs/x64
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-android-amd64
2+
3+
# Copy the OpenSSL headers and libs from the x64 rootfs into the Anroid NDK so dotnet/runtime's
4+
# OpenSSL headers hack can find them for the linux-bionic build.
5+
RUN mkdir -p ${ANDROID_NDK_ROOT}/usr/local/include && \
6+
mkdir ${ANDROID_NDK_ROOT}/usr/local/lib && \
7+
cp -r /crossrootfs/x64/usr/include/openssl ${ANDROID_NDK_ROOT}/usr/local/include/openssl && \
8+
cp -r /crossrootfs/x64/usr/include/x86_64-linux-gnu/openssl ${ANDROID_NDK_ROOT}/usr/local/include && \
9+
cp -r $(readlink -f /crossrootfs/x64/usr/lib/x86_64-linux-gnu/libssl.so) ${ANDROID_NDK_ROOT}/usr/local/lib/libssl.so && \
10+
cp -r $(readlink -f /crossrootfs/x64/usr/lib/x86_64-linux-gnu/libcrypto.so) ${ANDROID_NDK_ROOT}/usr/local/lib/libcrypto.so
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ARG ROOTFS_DIR=/crossrootfs/arm
2+
3+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-builder-amd64 AS builder
4+
ARG ROOTFS_DIR
5+
6+
RUN /scripts/eng/common/cross/build-rootfs.sh arm alpine3.17 --skipunmount
7+
8+
RUN TARGET_TRIPLE="armv7-alpine-linux-musleabihf" && \
9+
cmake -S llvm-project.src/runtimes -B runtimes \
10+
-DCMAKE_BUILD_TYPE=Release \
11+
-DCMAKE_ASM_COMPILER=clang \
12+
-DCMAKE_C_COMPILER=clang \
13+
-DCMAKE_CXX_COMPILER=clang++ \
14+
-DCMAKE_ASM_COMPILER_TARGET="$TARGET_TRIPLE" \
15+
-DCMAKE_C_COMPILER_TARGET="$TARGET_TRIPLE" \
16+
-DCMAKE_CXX_COMPILER_TARGET="$TARGET_TRIPLE" \
17+
# We're going to link the static libraries we build here into PIC images, so build the static libraries as PIC.
18+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
19+
-DCMAKE_SYSROOT="$ROOTFS_DIR" \
20+
# Specify linker to use for exes directly for CMake toolchain detection
21+
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
22+
# Don't search for tools in the sysroot as we're cross-compiling
23+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="NEVER" \
24+
-DLLVM_USE_LINKER=lld \
25+
-DLLVM_ENABLE_RUNTIMES="libcxx" \
26+
-DLIBCXX_ENABLE_SHARED=OFF \
27+
-DLIBCXX_HAS_MUSL_LIBC=ON \
28+
-DLIBCXX_CXX_ABI=libstdc++ \
29+
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="$ROOTFS_DIR/usr/include/c++/12.2.1/;$ROOTFS_DIR/usr/include/c++/12.2.1/$TARGET_TRIPLE" && \
30+
cmake --build runtimes -j $(getconf _NPROCESSORS_ONLN) && \
31+
cmake --install runtimes --prefix "$ROOTFS_DIR/usr"
32+
33+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-llvm-amd64
34+
ARG ROOTFS_DIR
35+
36+
COPY --from=builder $ROOTFS_DIR $ROOTFS_DIR
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
ARG ROOTFS_DIR=/crossrootfs/arm
2+
3+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-builder-amd64 AS builder
4+
ARG ROOTFS_DIR
5+
6+
# The arm rootfs targets Ubuntu 22.04, which is the first version with a
7+
# glibc that supports 64-bit time_t. See https://github.com/dotnet/core/discussions/9285.
8+
RUN /scripts/eng/common/cross/build-rootfs.sh arm jammy no-lldb --skipunmount
9+
10+
RUN TARGET_TRIPLE="arm-linux-gnueabihf" && \
11+
CLANG_MAJOR_VERSION=$(clang --version | grep -oP "(?<=version )\d+") && \
12+
cmake -S llvm-project.src/runtimes -B runtimes \
13+
-DCMAKE_BUILD_TYPE=Release \
14+
-DCMAKE_ASM_COMPILER=clang \
15+
-DCMAKE_C_COMPILER=clang \
16+
-DCMAKE_CXX_COMPILER=clang++ \
17+
-DCMAKE_ASM_COMPILER_TARGET="$TARGET_TRIPLE" \
18+
-DCMAKE_C_COMPILER_TARGET="$TARGET_TRIPLE" \
19+
-DCMAKE_CXX_COMPILER_TARGET="$TARGET_TRIPLE" \
20+
# We're going to link the static libraries we build here into PIC images, so build the static libraries as PIC.
21+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
22+
-DCMAKE_SYSROOT="$ROOTFS_DIR" \
23+
# Specify linker to use for exes directly for CMake toolchain detection
24+
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
25+
# Don't search for tools in the sysroot as we're cross-compiling
26+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="NEVER" \
27+
-DLLVM_USE_LINKER=lld \
28+
-DLLVM_ENABLE_RUNTIMES="libcxx;compiler-rt" \
29+
-DLIBCXX_ENABLE_SHARED=OFF \
30+
-DLIBCXX_CXX_ABI=libstdc++ \
31+
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="$ROOTFS_DIR/usr/include/c++/11/;$ROOTFS_DIR/usr/include/$TARGET_TRIPLE" \
32+
-DCOMPILER_RT_CXX_LIBRARY="libcxx" \
33+
-DCOMPILER_RT_STATIC_CXX_LIBRARY=ON \
34+
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
35+
-DCOMPILER_RT_BUILD_MEMPROF=OFF \
36+
# The libfuzzer build in LLVM doesn't correctly forward the required CMake properties to the "fuzzed libc++" build
37+
# so skip it here.
38+
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
39+
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
40+
-DCOMPILER_RT_INSTALL_PATH="/usr/local/lib/clang/$CLANG_MAJOR_VERSION" && \
41+
cmake --build runtimes -j $(getconf _NPROCESSORS_ONLN) && \
42+
cmake --install runtimes --prefix "$ROOTFS_DIR/usr"
43+
44+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-llvm-amd64
45+
ARG ROOTFS_DIR
46+
47+
COPY --from=builder /usr/local/lib/clang /usr/local/lib/clang/
48+
COPY --from=builder $ROOTFS_DIR $ROOTFS_DIR
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ARG ROOTFS_DIR=/crossrootfs/arm64
2+
3+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-builder-amd64 AS builder
4+
ARG ROOTFS_DIR
5+
6+
RUN /scripts/eng/common/cross/build-rootfs.sh arm64 alpine3.17 --skipunmount
7+
8+
RUN TARGET_TRIPLE="aarch64-alpine-linux-musl" && \
9+
cmake -S llvm-project.src/runtimes -B runtimes \
10+
-DCMAKE_BUILD_TYPE=Release \
11+
-DCMAKE_ASM_COMPILER=clang \
12+
-DCMAKE_C_COMPILER=clang \
13+
-DCMAKE_CXX_COMPILER=clang++ \
14+
-DCMAKE_ASM_COMPILER_TARGET="$TARGET_TRIPLE" \
15+
-DCMAKE_C_COMPILER_TARGET="$TARGET_TRIPLE" \
16+
-DCMAKE_CXX_COMPILER_TARGET="$TARGET_TRIPLE" \
17+
# We're going to link the static libraries we build here into PIC images, so build the static libraries as PIC.
18+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
19+
-DCMAKE_SYSROOT="$ROOTFS_DIR" \
20+
# Specify linker to use for exes directly for CMake toolchain detection
21+
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
22+
# Don't search for tools in the sysroot as we're cross-compiling
23+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="NEVER" \
24+
-DLLVM_USE_LINKER=lld \
25+
-DLLVM_ENABLE_RUNTIMES="libcxx" \
26+
-DLIBCXX_ENABLE_SHARED=OFF \
27+
-DLIBCXX_HAS_MUSL_LIBC=ON \
28+
-DLIBCXX_CXX_ABI=libstdc++ \
29+
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="$ROOTFS_DIR/usr/include/c++/12.2.1/;$ROOTFS_DIR/usr/include/c++/12.2.1/$TARGET_TRIPLE" && \
30+
cmake --build runtimes -j $(getconf _NPROCESSORS_ONLN) && \
31+
cmake --install runtimes --prefix "$ROOTFS_DIR/usr"
32+
33+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-llvm-amd64
34+
ARG ROOTFS_DIR
35+
36+
COPY --from=builder $ROOTFS_DIR $ROOTFS_DIR
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
ARG ROOTFS_DIR=/crossrootfs/arm64
2+
3+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-builder-amd64 AS builder
4+
ARG ROOTFS_DIR
5+
6+
RUN /scripts/eng/common/cross/build-rootfs.sh arm64 bionic --skipunmount
7+
8+
RUN TARGET_TRIPLE="aarch64-linux-gnu" && \
9+
CLANG_MAJOR_VERSION=$(clang --version | grep -oP "(?<=version )\d+") && \
10+
cmake -S llvm-project.src/runtimes -B runtimes \
11+
-DCMAKE_BUILD_TYPE=Release \
12+
-DCMAKE_ASM_COMPILER=clang \
13+
-DCMAKE_C_COMPILER=clang \
14+
-DCMAKE_CXX_COMPILER=clang++ \
15+
-DCMAKE_ASM_COMPILER_TARGET="$TARGET_TRIPLE" \
16+
-DCMAKE_C_COMPILER_TARGET="$TARGET_TRIPLE" \
17+
-DCMAKE_CXX_COMPILER_TARGET="$TARGET_TRIPLE" \
18+
# We're going to link the static libraries we build here into PIC images, so build the static libraries as PIC.
19+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
20+
-DCMAKE_SYSROOT="$ROOTFS_DIR" \
21+
# Specify linker to use for exes directly for CMake toolchain detection
22+
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
23+
# Don't search for tools in the sysroot as we're cross-compiling
24+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="NEVER" \
25+
-DLLVM_USE_LINKER=lld \
26+
-DLLVM_ENABLE_RUNTIMES="libcxx;compiler-rt" \
27+
-DLIBCXX_ENABLE_SHARED=OFF \
28+
-DLIBCXXABI_ENABLE_SHARED=OFF \
29+
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF \
30+
-DLIBCXX_CXX_ABI=libstdc++ \
31+
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="$ROOTFS_DIR/usr/include/c++/7.5.0/;$ROOTFS_DIR/usr/include/$TARGET_TRIPLE" \
32+
-DCOMPILER_RT_CXX_LIBRARY="libcxx" \
33+
-DCOMPILER_RT_STATIC_CXX_LIBRARY=ON \
34+
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
35+
-DCOMPILER_RT_BUILD_MEMPROF=OFF \
36+
# The libfuzzer build in LLVM doesn't correctly forward the required CMake properties to the "fuzzed libc++" build
37+
# so skip it here.
38+
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
39+
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
40+
-DCOMPILER_RT_INSTALL_PATH="/usr/local/lib/clang/$CLANG_MAJOR_VERSION" && \
41+
cmake --build runtimes -j $(getconf _NPROCESSORS_ONLN) && \
42+
cmake --install runtimes --prefix "$ROOTFS_DIR/usr"
43+
44+
FROM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-crossdeps-llvm-amd64
45+
ARG ROOTFS_DIR
46+
47+
COPY --from=builder /usr/local/lib/clang /usr/local/lib/clang/
48+
COPY --from=builder $ROOTFS_DIR $ROOTFS_DIR

0 commit comments

Comments
 (0)