Skip to content

Commit

Permalink
feat: add loongarch64-unknown-linux-musl image (#1557)
Browse files Browse the repository at this point in the history
Close #1556
  • Loading branch information
Emilgardis authored Sep 23, 2024
2 parents d8631fe + 860ae2e commit 8ee2c4c
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/1557.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "added",
"description": "add loongarch64-linux-musl support",
"issues": [1556]
}
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/b_issue_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ body:
- i686-unknown-linux-gnu
- i686-unknown-linux-musl
- loongarch64-unknown-linux-gnu
- loongarch64-unknown-linux-musl
- mips64el-unknown-linux-gnuabi64
- mips64el-unknown-linux-muslabi64
- mips64-unknown-linux-gnuabi64
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ terminate.
| `i686-pc-windows-gnu` | N/A | 9.4 || N/A ||
| `i686-unknown-linux-gnu` | 2.31 | 9.4.0 || 6.1.0 ||
| `loongarch64-unknown-linux-gnu` | 2.36 | 14.2.0 || 8.2.2 ||
| `loongarch64-unknown-linux-musl` | 1.2.5 | 14.2.0 || 8.2.2 ||
| `mips-unknown-linux-gnu` | 2.30 | 9.4.0 || 6.1.0 ||
| `mips-unknown-linux-musl` | 1.2.3 | 9.2.0 || 6.1.0 ||
| `mips64-unknown-linux-gnuabi64` | 2.30 | 9.4.0 || 6.1.0 ||
Expand Down
16 changes: 16 additions & 0 deletions crosstool-ng/loongarch64-unknown-linux-musl.config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CT_CONFIG_VERSION="4"
CT_EXPERIMENTAL=y
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_ARCH_LOONGARCH=y
# CT_DEMULTILIB is not set
CT_ARCH_USE_MMU=y
CT_ARCH_ARCH="loongarch64"
CT_KERNEL_LINUX=y
%CT_LINUX_V%
%CT_LINUX%
CT_LIBC_MUSL=y
%CT_MUSL_V%
%CT_GCC_V%
%CT_GCC%
CT_CC_GCC_ENABLE_DEFAULT_PIE=y
CT_CC_LANG_CXX=y
48 changes: 48 additions & 0 deletions docker/Dockerfile.loongarch64-unknown-linux-musl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM ubuntu:20.04 as cross-base
ENV DEBIAN_FRONTEND=noninteractive

COPY common.sh lib.sh /
RUN /common.sh

COPY cmake.sh /
RUN /cmake.sh

COPY xargo.sh /
RUN /xargo.sh

FROM cross-base as build

ARG VERBOSE
COPY crosstool-ng.sh /
COPY crosstool-config/loongarch64-unknown-linux-musl.config /
RUN /crosstool-ng.sh loongarch64-unknown-linux-musl.config 5 ed12fa68402f58e171a6f79500f73f4781fdc9e5

ENV PATH /x-tools/loongarch64-unknown-linux-musl/bin/:$PATH

COPY deny-debian-packages.sh /
RUN TARGET_ARCH=loong64 /deny-debian-packages.sh

COPY qemu.sh /
RUN /qemu.sh loongarch64

COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake

ENV CROSS_TOOLCHAIN_PREFIX=loongarch64-unknown-linux-musl-
ENV CROSS_SYSROOT=/x-tools/loongarch64-unknown-linux-musl/loongarch64-unknown-linux-musl/sysroot/
ENV CROSS_TARGET_RUNNER="/qemu-runner loongarch64"
ENV CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_RUNNER="$CROSS_TARGET_RUNNER" \
AR_loongarch64_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_loongarch64_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_loongarch64_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_loongarch64_unknown_linux_musl=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_loongarch64_unknown_linux_musl="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=loongarch64 \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"

RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
37 changes: 37 additions & 0 deletions docker/crosstool-config/loongarch64-unknown-linux-musl.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
CT_CONFIG_VERSION="4"
CT_EXPERIMENTAL=y
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_ARCH_LOONGARCH=y
# CT_DEMULTILIB is not set
CT_ARCH_USE_MMU=y
CT_ARCH_ARCH="loongarch64"
CT_KERNEL_LINUX=y
CT_LINUX_V_5_19=y
# CT_LINUX_NO_VERSIONS is not set
CT_LINUX_VERSION="5.19.16"
CT_LINUX_later_than_4_8=y
CT_LINUX_4_8_or_later=y
CT_LINUX_later_than_3_7=y
CT_LINUX_3_7_or_later=y
CT_LINUX_later_than_3_2=y
CT_LINUX_3_2_or_later=y
CT_LIBC_MUSL=y
CT_MUSL_V_1_2_5=y
# CT_MUSL_NO_VERSIONS is not set
CT_MUSL_VERSION="1.2.5"
CT_GCC_V_14=y
# CT_GCC_NO_VERSIONS is not set
CT_GCC_VERSION="14.2.0"
CT_GCC_later_than_7=y
CT_GCC_7_or_later=y
CT_GCC_later_than_6=y
CT_GCC_6_or_later=y
CT_GCC_later_than_5=y
CT_GCC_5_or_later=y
CT_GCC_later_than_4_9=y
CT_GCC_4_9_or_later=y
CT_GCC_later_than_4_8=y
CT_GCC_4_8_or_later=y
CT_CC_GCC_ENABLE_DEFAULT_PIE=y
CT_CC_LANG_CXX=y

5 changes: 5 additions & 0 deletions src/docker/provided_images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ pub static PROVIDED_IMAGES: &[ProvidedImage] = &[
platforms: &[ImagePlatform::X86_64_UNKNOWN_LINUX_GNU],
sub: None
},
ProvidedImage {
name: "loongarch64-unknown-linux-musl",
platforms: &[ImagePlatform::X86_64_UNKNOWN_LINUX_GNU],
sub: None
},
ProvidedImage {
name: "mips-unknown-linux-gnu",
platforms: &[ImagePlatform::X86_64_UNKNOWN_LINUX_GNU],
Expand Down
9 changes: 9 additions & 0 deletions targets.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ std = true
run = true
runners = "qemu-user"

[[target]]
target = "loongarch64-unknown-linux-musl"
os = "ubuntu-latest"
cpp = true
dylib = true
std = true
run = true
runners = "qemu-user"

[[target]]
target = "mips-unknown-linux-gnu"
os = "ubuntu-latest"
Expand Down

0 comments on commit 8ee2c4c

Please sign in to comment.