From 171d4cd6f081eba579253872af9603de025745ad Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Fri, 2 Feb 2024 16:04:37 +0000 Subject: [PATCH] Promote OpenHarmony targets to tier 2 MCP: rust-lang/compiler-team#719 --- .github/workflows/ci.yml | 3 + .../docker/host-x86_64/dist-ohos/Dockerfile | 57 +++++++++++++++++++ src/ci/docker/scripts/ohos-sdk.sh | 9 +++ .../aarch64-unknown-linux-ohos-clang++.sh | 6 ++ .../ohos/aarch64-unknown-linux-ohos-clang.sh | 6 ++ .../ohos/armv7-unknown-linux-ohos-clang++.sh | 10 ++++ .../ohos/armv7-unknown-linux-ohos-clang.sh | 10 ++++ .../ohos/x86_64-unknown-linux-ohos-clang++.sh | 6 ++ .../ohos/x86_64-unknown-linux-ohos-clang.sh | 6 ++ src/ci/github-actions/ci.yml | 3 + src/doc/rustc/src/platform-support.md | 3 + .../rustc/src/platform-support/openharmony.md | 3 +- src/tools/build-manifest/src/main.rs | 3 + 13 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 src/ci/docker/host-x86_64/dist-ohos/Dockerfile create mode 100755 src/ci/docker/scripts/ohos-sdk.sh create mode 100755 src/ci/docker/scripts/ohos/aarch64-unknown-linux-ohos-clang++.sh create mode 100755 src/ci/docker/scripts/ohos/aarch64-unknown-linux-ohos-clang.sh create mode 100755 src/ci/docker/scripts/ohos/armv7-unknown-linux-ohos-clang++.sh create mode 100755 src/ci/docker/scripts/ohos/armv7-unknown-linux-ohos-clang.sh create mode 100755 src/ci/docker/scripts/ohos/x86_64-unknown-linux-ohos-clang++.sh create mode 100755 src/ci/docker/scripts/ohos/x86_64-unknown-linux-ohos-clang.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf44456b28749..fbaa2fa6b0141 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -221,6 +221,9 @@ jobs: - name: dist-mipsel-linux os: ubuntu-20.04-xl env: {} + - name: dist-ohos + os: ubuntu-20.04-8core-32gb + env: {} - name: dist-powerpc-linux os: ubuntu-20.04-xl env: {} diff --git a/src/ci/docker/host-x86_64/dist-ohos/Dockerfile b/src/ci/docker/host-x86_64/dist-ohos/Dockerfile new file mode 100644 index 0000000000000..6dff3095b46af --- /dev/null +++ b/src/ci/docker/host-x86_64/dist-ohos/Dockerfile @@ -0,0 +1,57 @@ +FROM ubuntu:23.04 + +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + make \ + ninja-build \ + file \ + curl \ + ca-certificates \ + python3 \ + git \ + cmake \ + sudo \ + gdb \ + libssl-dev \ + pkg-config \ + xz-utils \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +COPY scripts/ohos-sdk.sh /scripts/ +RUN sh /scripts/ohos-sdk.sh + +COPY scripts/ohos/aarch64-unknown-linux-ohos-clang.sh /usr/local/bin/ +COPY scripts/ohos/aarch64-unknown-linux-ohos-clang++.sh /usr/local/bin/ +COPY scripts/ohos/armv7-unknown-linux-ohos-clang.sh /usr/local/bin/ +COPY scripts/ohos/armv7-unknown-linux-ohos-clang++.sh /usr/local/bin/ +COPY scripts/ohos/x86_64-unknown-linux-ohos-clang.sh /usr/local/bin/ +COPY scripts/ohos/x86_64-unknown-linux-ohos-clang++.sh /usr/local/bin/ + +# env +ENV TARGETS=aarch64-unknown-linux-ohos +ENV TARGETS=$TARGETS,armv7-unknown-linux-ohos +ENV TARGETS=$TARGETS,x86_64-unknown-linux-ohos + +ENV \ + CC_aarch64_unknown_linux_ohos=/usr/local/bin/aarch64-unknown-linux-ohos-clang.sh \ + AR_aarch64_unknown_linux_ohos=/opt/ohos-sdk/native/llvm/bin/llvm-ar \ + CXX_aarch64_unknown_linux_ohos=/usr/local/bin/aarch64-unknown-linux-ohos-clang++.sh +ENV \ + CC_armv7_unknown_linux_ohos=/usr/local/bin/armv7-unknown-linux-ohos-clang.sh \ + AR_armv7_unknown_linux_ohos=/opt/ohos-sdk/native/llvm/bin/llvm-ar \ + CXX_armv7_unknown_linux_ohos=/usr/local/bin/armv7-unknown-linux-ohos-clang++.sh +ENV \ + CC_x86_64_unknown_linux_ohos=/usr/local/bin/x86_64-unknown-linux-ohos-clang.sh \ + AR_x86_64_unknown_linux_ohos=/opt/ohos-sdk/native/llvm/bin/llvm-ar \ + CXX_x86_64_unknown_linux_ohos=/usr/local/bin/x86_64-unknown-linux-ohos-clang++.sh + +ENV RUST_CONFIGURE_ARGS \ + --enable-profiler \ + --disable-docs + +ENV SCRIPT python3 ../x.py dist --host='' --target $TARGETS + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh diff --git a/src/ci/docker/scripts/ohos-sdk.sh b/src/ci/docker/scripts/ohos-sdk.sh new file mode 100755 index 0000000000000..321be2b8697b0 --- /dev/null +++ b/src/ci/docker/scripts/ohos-sdk.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -ex + +URL=https://repo.huaweicloud.com/openharmony/os/4.0-Release/ohos-sdk-windows_linux-public.tar.gz + +curl $URL | tar xz -C /tmp ohos-sdk/linux/native-linux-x64-4.0.10.13-Release.zip +mkdir /opt/ohos-sdk +cd /opt/ohos-sdk +unzip -qq /tmp/ohos-sdk/linux/native-linux-x64-4.0.10.13-Release.zip diff --git a/src/ci/docker/scripts/ohos/aarch64-unknown-linux-ohos-clang++.sh b/src/ci/docker/scripts/ohos/aarch64-unknown-linux-ohos-clang++.sh new file mode 100755 index 0000000000000..5dfb4c72ffea8 --- /dev/null +++ b/src/ci/docker/scripts/ohos/aarch64-unknown-linux-ohos-clang++.sh @@ -0,0 +1,6 @@ +#!/bin/sh +exec /opt/ohos-sdk/native/llvm/bin/clang++ \ + -target aarch64-linux-ohos \ + --sysroot=/opt/ohos-sdk/native/sysroot \ + -D__MUSL__ \ + "$@" diff --git a/src/ci/docker/scripts/ohos/aarch64-unknown-linux-ohos-clang.sh b/src/ci/docker/scripts/ohos/aarch64-unknown-linux-ohos-clang.sh new file mode 100755 index 0000000000000..972e564fffbd7 --- /dev/null +++ b/src/ci/docker/scripts/ohos/aarch64-unknown-linux-ohos-clang.sh @@ -0,0 +1,6 @@ +#!/bin/sh +exec /opt/ohos-sdk/native/llvm/bin/clang \ + -target aarch64-linux-ohos \ + --sysroot=/opt/ohos-sdk/native/sysroot \ + -D__MUSL__ \ + "$@" diff --git a/src/ci/docker/scripts/ohos/armv7-unknown-linux-ohos-clang++.sh b/src/ci/docker/scripts/ohos/armv7-unknown-linux-ohos-clang++.sh new file mode 100755 index 0000000000000..d8f99b3d0cd5c --- /dev/null +++ b/src/ci/docker/scripts/ohos/armv7-unknown-linux-ohos-clang++.sh @@ -0,0 +1,10 @@ +#!/bin/sh +exec /opt/ohos-sdk/native/llvm/bin/clang++ \ + -target arm-linux-ohos \ + --sysroot=/opt/ohos-sdk/native/sysroot \ + -D__MUSL__ \ + -march=armv7-a \ + -mfloat-abi=softfp \ + -mtune=generic-armv7-a \ + -mthumb \ + "$@" diff --git a/src/ci/docker/scripts/ohos/armv7-unknown-linux-ohos-clang.sh b/src/ci/docker/scripts/ohos/armv7-unknown-linux-ohos-clang.sh new file mode 100755 index 0000000000000..fe92ec41b788c --- /dev/null +++ b/src/ci/docker/scripts/ohos/armv7-unknown-linux-ohos-clang.sh @@ -0,0 +1,10 @@ +#!/bin/sh +exec /opt/ohos-sdk/native/llvm/bin/clang \ + -target arm-linux-ohos \ + --sysroot=/opt/ohos-sdk/native/sysroot \ + -D__MUSL__ \ + -march=armv7-a \ + -mfloat-abi=softfp \ + -mtune=generic-armv7-a \ + -mthumb \ + "$@" diff --git a/src/ci/docker/scripts/ohos/x86_64-unknown-linux-ohos-clang++.sh b/src/ci/docker/scripts/ohos/x86_64-unknown-linux-ohos-clang++.sh new file mode 100755 index 0000000000000..a45df15b1bfd2 --- /dev/null +++ b/src/ci/docker/scripts/ohos/x86_64-unknown-linux-ohos-clang++.sh @@ -0,0 +1,6 @@ +#!/bin/sh +exec /opt/ohos-sdk/native/llvm/bin/clang++ \ + -target x86_64-linux-ohos \ + --sysroot=/opt/ohos-sdk/native/sysroot \ + -D__MUSL__ \ + "$@" diff --git a/src/ci/docker/scripts/ohos/x86_64-unknown-linux-ohos-clang.sh b/src/ci/docker/scripts/ohos/x86_64-unknown-linux-ohos-clang.sh new file mode 100755 index 0000000000000..3bf4c5777f113 --- /dev/null +++ b/src/ci/docker/scripts/ohos/x86_64-unknown-linux-ohos-clang.sh @@ -0,0 +1,6 @@ +#!/bin/sh +exec /opt/ohos-sdk/native/llvm/bin/clang \ + -target x86_64-linux-ohos \ + --sysroot=/opt/ohos-sdk/native/sysroot \ + -D__MUSL__ \ + "$@" diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index 4a3a609d2e8b9..cbe98215b6aac 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -369,6 +369,9 @@ jobs: - name: dist-mipsel-linux <<: *job-linux-xl + - name: dist-ohos + <<: *job-linux-8c + - name: dist-powerpc-linux <<: *job-linux-xl diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 46bdd1ab91f6b..e5562e4bf2f09 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -128,6 +128,7 @@ target | std | notes `aarch64-fuchsia` | ✓ | Alias for `aarch64-unknown-fuchsia` `aarch64-unknown-fuchsia` | ✓ | ARM64 Fuchsia [`aarch64-linux-android`](platform-support/android.md) | ✓ | ARM64 Android +[`aarch64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | ARM64 OpenHarmony `aarch64-unknown-none-softfloat` | * | Bare ARM64, softfloat `aarch64-unknown-none` | * | Bare ARM64, hardfloat [`aarch64-unknown-uefi`](platform-support/unknown-uefi.md) | * | ARM64 UEFI @@ -142,6 +143,7 @@ target | std | notes `armv7-unknown-linux-gnueabi` | ✓ |ARMv7 Linux (kernel 4.15, glibc 2.27) `armv7-unknown-linux-musleabi` | ✓ |ARMv7 Linux with MUSL `armv7-unknown-linux-musleabihf` | ✓ | ARMv7 Linux with MUSL, hardfloat +[`armv7-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | ARMv7-A OpenHarmony `armv7a-none-eabi` | * | Bare ARMv7-A `armv7r-none-eabi` | * | Bare ARMv7-R `armv7r-none-eabihf` | * | Bare ARMv7-R, hardfloat @@ -187,6 +189,7 @@ target | std | notes [`x86_64-linux-android`](platform-support/android.md) | ✓ | 64-bit x86 Android `x86_64-pc-solaris` | ✓ | 64-bit Solaris 10/11, illumos `x86_64-unknown-linux-gnux32` | ✓ | 64-bit Linux (x32 ABI) (kernel 4.15, glibc 2.27) +[`x86_64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | x86_64 OpenHarmony [`x86_64-unknown-none`](platform-support/x86_64-unknown-none.md) | * | Freestanding/bare-metal x86_64, softfloat `x86_64-unknown-redox` | ✓ | Redox OS [`x86_64-unknown-uefi`](platform-support/unknown-uefi.md) | * | 64-bit UEFI diff --git a/src/doc/rustc/src/platform-support/openharmony.md b/src/doc/rustc/src/platform-support/openharmony.md index aa4debfd45a33..970901f39b937 100644 --- a/src/doc/rustc/src/platform-support/openharmony.md +++ b/src/doc/rustc/src/platform-support/openharmony.md @@ -1,6 +1,6 @@ # `*-linux-ohos*` -**Tier: 3** +**Tier: 2** Targets for the [OpenHarmony](https://gitee.com/openharmony/docs/) operating system. @@ -8,6 +8,7 @@ system. ## Target maintainers - Amanieu d'Antras ([@Amanieu](https://github.com/Amanieu)) +- Lu Binglun ([@lubinglun](https://github.com/lubinglun)) ## Setup diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 5f5581c13ef1a..4bd27ae203a2f 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -58,6 +58,7 @@ static TARGETS: &[&str] = &[ "aarch64-unknown-hermit", "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", + "aarch64-unknown-linux-ohos", "aarch64-unknown-none", "aarch64-unknown-none-softfloat", "aarch64-unknown-redox", @@ -78,6 +79,7 @@ static TARGETS: &[&str] = &[ "thumbv7neon-unknown-linux-gnueabihf", "armv7-unknown-linux-musleabi", "armv7-unknown-linux-musleabihf", + "armv7-unknown-linux-ohos", "armebv7r-none-eabi", "armebv7r-none-eabihf", "armv7r-none-eabi", @@ -153,6 +155,7 @@ static TARGETS: &[&str] = &[ "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-gnux32", "x86_64-unknown-linux-musl", + "x86_64-unknown-linux-ohos", "x86_64-unknown-netbsd", "x86_64-unknown-none", "x86_64-unknown-redox",