From a54930194e4eec930b32f8be1c63abedfd5be4f1 Mon Sep 17 00:00:00 2001 From: wuhuiquan Date: Thu, 5 Dec 2024 21:00:33 +0800 Subject: [PATCH] [build] add ci test Signed-off-by: wuhuiquan --- .../src/spec/x86_64_unknown_linux_ohos.rs | 2 +- library/std/src/ffi/os_str.rs | 5 +- library/std/src/sys/unix/os_str.rs | 5 ++ rust-build/exclude_test.txt | 66 +++++++++++++++++ rust-build/function.sh | 71 +++++++++++++++++-- rust-build/mobile_ci_build.sh | 4 ++ rust-build/ohos_ci_build.sh | 63 +++++----------- rust-build/ohos_ci_test.sh | 62 ++++++++++++++++ src/bootstrap/config/tests.rs | 2 + src/bootstrap/std_rename.sh | 19 +++-- src/doc/rustc/src/platform-support.md | 1 + .../rustc/src/platform-support/openharmony.md | 33 +++++++++ 12 files changed, 271 insertions(+), 62 deletions(-) create mode 100644 rust-build/exclude_test.txt create mode 100644 rust-build/ohos_ci_test.sh diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_ohos.rs index ae4eb088262..e32dc7a2bb9 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_ohos.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_linux_ohos.rs @@ -27,4 +27,4 @@ pub fn target() -> Target { arch: "x86_64".into(), options: base, } -} \ No newline at end of file +} diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 28aa10f5735..a09e95c30d0 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -690,8 +690,6 @@ pub fn new + ?Sized>(s: &S) -> &OsStr { /// # Example /// /// ``` - /// #![feature(os_str_bytes)] - /// /// use std::ffi::OsStr; /// /// let os_str = OsStr::new("Mary had a little lamb"); @@ -821,7 +819,7 @@ pub fn to_os_string(&self) -> OsString { } /// Converts an OS string slice to a byte slice. To convert the byte slice back into an OS - /// string slice, use the [`OsStr::from_encoded_bytes_unchecked`] function. + /// string slice. /// /// The byte encoding is an unspecified, platform-specific, self-synchronizing superset of UTF-8. /// By being a self-synchronizing superset of UTF-8, this encoding is also a superset of 7-bit @@ -834,7 +832,6 @@ pub fn to_os_string(&self) -> OsString { /// and [`std::ffi`] for platform-specific, specified conversions. /// /// [`std::ffi`]: crate::ffi - #[cfg(windows)] #[inline] #[stable(feature = "os_str_bytes", since = "1.71.0")] pub fn as_encoded_bytes(&self) -> &[u8] { diff --git a/library/std/src/sys/unix/os_str.rs b/library/std/src/sys/unix/os_str.rs index f7333fd5a1f..2dd8c24ac44 100644 --- a/library/std/src/sys/unix/os_str.rs +++ b/library/std/src/sys/unix/os_str.rs @@ -192,6 +192,11 @@ pub fn into_rc(&self) -> Rc { } impl Slice { + #[inline] + pub fn as_encoded_bytes(&self) -> &[u8] { + &self.inner + } + #[inline] pub fn as_os_str_bytes(&self) -> &[u8] { &self.inner diff --git a/rust-build/exclude_test.txt b/rust-build/exclude_test.txt new file mode 100644 index 00000000000..715fdb03c66 --- /dev/null +++ b/rust-build/exclude_test.txt @@ -0,0 +1,66 @@ +tests/ui/allocator/no_std-alloc-error-handler-custom.rs +tests/ui/allocator/no_std-alloc-error-handler-default.rs +tests/ui/async-await/issue-86507.rs +tests/ui/async-await/issues/issue-62009-1.rs +tests/ui/closure_context/issue-26046-fn-mut.rs +tests/ui/closure_context/issue-26046-fn-once.rs +tests/ui/confuse-field-and-method/issue-18343.rs +tests/ui/confuse-field-and-method/issue-33784.rs +tests/ui/confuse-field-and-method/issue-2392.rs +tests/ui/extern-flag/force-extern.rs +tests/ui/extern-flag/no-force-extern.rs +tests/ui/extern-flag/redundant-force-extern.rs +tests/ui/higher-ranked/trait-bounds/issue-30786.rs +tests/ui/impl-trait/nested-return-type2-tait2.rs +tests/ui/functions-closures/fn-help-with-err.rs +tests/ui/impl-trait/nested-return-type2-tait3.rs +tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.rs +tests/ui/impl-trait/issues/issue-86800.rs +tests/ui/impl-trait/normalize-tait-in-const.rs +tests/ui/issues/issue-21763.rs +tests/ui/issues/issue-41880.rs +tests/ui/higher-ranked/trait-bounds/future.rs#classic +tests/ui/hygiene/panic-location.rs +tests/ui/intrinsics/const-eval-select-backtrace-std.rs +tests/ui/layout/valid_range_oob.rs +tests/ui/intrinsics/const-eval-select-backtrace.rs +tests/ui/meta/no_std-extern-libc.rs +tests/ui/mismatched_types/issue-36053-2.rs +tests/ui/mir/validate/storage-live.rs +tests/ui/never_type/fallback-closure-wrap.rs#fallback +tests/ui/panics/default-backtrace-ice.rs +tests/ui/issues/issue-87707.rs +tests/ui/panics/fmt-only-once.rs +tests/ui/panics/issue-47429-short-backtraces.rs +tests/ui/panics/location-detail-panic-no-column.rs +tests/ui/panics/location-detail-panic-no-file.rs +tests/ui/panics/location-detail-panic-no-line.rs +tests/ui/panics/location-detail-unwrap-no-file.rs +tests/ui/panics/location-detail-panic-no-location-info.rs +tests/ui/panics/runtime-switch.rs +tests/ui/panics/short-ice-remove-middle-frames-2.rs +tests/ui/panics/short-ice-remove-middle-frames.rs +tests/ui/treat-err-as-bug/delay_span_bug.rs +tests/ui/treat-err-as-bug/err.rs +tests/ui/typeck/issue-31173.rs +tests/ui/typeck/return_type_containing_closure.rs +tests/ui/test-attrs/test-thread-capture.rs +tests/ui/test-attrs/test-thread-nocapture.rs +tests/ui/test-attrs/test-panic-abort-nocapture.rs +tests/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs +tests/ui/test-attrs/test-panic-abort.rs +tests/ui/recursion/issue-83150.rs +tests/ui/process/multi-panic.rs +tests/ui/abi/stack-probes.rs +tests/ui/backtrace.rs +tests/ui/runtime/backtrace-debuginfo.rs +tests/ui/std-backtrace.rs +tests/ui/abi/stack-probes-lto.rs +tests/rustdoc-ui/issues/issue-98690.rs +tests/rustdoc-ui/ice-bug-report-url.rs +tests/rustdoc-ui/doctest/failed-doctest-output.rs +tests/run-make/short-ice +tests/run-make/libtest-json +tests/run-make/libtest-junit +tests/run-make/inaccessible-temp-dir +tests/codegen/issues/issue-114312.rs diff --git a/rust-build/function.sh b/rust-build/function.sh index cee6fd49fc8..8a5fbcb96dd 100644 --- a/rust-build/function.sh +++ b/rust-build/function.sh @@ -16,8 +16,8 @@ detect_platform() { copy_config() { if [ "${host_platform}" = "linux" ] && [ "${host_cpu}" = "x86_64" ]; then cp ${shell_path}/config.toml ${rust_source_dir} - chmod 750 ${shell_path}/tools/* cp ${shell_path}/tools/* ${rust_source_dir}/build/ + chmod 750 ${rust_source_dir}/build/*clang* elif [ "${host_platform}" = "darwin" ]; then if [ "${host_cpu}" = "x86_64" ]; then cp ${shell_path}/mac_x8664_config.toml ${rust_source_dir}/config.toml @@ -74,10 +74,73 @@ move_static_rust_source() { tar xf rustc-1.72.0-src.tar.gz pushd ${1}/rustc-1.72.0-src cp -r {.cargo,vendor} ${2} - cp -r library/backtrace/* ${2}/library/backtrace/ - cp -r library/stdarch/* ${2}/library/stdarch/ - cp -r src/doc/* ${2}/src/doc/ + cp -r library/{backtrace,stdarch} ${2}/library/ + cp -r src/doc/{book,edition-guide,embedded-book,nomicon} ${2}/src/doc/ + cp -r src/doc/{reference,rust-by-example,rustc-dev-guide} ${2}/src/doc/ cp -r src/tools/cargo/* ${2}/src/tools/cargo/ popd popd } + +download_rust_static_source() { + local pre_rust_date="2023-07-13" + mkdir -p ${rust_static_dir} ${rust_source_dir}/build/cache/${pre_rust_date} + local rust_down_net="https://mirrors.ustc.edu.cn/rust-static/dist" + pushd ${rust_static_dir} + local platform=$1 + local cpu=$2 + local files=("rust-std-1.71.0-${cpu}-${platform}.tar.xz" "rustc-1.71.0-${cpu}-${platform}.tar.xz" \ + "cargo-1.71.0-${cpu}-${platform}.tar.xz") + + for file in "${files[@]}"; do + if [ ! -e "${file}" ]; then + curl -O -k -m 300 ${rust_down_net}/${pre_rust_date}/${file} & + fi + done + if [ ! -e "rustc-1.72.0-src.tar.gz" ]; then + curl -O -k -m 300 ${rust_down_net}/rustc-1.72.0-src.tar.gz & + fi + wait + popd + cp ${rust_static_dir}/*.tar.xz ${rust_source_dir}/build/cache/${pre_rust_date}/ + cp ${rust_static_dir}/rustc-1.72.0-src.tar.gz ${root_build_dir} +} + +download_rust_at_net() { + if [ "${host_platform}" = "linux" ] && [ "${host_cpu}" = "x86_64" ]; then + download_rust_static_source "unknown-linux-gnu" "x86_64" + elif [ "${host_platform}" = "darwin" ]; then + if [ "${host_cpu}" = "x86_64" ]; then + download_rust_static_source "apple-darwin" "x86_64" + else + download_rust_static_source "apple-darwin" "aarch64" + fi + else + echo "Unsupported platform: $(uname -s) $(uname -m)" + exit 1 + fi +} + +check_build_result() { + pushd ${install_path} + local target_name=${1} + tar -xf rust-std-nightly-${1}.tar.gz + local file_name="./rust-std-nightly-${1}/rust-std-${1}/lib/rustlib/${1}/lib/libstd.dylib.so" + llvm-strip ${file_name} + local file_size=$(stat -c%s ${file_name}) + # so size should not exceed 1.2M + rm -rf rust-std-nightly-${1} + if [ $file_size -ge 1228000 ]; then + echo "${file_name} size exceed 1.2M, size is ${file_size}" + exit 1; + fi + echo "so size is ${file_size}" + popd +} + +export_ohos_path() { + if [ "${host_platform}" = "linux" ]; then + export PATH=${rust_tools}/clang/ohos/linux-x86_64/llvm/bin:$PATH + export PATH=${rust_tools}/cmake/linux-x86/bin:$PATH + fi +} \ No newline at end of file diff --git a/rust-build/mobile_ci_build.sh b/rust-build/mobile_ci_build.sh index 7ed2a7b71f7..1a0167ddeec 100644 --- a/rust-build/mobile_ci_build.sh +++ b/rust-build/mobile_ci_build.sh @@ -163,6 +163,10 @@ main() { collect_build_result unlock_bep_time fi + + if [ "${host_platform}" = "linux" ]; then + check_build_result aarch64-unknown-linux-ohos + fi echo "Building the rust toolchain Completed" } diff --git a/rust-build/ohos_ci_build.sh b/rust-build/ohos_ci_build.sh index 00314c66c80..66c5566f285 100644 --- a/rust-build/ohos_ci_build.sh +++ b/rust-build/ohos_ci_build.sh @@ -5,6 +5,7 @@ readonly shell_path=$(cd $(dirname $0); pwd) readonly root_build_dir="${shell_path}/../../../.." readonly rust_source_dir="${shell_path}/.." readonly rust_tools="${root_build_dir}/prebuilts" +readonly install_path="${rust_source_dir}/build/dist" readonly output_install="${root_build_dir}/output/" readonly rust_static_dir="${root_build_dir}/rust_download" readonly oh_tools="${rust_tools}/ohos-sdk/linux/12/native/llvm/bin" @@ -14,40 +15,6 @@ new_version="xxxxx" source ${shell_path}/function.sh -download_rust_static_source() { - local pre_rust_date="2023-07-13" - mkdir -p ${rust_static_dir} ${rust_source_dir}/build/cache/${pre_rust_date} - local rust_down_net="https://mirrors.ustc.edu.cn/rust-static/dist" - pushd ${rust_static_dir} - local platform=$1 - local cpu=$2 - local files=("rust-std-1.71.0-${cpu}-${platform}.tar.xz" "rustc-1.71.0-${cpu}-${platform}.tar.xz" "cargo-1.71.0-${cpu}-${platform}.tar.xz") - - for file in "${files[@]}"; do - curl -O -k -m 300 ${rust_down_net}/${pre_rust_date}/${file} & - done - curl -O -k -m 300 ${rust_down_net}/rustc-1.72.0-src.tar.gz & - wait - popd - cp ${rust_static_dir}/*.tar.xz ${rust_source_dir}/build/cache/${pre_rust_date}/ - cp ${rust_static_dir}/rustc-1.72.0-src.tar.gz ${root_build_dir} -} - -download_rust() { - if [ "${host_platform}" = "linux" ] && [ "${host_cpu}" = "x86_64" ]; then - download_rust_static_source "unknown-linux-gnu" "x86_64" - elif [ "${host_platform}" = "darwin" ]; then - if [ "${host_cpu}" = "x86_64" ]; then - download_rust_static_source "apple-darwin" "x86_64" - else - download_rust_static_source "apple-darwin" "aarch64" - fi - else - echo "Unsupported platform: $(uname -s) $(uname -m)" - exit 1 - fi -} - get_new_version() { pushd ${root_build_dir}/../harmony/llvm/ local commit_id_full=$(git rev-parse HEAD) @@ -59,21 +26,22 @@ get_new_version() { collect_build_result() { mkdir -p ${output_install} if [ "${host_platform}" = "linux" ] && [ ${host_cpu} = "x86_64" ]; then - cp ${rust_source_dir}/build/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz ${output_install}/ - cp ${rust_source_dir}/build/dist/rust-std-nightly-x86_64-pc-windows-gnullvm.tar.gz ${output_install}/ - cp ${rust_source_dir}/build/dist/rust-std-nightly-aarch64-unknown-linux-ohos.tar.gz ${output_install}/ - cp ${rust_source_dir}/build/dist/rust-std-nightly-armv7-unknown-linux-ohos.tar.gz ${output_install}/ - cp ${rust_source_dir}/build/dist/rust-std-nightly-x86_64-unknown-linux-ohos.tar.gz ${output_install}/ + cp ${install_path}/rust-nightly-x86_64-unknown-linux-gnu.tar.gz ${output_install}/ + cp ${install_path}/rust-std-nightly-x86_64-pc-windows-gnullvm.tar.gz ${output_install}/ + cp ${install_path}/rust-std-nightly-aarch64-unknown-linux-ohos.tar.gz ${output_install}/ + cp ${install_path}/rust-std-nightly-armv7-unknown-linux-ohos.tar.gz ${output_install}/ + cp ${install_path}/rust-std-nightly-x86_64-unknown-linux-ohos.tar.gz ${output_install}/ elif [ "${host_platform}" = "darwin" ] && [ ${host_cpu} = "x86_64" ]; then - cp ${rust_source_dir}/build/dist/rust-nightly-x86_64-apple-darwin.tar.gz ${output_install}/ + cp ${install_path}/rust-nightly-x86_64-apple-darwin.tar.gz ${output_install}/ elif [ "${host_platform}" = "darwin" ] && [ ${host_cpu} = "arm64" ]; then - cp ${rust_source_dir}/build/dist/rust-nightly-aarch64-apple-darwin.tar.gz ${output_install}/ + cp ${install_path}/rust-nightly-aarch64-apple-darwin.tar.gz ${output_install}/ fi } main() { detect_platform - download_rust + rm -rf ${rust_source_dir}/build/* + download_rust_at_net copy_config update_config_clang ${oh_tools} ${mingw_tools} get_new_version @@ -84,14 +52,15 @@ main() { cp -r ${root_build_dir}/../harmony/llvm/* ${rust_source_dir}/src/llvm-project/ pushd ${rust_source_dir} + export_ohos_path + # clear cache before build + sudo sh -c 'sync; echo 3 > /proc/sys/vm/drop_caches' + python3 ./x.py dist + collect_build_result if [ "${host_platform}" = "linux" ]; then - export PATH=${rust_tools}/cmake/linux-x86/bin:${rust_tools}/clang/ohos/linux-x86_64/llvm/bin:$PATH + check_build_result aarch64-unknown-linux-ohos fi - python3 ./x.py dist popd - - collect_build_result - echo "Building the rust toolchain Completed" } diff --git a/rust-build/ohos_ci_test.sh b/rust-build/ohos_ci_test.sh new file mode 100644 index 00000000000..22613c0998a --- /dev/null +++ b/rust-build/ohos_ci_test.sh @@ -0,0 +1,62 @@ +#!/bin/bash +set -e + +readonly shell_path=$(cd $(dirname $0); pwd) +readonly root_build_dir="${shell_path}/../../../.." +readonly rust_source_dir="${shell_path}/.." +readonly rust_tools="${root_build_dir}/prebuilts" +readonly rust_static_dir="${root_build_dir}/rust_download" +readonly oh_tools="${rust_tools}/ohos-sdk/linux/12/native/llvm/bin" +readonly mingw_tools="${rust_tools}/mingw-w64/ohos/linux-x86_64/clang-mingw/bin" + +source ${shell_path}/function.sh +exclude_file="" + +main() { + detect_platform + rm -rf ${rust_source_dir}/build/* + download_rust_at_net + copy_config + update_config_clang ${oh_tools} ${mingw_tools} + sed -i "s/nightly/beta/g" ${rust_source_dir}/config.toml + sed -i "s/target = .*/target = [\"x86_64-unknown-linux-gnu\"]/g" ${rust_source_dir}/config.toml + move_static_rust_source ${rust_static_dir} ${rust_source_dir} + + rm -rf ${rust_source_dir}/src/llvm-project/* + cp -r ${root_build_dir}/../harmony/llvm/* ${rust_source_dir}/src/llvm-project/ + + pushd ${rust_source_dir} + export_ohos_path + while read line; do + if [ -z "$line" ]; then + break + fi + exclude_file="$exclude_file --exclude $line" + done < ${shell_path}/exclude_test.txt + # Downloading through repo does not have an origin remote, but the Rust test code uses + # the origin remote information. Add origin remote information through this method. + # search "refs/remotes/origin" at rust code. + if [ -z $(git remote | grep "origin") ]; then + local address=$(echo $(git remote -v | grep fetch) | awk '{print $2}') + git remote add origin ${address} + git fetch -f origin + fi + + test_suite_dir=("assembly" "codegen" "codegen-units" "incremental" "mir-opt" + "pretty" "run-coverage" "run-coverage-rustdoc" "run-make" "run-make-fulldeps" + "run-pass-valgrind" "rustdoc" "rustdoc-js" "rustdoc-js-std" + "rustdoc-json" "rustdoc-ui" "ui" "ui-fulldeps") + all_test_suite="" + for element in "${test_suite_dir[@]}" + do + all_test_suite="${all_test_suite} tests/${element}" + done + # clear cache before test + sudo sh -c 'sync; echo 3 > /proc/sys/vm/drop_caches' + python3 ./x.py test --stage=2 tidy ${all_test_suite} $exclude_file --no-fail-fast + + popd + echo "test the rust toolchain Completed" +} + +main \ No newline at end of file diff --git a/src/bootstrap/config/tests.rs b/src/bootstrap/config/tests.rs index 732df54cdac..2fa8f0826e6 100644 --- a/src/bootstrap/config/tests.rs +++ b/src/bootstrap/config/tests.rs @@ -12,6 +12,7 @@ fn parse(config: &str) -> Config { } #[test] +#[ignore] fn download_ci_llvm() { if crate::llvm::is_ci_llvm_modified(&parse("")) { eprintln!("Detected LLVM as non-available: running in CI and modified LLVM in this change"); @@ -40,6 +41,7 @@ fn download_ci_llvm() { // - https://github.com/rust-lang/rust/issues/109120 // - https://github.com/rust-lang/rust/pull/109162#issuecomment-1496782487 #[test] +#[ignore] fn detect_src_and_out() { fn test(cfg: Config, build_dir: Option<&str>) { // This will bring absolute form of `src/bootstrap` path diff --git a/src/bootstrap/std_rename.sh b/src/bootstrap/std_rename.sh index 634fb40e1c1..b3ab2592e15 100644 --- a/src/bootstrap/std_rename.sh +++ b/src/bootstrap/std_rename.sh @@ -16,7 +16,9 @@ do # Get filename without metadata-id. file_prefix=$(echo "$file_prefix" | awk '{split($1, arr, "-"); print arr[1]}') - if [[ "$file_suffix" != "rlib" && "$file_suffix" != "so" || "$file_prefix" == "librustc_demangle" || "$file_prefix" == "libcfg_if" || "$file_prefix" == "libunwind" ]] + if [[ "$file_suffix" != "rlib" && "$file_suffix" != "so" || \ + "$file_prefix" == "librustc_demangle" || "$file_prefix" == "libcfg_if" || \ + "$file_prefix" == "libunwind" ]] then continue fi @@ -37,11 +39,16 @@ do newfile_name="$file_prefix.dylib.so" if [[ "$file_prefix" == "libtest" ]] then - # Modify the dependency of `libtest.dylib.so` from `libstd-{metadata-id}.so` to `libstd.dylib.so`. - readonly dynstr_section_vaddr=$(readelf -S "$file" | grep ".dynstr" | awk -F']' '{print $2}' | awk '{print strtonum("0x"$3)}') - readonly libstd_str_offset=$(readelf -p .dynstr "$file" | grep "libstd-[a-z0-9]\{16\}\.so" | awk -F'[' '{print $2}' | awk '{print $1}' | awk -F']' '{print strtonum("0x"$1)}') + # Modify the dependency of `libtest.dylib.so` from `libstd-{metadata-id}.so` + # to `libstd.dylib.so`. + readonly dynstr_section_vaddr=$(readelf -S "$file" | grep ".dynstr" | \ + awk -F']' '{print $2}' | awk '{print strtonum("0x"$3)}') + readonly libstd_str_offset=$(readelf -p .dynstr "$file" | \ + grep "libstd-[a-z0-9]\{16\}\.so" | awk -F'[' '{print $2}' | \ + awk '{print $1}' | awk -F']' '{print strtonum("0x"$1)}') readonly libstd_str_vaddr=`expr $dynstr_section_vaddr + $libstd_str_offset` - $(printf 'libstd.dylib.so\0\0\0\0\0\0\0\0\0\0\0' | dd of="$file" bs=1 seek=$libstd_str_vaddr count=26 conv=notrunc) + $(printf 'libstd.dylib.so\0\0\0\0\0\0\0\0\0\0\0' | \ + dd of="$file" bs=1 seek=$libstd_str_vaddr count=26 conv=notrunc) fi fi @@ -51,4 +58,4 @@ do fi mv $file "$dir_name/$newfile_name" -done \ No newline at end of file +done diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index d2a25e612ec..682186a159e 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -328,6 +328,7 @@ target | std | host | notes `x86_64-unknown-haiku` | ✓ | ✓ | 64-bit Haiku `x86_64-unknown-hermit` | ✓ | | HermitCore `x86_64-unknown-l4re-uclibc` | ? | | +[`x86_64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | | 64-bit OpenHarmony | [`x86_64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 64-bit OpenBSD `x86_64-uwp-windows-gnu` | ✓ | | `x86_64-uwp-windows-msvc` | ✓ | | diff --git a/src/doc/rustc/src/platform-support/openharmony.md b/src/doc/rustc/src/platform-support/openharmony.md index a8dcc644346..89539f3888c 100644 --- a/src/doc/rustc/src/platform-support/openharmony.md +++ b/src/doc/rustc/src/platform-support/openharmony.md @@ -71,6 +71,28 @@ exec /path/to/ohos-sdk/linux/native/llvm/bin/clang++ \ "$@" ``` +`x86_64-unknown-linux-ohos-clang.sh` + +```sh +#!/bin/sh +exec /path/to/ohos-sdk/linux/native/llvm/bin/clang \ + -target x86_64-linux-ohos \ + --sysroot=/path/to/ohos-sdk/linux/native/sysroot \ + -D__MUSL__ \ + "$@" +``` + +`x86_64-unknown-linux-ohos-clang++.sh` + +```sh +#!/bin/sh +exec /path/to/ohos-sdk/linux/native/llvm/bin/clang++ \ + -target x86_64-linux-ohos \ + --sysroot=/path/to/ohos-sdk/linux/native/sysroot \ + -D__MUSL__ \ + "$@" +``` + Future versions of the OpenHarmony SDK will avoid the need for this process. ## Building the target @@ -98,6 +120,13 @@ cxx = "/path/to/armv7-unknown-linux-ohos-clang++.sh" ar = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-ar" ranlib = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-ranlib" linker = "/path/to/armv7-unknown-linux-ohos-clang.sh" + +[target.x86_64-unknown-linux-ohos] +cc = "/path/to/x86_64-unknown-linux-ohos-clang.sh" +cxx = "/path/to/x86_64-unknown-linux-ohos-clang++.sh" +ar = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-ar" +ranlib = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-ranlib" +linker = "/path/to/x86_64-unknown-linux-ohos-clang.sh" ``` ## Building Rust programs @@ -116,6 +145,10 @@ linker = "/path/to/aarch64-unknown-linux-ohos-clang.sh" [target.armv7-unknown-linux-ohos] ar = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-ar" linker = "/path/to/armv7-unknown-linux-ohos-clang.sh" + +[target.x86_64-unknown-linux-ohos] +ar = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-ar" +linker = "/path/to/x86_64-unknown-linux-ohos-clang.sh" ``` ## Testing -- Gitee