From 6324b398735961c4636fd41d5044a196063d5efa Mon Sep 17 00:00:00 2001 From: LuuuXXX Date: Wed, 12 Feb 2025 10:24:57 +0800 Subject: [PATCH 1/8] promote ohos targets to tier to with host tools --- Cargo.lock | 21 +++++++++++++++---- compiler/rustc_codegen_llvm/Cargo.toml | 3 ++- compiler/rustc_data_structures/Cargo.toml | 3 ++- compiler/rustc_llvm/build.rs | 3 ++- compiler/rustc_query_impl/Cargo.toml | 4 ++-- src/bootstrap/src/core/build_steps/llvm.rs | 4 ++++ .../docker/host-x86_64/dist-ohos/Dockerfile | 13 +++++++++++- src/ci/docker/scripts/ohos-openssl.sh | 7 +++++++ src/ci/docker/scripts/ohos-sdk.sh | 6 +++--- src/doc/rustc/src/platform-support.md | 6 +++--- 10 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 src/ci/docker/scripts/ohos-openssl.sh diff --git a/Cargo.lock b/Cargo.lock index 72f2d4f6cd3..ea5d9bffefb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2178,6 +2178,20 @@ dependencies = [ "smallvec", ] +[[package]] +name = "measureme-mirror" +version = "12.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe110855993552cfa51a5018e8cdf2acf7f948c46136322017a9a8484ffc5ea8" +dependencies = [ + "log", + "memmap2", + "parking_lot", + "perf-event-open-sys", + "rustc-hash 1.1.0", + "smallvec", +] + [[package]] name = "memchr" version = "2.7.4" @@ -3365,7 +3379,7 @@ dependencies = [ "gimli 0.30.0", "itertools", "libc", - "measureme", + "measureme-mirror", "object 0.36.7", "rustc-demangle", "rustc_abi", @@ -3483,7 +3497,7 @@ dependencies = [ "indexmap", "jobserver", "libc", - "measureme", + "measureme-mirror", "memmap2", "parking_lot", "portable-atomic", @@ -4249,8 +4263,7 @@ dependencies = [ name = "rustc_query_impl" version = "0.0.0" dependencies = [ - "measureme", - "rustc_attr_data_structures", + "measureme-mirror", "rustc_data_structures", "rustc_errors", "rustc_hashes", diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index d3ce7c5a113..1122883914d 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -14,7 +14,8 @@ bitflags = "2.4.1" gimli = "0.30" itertools = "0.12" libc = "0.2" -measureme = "11" +# FIXME: waiting for the new version of measureme. (https://github.com/rust-lang/measureme/pull/240) +measureme = { package = "measureme-mirror", version = "12.0.1" } object = { version = "0.36.3", default-features = false, features = ["std", "read"] } rustc-demangle = "0.1.21" rustc_abi = { path = "../rustc_abi" } diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml index bdf5494f210..6629f2a7516 100644 --- a/compiler/rustc_data_structures/Cargo.toml +++ b/compiler/rustc_data_structures/Cargo.toml @@ -12,7 +12,8 @@ elsa = "1.11.0" ena = "0.14.3" indexmap = "2.4.0" jobserver_crate = { version = "0.1.28", package = "jobserver" } -measureme = "11" +# FIXME: waiting for the new version of measureme. (https://github.com/rust-lang/measureme/pull/240) +measureme = { package = "measureme-mirror", version = "12.0.1" } rustc-hash = "2.0.0" rustc-rayon = { version = "0.5.1", features = ["indexmap"] } rustc-stable-hash = { version = "0.1.0", features = ["nightly"] } diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index 3d1f3b2cd4d..6692ea73540 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -241,7 +241,7 @@ fn main() { println!("cargo:rustc-link-lib=kstat"); } - if (target.starts_with("arm") && !target.contains("freebsd")) + if (target.starts_with("arm") && !target.contains("freebsd")) && !target.contains("ohos") || target.starts_with("mips-") || target.starts_with("mipsel-") || target.starts_with("powerpc-") @@ -371,6 +371,7 @@ fn main() { || target.contains("freebsd") || target.contains("windows-gnullvm") || target.contains("aix") + || target.contains("ohos") { "c++" } else if target.contains("netbsd") && llvm_static_stdcpp.is_some() { diff --git a/compiler/rustc_query_impl/Cargo.toml b/compiler/rustc_query_impl/Cargo.toml index c85156e059e..14a7391f108 100644 --- a/compiler/rustc_query_impl/Cargo.toml +++ b/compiler/rustc_query_impl/Cargo.toml @@ -5,8 +5,8 @@ edition = "2024" [dependencies] # tidy-alphabetical-start -measureme = "11" -rustc_attr_data_structures = { path = "../rustc_attr_data_structures" } +# FIXME: waiting for the new version of measureme. (https://github.com/rust-lang/measureme/pull/240) +measureme = { package = "measureme-mirror", version = "12.0.1" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } rustc_hashes = { path = "../rustc_hashes" } diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 40d701f22c1..5919e989b34 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -471,6 +471,10 @@ impl Step for Llvm { cfg.define("LLVM_BUILD_32_BITS", "ON"); } + if target.starts_with("x86_64") && target.contains("ohos") { + cfg.define("LLVM_TOOL_LLVM_RTDYLD_BUILD", "OFF"); + } + let mut enabled_llvm_projects = Vec::new(); if helpers::forcing_clang_based_tests() { diff --git a/src/ci/docker/host-x86_64/dist-ohos/Dockerfile b/src/ci/docker/host-x86_64/dist-ohos/Dockerfile index bbbf0b3adf2..23c0c8b49d2 100644 --- a/src/ci/docker/host-x86_64/dist-ohos/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-ohos/Dockerfile @@ -22,6 +22,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ COPY scripts/ohos-sdk.sh /scripts/ RUN sh /scripts/ohos-sdk.sh +COPY scripts/ohos-openssl.sh /scripts/ +RUN sh /scripts/ohos-openssl.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/ @@ -30,6 +33,14 @@ 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 AARCH64_UNKNOWN_LINUX_OHOS_OPENSSL_DIR=/opt/ohos-openssl/prelude/arm64-v8a +ENV ARMV7_UNKNOWN_LINUX_OHOS_OPENSSL_DIR=/opt/ohos-openssl/prelude/armeabi-v7a +ENV X86_64_UNKNOWN_LINUX_OHOS_OPENSSL_DIR=/opt/ohos-openssl/prelude/x86_64 + +ENV AARCH64_UNKNOWN_LINUX_OHOS_OPENSSL_NO_VENDOR=1 +ENV ARMV7_UNKNOWN_LINUX_OHOS_OPENSSL_NO_VENDOR=1 +ENV X86_64_UNKNOWN_LINUX_OHOS_OPENSSL_NO_VENDOR=1 + ENV TARGETS=aarch64-unknown-linux-ohos ENV TARGETS=$TARGETS,armv7-unknown-linux-ohos ENV TARGETS=$TARGETS,x86_64-unknown-linux-ohos @@ -51,7 +62,7 @@ ENV RUST_CONFIGURE_ARGS \ --enable-profiler \ --disable-docs -ENV SCRIPT python3 ../x.py dist --host='' --target $TARGETS +ENV SCRIPT python3 ../x.py dist --host=$TARGETS --target $TARGETS COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh diff --git a/src/ci/docker/scripts/ohos-openssl.sh b/src/ci/docker/scripts/ohos-openssl.sh new file mode 100644 index 00000000000..713ab6131e3 --- /dev/null +++ b/src/ci/docker/scripts/ohos-openssl.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -ex + +URL=https://github.com/ohos-rs/ohos-openssl/archive/refs/tags/0.1.0.tar.gz + +mkdir -p /opt/ohos-openssl +curl -fL $URL | tar xz -C /opt/ohos-openssl --strip-components=1 diff --git a/src/ci/docker/scripts/ohos-sdk.sh b/src/ci/docker/scripts/ohos-sdk.sh index 321be2b8697..0b62e49f7ca 100755 --- a/src/ci/docker/scripts/ohos-sdk.sh +++ b/src/ci/docker/scripts/ohos-sdk.sh @@ -1,9 +1,9 @@ #!/bin/sh set -ex -URL=https://repo.huaweicloud.com/openharmony/os/4.0-Release/ohos-sdk-windows_linux-public.tar.gz +URL=https://repo.huaweicloud.com/openharmony/os/5.0.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 +curl $URL | tar xz -C /tmp linux/native-linux-x64-5.0.0.71-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 +unzip -qq /tmp/linux/native-linux-x64-5.0.0.71-Release.zip diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index c4e5c1aac2f..a98c6f8d861 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -89,9 +89,11 @@ target | notes -------|------- `aarch64-pc-windows-msvc` | ARM64 Windows MSVC `aarch64-unknown-linux-musl` | ARM64 Linux with musl 1.2.3 +[`aarch64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | ARM64 OpenHarmony `arm-unknown-linux-gnueabi` | Armv6 Linux (kernel 3.2, glibc 2.17) `arm-unknown-linux-gnueabihf` | Armv6 Linux, hardfloat (kernel 3.2, glibc 2.17) `armv7-unknown-linux-gnueabihf` | Armv7-A Linux, hardfloat (kernel 3.2, glibc 2.17) +[`armv7-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | Armv7-A OpenHarmony [`loongarch64-unknown-linux-gnu`](platform-support/loongarch-linux.md) | LoongArch64 Linux, LP64D ABI (kernel 5.19, glibc 2.36) [`loongarch64-unknown-linux-musl`](platform-support/loongarch-linux.md) | LoongArch64 Linux, LP64D ABI (kernel 5.19, musl 1.2.5) `powerpc-unknown-linux-gnu` | PowerPC Linux (kernel 3.2, glibc 2.17) @@ -104,6 +106,7 @@ target | notes [`x86_64-unknown-freebsd`](platform-support/freebsd.md) | 64-bit x86 FreeBSD [`x86_64-unknown-illumos`](platform-support/illumos.md) | illumos `x86_64-unknown-linux-musl` | 64-bit Linux with musl 1.2.3 +[`x86_64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | x86_64 OpenHarmony [`x86_64-unknown-netbsd`](platform-support/netbsd.md) | NetBSD/amd64 ## Tier 2 without Host Tools @@ -142,7 +145,6 @@ target | std | notes [`aarch64-linux-android`](platform-support/android.md) | ✓ | ARM64 Android [`aarch64-pc-windows-gnullvm`](platform-support/pc-windows-gnullvm.md) | ✓ | ARM64 MinGW (Windows 10+), LLVM ABI [`aarch64-unknown-fuchsia`](platform-support/fuchsia.md) | ✓ | ARM64 Fuchsia -[`aarch64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | ARM64 OpenHarmony `aarch64-unknown-none` | * | Bare ARM64, hardfloat `aarch64-unknown-none-softfloat` | * | Bare ARM64, softfloat [`aarch64-unknown-uefi`](platform-support/unknown-uefi.md) | ? | ARM64 UEFI @@ -158,7 +160,6 @@ target | std | notes `armv7-unknown-linux-gnueabi` | ✓ | Armv7-A Linux (kernel 4.15, glibc 2.27) `armv7-unknown-linux-musleabi` | ✓ | Armv7-A Linux with musl 1.2.3 `armv7-unknown-linux-musleabihf` | ✓ | Armv7-A Linux with musl 1.2.3, hardfloat -[`armv7-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | Armv7-A OpenHarmony [`armv7a-none-eabi`](platform-support/arm-none-eabi.md) | * | Bare Armv7-A [`armv7r-none-eabi`](platform-support/armv7r-none-eabi.md) | * | Bare Armv7-R [`armv7r-none-eabihf`](platform-support/armv7r-none-eabi.md) | * | Bare Armv7-R, hardfloat @@ -205,7 +206,6 @@ target | std | notes [`x86_64-pc-windows-gnullvm`](platform-support/pc-windows-gnullvm.md) | ✓ | 64-bit x86 MinGW (Windows 10+), LLVM ABI [`x86_64-unknown-fuchsia`](platform-support/fuchsia.md) | ✓ | 64-bit x86 Fuchsia `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`](platform-support/redox.md) | ✓ | Redox OS [`x86_64-unknown-uefi`](platform-support/unknown-uefi.md) | ? | 64-bit UEFI From 7279acf2025a5affd51862d126624ed0f49f701b Mon Sep 17 00:00:00 2001 From: LuuuXXX Date: Sat, 15 Feb 2025 09:19:02 +0800 Subject: [PATCH 2/8] use measureme-12.0.1 --- Cargo.lock | 12 ++++++------ compiler/rustc_codegen_llvm/Cargo.toml | 3 +-- compiler/rustc_data_structures/Cargo.toml | 3 +-- compiler/rustc_query_impl/Cargo.toml | 3 +-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ea5d9bffefb..d4ca5ce5d59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2179,10 +2179,10 @@ dependencies = [ ] [[package]] -name = "measureme-mirror" +name = "measureme" version = "12.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe110855993552cfa51a5018e8cdf2acf7f948c46136322017a9a8484ffc5ea8" +checksum = "570a507d8948a66a97f42cbbaf8a6bb9516a51017d4ee949502ad7a10a864395" dependencies = [ "log", "memmap2", @@ -2275,7 +2275,7 @@ dependencies = [ "libc", "libffi", "libloading", - "measureme", + "measureme 11.0.1", "rand 0.9.0", "regex", "rustc_version", @@ -3379,7 +3379,7 @@ dependencies = [ "gimli 0.30.0", "itertools", "libc", - "measureme-mirror", + "measureme 12.0.1", "object 0.36.7", "rustc-demangle", "rustc_abi", @@ -3497,7 +3497,7 @@ dependencies = [ "indexmap", "jobserver", "libc", - "measureme-mirror", + "measureme 12.0.1", "memmap2", "parking_lot", "portable-atomic", @@ -4263,7 +4263,7 @@ dependencies = [ name = "rustc_query_impl" version = "0.0.0" dependencies = [ - "measureme-mirror", + "measureme 12.0.1", "rustc_data_structures", "rustc_errors", "rustc_hashes", diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index 1122883914d..ec1fd4b641a 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -14,8 +14,7 @@ bitflags = "2.4.1" gimli = "0.30" itertools = "0.12" libc = "0.2" -# FIXME: waiting for the new version of measureme. (https://github.com/rust-lang/measureme/pull/240) -measureme = { package = "measureme-mirror", version = "12.0.1" } +measureme = "12.0.1" object = { version = "0.36.3", default-features = false, features = ["std", "read"] } rustc-demangle = "0.1.21" rustc_abi = { path = "../rustc_abi" } diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml index 6629f2a7516..df3bee6ee9c 100644 --- a/compiler/rustc_data_structures/Cargo.toml +++ b/compiler/rustc_data_structures/Cargo.toml @@ -12,8 +12,7 @@ elsa = "1.11.0" ena = "0.14.3" indexmap = "2.4.0" jobserver_crate = { version = "0.1.28", package = "jobserver" } -# FIXME: waiting for the new version of measureme. (https://github.com/rust-lang/measureme/pull/240) -measureme = { package = "measureme-mirror", version = "12.0.1" } +measureme = "12.0.1" rustc-hash = "2.0.0" rustc-rayon = { version = "0.5.1", features = ["indexmap"] } rustc-stable-hash = { version = "0.1.0", features = ["nightly"] } diff --git a/compiler/rustc_query_impl/Cargo.toml b/compiler/rustc_query_impl/Cargo.toml index 14a7391f108..b6773fb460f 100644 --- a/compiler/rustc_query_impl/Cargo.toml +++ b/compiler/rustc_query_impl/Cargo.toml @@ -5,8 +5,7 @@ edition = "2024" [dependencies] # tidy-alphabetical-start -# FIXME: waiting for the new version of measureme. (https://github.com/rust-lang/measureme/pull/240) -measureme = { package = "measureme-mirror", version = "12.0.1" } +measureme = "12.0.1" rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } rustc_hashes = { path = "../rustc_hashes" } From 6efacfb7a59ebde2620398861713fae136060a04 Mon Sep 17 00:00:00 2001 From: LuuuXXX Date: Mon, 24 Feb 2025 11:42:07 +0800 Subject: [PATCH 3/8] add fix for full tools and sanitizer --- Cargo.lock | 20 +++++++++---------- src/bootstrap/src/core/build_steps/llvm.rs | 13 ++++++++++++ .../docker/host-x86_64/dist-ohos/Dockerfile | 5 ++++- .../rustc/src/platform-support/openharmony.md | 13 +++++++++++- src/gcc | 2 +- src/llvm-project | 2 +- src/tools/cargo | 2 +- src/tools/enzyme | 2 +- 8 files changed, 43 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d4ca5ce5d59..05a2534c857 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1997,22 +1997,22 @@ dependencies = [ ] [[package]] -name = "libffi" -version = "3.2.0" +name = "libffi-sys2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce826c243048e3d5cec441799724de52e2d42f820468431fc3fceee2341871e2" +checksum = "47aedd9774ffb3dcab5c96f593cb5a0caf421a5e38b16bab3b8cdef5facb6ea2" dependencies = [ - "libc", - "libffi-sys", + "cc", ] [[package]] -name = "libffi-sys" -version = "2.3.0" +name = "libffi2" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36115160c57e8529781b4183c2bb51fdc1f6d6d1ed345591d84be7703befb3c" +checksum = "c88a3402cad8ff58216ec6d07e5ecfa9e15fc36613c0a832db541e4e1a718a7b" dependencies = [ - "cc", + "libc", + "libffi-sys2", ] [[package]] @@ -2273,7 +2273,7 @@ dependencies = [ "directories", "getrandom 0.3.1", "libc", - "libffi", + "libffi2", "libloading", "measureme 11.0.1", "rand 0.9.0", diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 5919e989b34..6a392b6bd7c 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -814,6 +814,10 @@ fn configure_cmake( cflags.push(s); } + if target.contains("ohos") { + cflags.push(" -D_LINUX_SYSINFO_H"); + } + if builder.config.llvm_clang_cl.is_some() { cflags.push(format!(" --target={target}")); } @@ -834,6 +838,11 @@ fn configure_cmake( cxxflags.push(" "); cxxflags.push(s); } + + if target.contains("ohos") { + cxxflags.push(" -D_LINUX_SYSINFO_H"); + } + if builder.config.llvm_clang_cl.is_some() { cxxflags.push(format!(" --target={target}")); } @@ -1220,6 +1229,10 @@ impl Step for Sanitizers { cfg.define("COMPILER_RT_USE_LIBCXX", "OFF"); cfg.define("LLVM_CONFIG_PATH", &llvm_config); + if self.target.contains("ohos") { + cfg.define("COMPILER_RT_USE_BUILTINS_LIBRARY", "ON"); + } + // On Darwin targets the sanitizer runtimes are build as universal binaries. // Unfortunately sccache currently lacks support to build them successfully. // Disable compiler launcher on Darwin targets to avoid potential issues. diff --git a/src/ci/docker/host-x86_64/dist-ohos/Dockerfile b/src/ci/docker/host-x86_64/dist-ohos/Dockerfile index 23c0c8b49d2..2c514fa0d4d 100644 --- a/src/ci/docker/host-x86_64/dist-ohos/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-ohos/Dockerfile @@ -60,7 +60,10 @@ ENV \ ENV RUST_CONFIGURE_ARGS \ --enable-profiler \ - --disable-docs + --disable-docs \ + --tools=cargo,clippy,rustdocs,rustfmt,rust-analyzer,rust-analyzer-proc-macro-srv,analysis,src,wasm-component-ld \ + --enable-extended \ + --enable-sanitizers ENV SCRIPT python3 ../x.py dist --host=$TARGETS --target $TARGETS diff --git a/src/doc/rustc/src/platform-support/openharmony.md b/src/doc/rustc/src/platform-support/openharmony.md index 1632f44aeec..5988c468a8b 100644 --- a/src/doc/rustc/src/platform-support/openharmony.md +++ b/src/doc/rustc/src/platform-support/openharmony.md @@ -1,6 +1,6 @@ # `*-unknown-linux-ohos` -**Tier: 2** +**Tier: 2(with Host Tools)** * aarch64-unknown-linux-ohos * armv7-unknown-linux-ohos @@ -18,6 +18,17 @@ system. - Amanieu d'Antras ([@Amanieu](https://github.com/Amanieu)) - Lu Binglun ([@lubinglun](https://github.com/lubinglun)) +## Requirements + +All the ohos targets of Tier 2 with host tools support all extended rust tools. +(exclude `miri`, the support of `miri` will be added soon) + +### Host toolchain + +The targets require a reasonably up-to-date OpenHarmony SDK on the host. + +The targets support `cargo`, which require [ohos-openssl](https://github.com/ohos-rs/ohos-openssl). + ## Setup The OpenHarmony SDK doesn't currently support Rust compilation directly, so diff --git a/src/gcc b/src/gcc index 48664a6cab2..fd3498bff0b 160000 --- a/src/gcc +++ b/src/gcc @@ -1 +1 @@ -Subproject commit 48664a6cab29d48138ffa004b7978d52ef73e3ac +Subproject commit fd3498bff0b939dda91d56960acc33d55f2f9cdf diff --git a/src/llvm-project b/src/llvm-project index 1c3bb96fdb6..92e80685d0d 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 1c3bb96fdb6db7b8e8f24edb016099c223fdd27e +Subproject commit 92e80685d0d5dcea3ccf321995c43b72338639c6 diff --git a/src/tools/cargo b/src/tools/cargo index 2622e844bc1..ce948f4616e 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 2622e844bc1e2e6123e54e94e4706f7b6195ce3d +Subproject commit ce948f4616e3d4277e30c75c8bb01e094910df39 diff --git a/src/tools/enzyme b/src/tools/enzyme index a35f4f77311..5004a8f6f5d 160000 --- a/src/tools/enzyme +++ b/src/tools/enzyme @@ -1 +1 @@ -Subproject commit a35f4f773118ccfbd8d05102eb12a34097b1ee55 +Subproject commit 5004a8f6f5d8468b64fae457afb7d96e1784c783 From 4dab55bcaa3f1a60f11b3ff36159c199bc210616 Mon Sep 17 00:00:00 2001 From: LuuuXXX Date: Tue, 4 Mar 2025 17:38:06 +0800 Subject: [PATCH 4/8] Revert "add fix for full tools and sanitizer" This reverts commit 6efacfb7a59ebde2620398861713fae136060a04. --- Cargo.lock | 20 +++++++++---------- src/bootstrap/src/core/build_steps/llvm.rs | 13 ------------ .../docker/host-x86_64/dist-ohos/Dockerfile | 5 +---- .../rustc/src/platform-support/openharmony.md | 13 +----------- src/gcc | 2 +- src/llvm-project | 2 +- src/tools/cargo | 2 +- src/tools/enzyme | 2 +- 8 files changed, 16 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 05a2534c857..d4ca5ce5d59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1997,22 +1997,22 @@ dependencies = [ ] [[package]] -name = "libffi-sys2" -version = "2.4.0" +name = "libffi" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47aedd9774ffb3dcab5c96f593cb5a0caf421a5e38b16bab3b8cdef5facb6ea2" +checksum = "ce826c243048e3d5cec441799724de52e2d42f820468431fc3fceee2341871e2" dependencies = [ - "cc", + "libc", + "libffi-sys", ] [[package]] -name = "libffi2" -version = "3.3.0" +name = "libffi-sys" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c88a3402cad8ff58216ec6d07e5ecfa9e15fc36613c0a832db541e4e1a718a7b" +checksum = "f36115160c57e8529781b4183c2bb51fdc1f6d6d1ed345591d84be7703befb3c" dependencies = [ - "libc", - "libffi-sys2", + "cc", ] [[package]] @@ -2273,7 +2273,7 @@ dependencies = [ "directories", "getrandom 0.3.1", "libc", - "libffi2", + "libffi", "libloading", "measureme 11.0.1", "rand 0.9.0", diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 6a392b6bd7c..5919e989b34 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -814,10 +814,6 @@ fn configure_cmake( cflags.push(s); } - if target.contains("ohos") { - cflags.push(" -D_LINUX_SYSINFO_H"); - } - if builder.config.llvm_clang_cl.is_some() { cflags.push(format!(" --target={target}")); } @@ -838,11 +834,6 @@ fn configure_cmake( cxxflags.push(" "); cxxflags.push(s); } - - if target.contains("ohos") { - cxxflags.push(" -D_LINUX_SYSINFO_H"); - } - if builder.config.llvm_clang_cl.is_some() { cxxflags.push(format!(" --target={target}")); } @@ -1229,10 +1220,6 @@ impl Step for Sanitizers { cfg.define("COMPILER_RT_USE_LIBCXX", "OFF"); cfg.define("LLVM_CONFIG_PATH", &llvm_config); - if self.target.contains("ohos") { - cfg.define("COMPILER_RT_USE_BUILTINS_LIBRARY", "ON"); - } - // On Darwin targets the sanitizer runtimes are build as universal binaries. // Unfortunately sccache currently lacks support to build them successfully. // Disable compiler launcher on Darwin targets to avoid potential issues. diff --git a/src/ci/docker/host-x86_64/dist-ohos/Dockerfile b/src/ci/docker/host-x86_64/dist-ohos/Dockerfile index 2c514fa0d4d..23c0c8b49d2 100644 --- a/src/ci/docker/host-x86_64/dist-ohos/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-ohos/Dockerfile @@ -60,10 +60,7 @@ ENV \ ENV RUST_CONFIGURE_ARGS \ --enable-profiler \ - --disable-docs \ - --tools=cargo,clippy,rustdocs,rustfmt,rust-analyzer,rust-analyzer-proc-macro-srv,analysis,src,wasm-component-ld \ - --enable-extended \ - --enable-sanitizers + --disable-docs ENV SCRIPT python3 ../x.py dist --host=$TARGETS --target $TARGETS diff --git a/src/doc/rustc/src/platform-support/openharmony.md b/src/doc/rustc/src/platform-support/openharmony.md index 5988c468a8b..1632f44aeec 100644 --- a/src/doc/rustc/src/platform-support/openharmony.md +++ b/src/doc/rustc/src/platform-support/openharmony.md @@ -1,6 +1,6 @@ # `*-unknown-linux-ohos` -**Tier: 2(with Host Tools)** +**Tier: 2** * aarch64-unknown-linux-ohos * armv7-unknown-linux-ohos @@ -18,17 +18,6 @@ system. - Amanieu d'Antras ([@Amanieu](https://github.com/Amanieu)) - Lu Binglun ([@lubinglun](https://github.com/lubinglun)) -## Requirements - -All the ohos targets of Tier 2 with host tools support all extended rust tools. -(exclude `miri`, the support of `miri` will be added soon) - -### Host toolchain - -The targets require a reasonably up-to-date OpenHarmony SDK on the host. - -The targets support `cargo`, which require [ohos-openssl](https://github.com/ohos-rs/ohos-openssl). - ## Setup The OpenHarmony SDK doesn't currently support Rust compilation directly, so diff --git a/src/gcc b/src/gcc index fd3498bff0b..48664a6cab2 160000 --- a/src/gcc +++ b/src/gcc @@ -1 +1 @@ -Subproject commit fd3498bff0b939dda91d56960acc33d55f2f9cdf +Subproject commit 48664a6cab29d48138ffa004b7978d52ef73e3ac diff --git a/src/llvm-project b/src/llvm-project index 92e80685d0d..1c3bb96fdb6 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 92e80685d0d5dcea3ccf321995c43b72338639c6 +Subproject commit 1c3bb96fdb6db7b8e8f24edb016099c223fdd27e diff --git a/src/tools/cargo b/src/tools/cargo index ce948f4616e..2622e844bc1 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit ce948f4616e3d4277e30c75c8bb01e094910df39 +Subproject commit 2622e844bc1e2e6123e54e94e4706f7b6195ce3d diff --git a/src/tools/enzyme b/src/tools/enzyme index 5004a8f6f5d..a35f4f77311 160000 --- a/src/tools/enzyme +++ b/src/tools/enzyme @@ -1 +1 @@ -Subproject commit 5004a8f6f5d8468b64fae457afb7d96e1784c783 +Subproject commit a35f4f773118ccfbd8d05102eb12a34097b1ee55 From 3eb04fd590527a103a70027a9da5ed9b20b76238 Mon Sep 17 00:00:00 2001 From: LuuuXXX Date: Tue, 4 Mar 2025 17:55:06 +0800 Subject: [PATCH 5/8] add support for extend rust tools and sanitizer --- src/bootstrap/src/core/build_steps/llvm.rs | 11 ++++++++++- src/ci/docker/host-x86_64/dist-ohos/Dockerfile | 5 ++++- src/doc/rustc/src/platform-support/openharmony.md | 13 ++++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 5919e989b34..3a32487a17c 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -813,7 +813,9 @@ fn configure_cmake( cflags.push(" "); cflags.push(s); } - + if target.contains("ohos") { + cflags.push(" -D_LINUX_SYSINFO_H"); + } if builder.config.llvm_clang_cl.is_some() { cflags.push(format!(" --target={target}")); } @@ -834,6 +836,9 @@ fn configure_cmake( cxxflags.push(" "); cxxflags.push(s); } + if target.contains("ohos") { + cxxflags.push(" -D_LINUX_SYSINFO_H"); + } if builder.config.llvm_clang_cl.is_some() { cxxflags.push(format!(" --target={target}")); } @@ -1220,6 +1225,10 @@ impl Step for Sanitizers { cfg.define("COMPILER_RT_USE_LIBCXX", "OFF"); cfg.define("LLVM_CONFIG_PATH", &llvm_config); + if self.target.contains("ohos") { + cfg.define("COMPILER_RT_USE_BUILTINS_LIBRARY", "ON"); + } + // On Darwin targets the sanitizer runtimes are build as universal binaries. // Unfortunately sccache currently lacks support to build them successfully. // Disable compiler launcher on Darwin targets to avoid potential issues. diff --git a/src/ci/docker/host-x86_64/dist-ohos/Dockerfile b/src/ci/docker/host-x86_64/dist-ohos/Dockerfile index 23c0c8b49d2..2c514fa0d4d 100644 --- a/src/ci/docker/host-x86_64/dist-ohos/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-ohos/Dockerfile @@ -60,7 +60,10 @@ ENV \ ENV RUST_CONFIGURE_ARGS \ --enable-profiler \ - --disable-docs + --disable-docs \ + --tools=cargo,clippy,rustdocs,rustfmt,rust-analyzer,rust-analyzer-proc-macro-srv,analysis,src,wasm-component-ld \ + --enable-extended \ + --enable-sanitizers ENV SCRIPT python3 ../x.py dist --host=$TARGETS --target $TARGETS diff --git a/src/doc/rustc/src/platform-support/openharmony.md b/src/doc/rustc/src/platform-support/openharmony.md index 1632f44aeec..a2107b48a86 100644 --- a/src/doc/rustc/src/platform-support/openharmony.md +++ b/src/doc/rustc/src/platform-support/openharmony.md @@ -1,6 +1,6 @@ # `*-unknown-linux-ohos` -**Tier: 2** +**Tier: 2 (with Host Tools)** * aarch64-unknown-linux-ohos * armv7-unknown-linux-ohos @@ -18,6 +18,17 @@ system. - Amanieu d'Antras ([@Amanieu](https://github.com/Amanieu)) - Lu Binglun ([@lubinglun](https://github.com/lubinglun)) +## Requirements + +All the ohos targets of Tier 2 with host tools support all extended rust tools. +(exclude `miri`, the support of `miri` will be added soon) + +### Host toolchain + +The targets require a reasonably up-to-date OpenHarmony SDK on the host. + +The targets support `cargo`, which require [ohos-openssl](https://github.com/ohos-rs/ohos-openssl). + ## Setup The OpenHarmony SDK doesn't currently support Rust compilation directly, so From f3312609f7a9db95047196387fdd8c69edaa898e Mon Sep 17 00:00:00 2001 From: LuuuXXX Date: Tue, 4 Mar 2025 20:30:57 +0800 Subject: [PATCH 6/8] add note for miri --- src/doc/rustc/src/platform-support/openharmony.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/doc/rustc/src/platform-support/openharmony.md b/src/doc/rustc/src/platform-support/openharmony.md index a2107b48a86..e772a3d09f3 100644 --- a/src/doc/rustc/src/platform-support/openharmony.md +++ b/src/doc/rustc/src/platform-support/openharmony.md @@ -29,6 +29,9 @@ The targets require a reasonably up-to-date OpenHarmony SDK on the host. The targets support `cargo`, which require [ohos-openssl](https://github.com/ohos-rs/ohos-openssl). +`miri` isn't supported yet, since its dependencies (`libffi` and `tikv-jemalloc-sys`) don't support +compiling for the OHOS targets. + ## Setup The OpenHarmony SDK doesn't currently support Rust compilation directly, so From 23adb46b4733a5e5962419dbd5876b7d06d51f7a Mon Sep 17 00:00:00 2001 From: LuuuXXX Date: Wed, 5 Mar 2025 18:23:34 +0800 Subject: [PATCH 7/8] disable link libstdc++ statically --- src/ci/run.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ci/run.sh b/src/ci/run.sh index b874f71832d..205eb243843 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -113,7 +113,11 @@ export RUST_RELEASE_CHANNEL=$(releaseChannel) RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL" if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then - RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp" + if [[ "$CI_JOB_NAME" == *ohos* ]]; then + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-static-stdcpp" + else + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp" + fi RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo" if [ "$DEPLOY_ALT" != "" ] && isLinux; then From 4cd350f61639d66095a9c5c87e6ff574ad1f7a00 Mon Sep 17 00:00:00 2001 From: LuuuXXX Date: Thu, 6 Mar 2025 16:03:35 +0800 Subject: [PATCH 8/8] remove zip file in /tmp to save some space and use large runner --- src/ci/docker/scripts/ohos-sdk.sh | 1 + src/ci/github-actions/jobs.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ci/docker/scripts/ohos-sdk.sh b/src/ci/docker/scripts/ohos-sdk.sh index 0b62e49f7ca..47d630ca76b 100755 --- a/src/ci/docker/scripts/ohos-sdk.sh +++ b/src/ci/docker/scripts/ohos-sdk.sh @@ -7,3 +7,4 @@ curl $URL | tar xz -C /tmp linux/native-linux-x64-5.0.0.71-Release.zip mkdir /opt/ohos-sdk cd /opt/ohos-sdk unzip -qq /tmp/linux/native-linux-x64-5.0.0.71-Release.zip +rm /tmp/linux/native-linux-x64-5.0.0.71-Release.zip diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 1504e5c60ce..45ec4433c42 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -176,7 +176,7 @@ auto: <<: *job-linux-4c - name: dist-ohos - <<: *job-linux-4c + <<: *job-linux-4c-largedisk - name: dist-powerpc-linux <<: *job-linux-4c