diff --git a/rust-build/README.md b/rust-build/README.md index e2cf3d47df54c621ee686eb9818e83ed140c15b7..3bae7e759e177543cd61891475a18530877e84c9 100644 --- a/rust-build/README.md +++ b/rust-build/README.md @@ -46,8 +46,9 @@ python3 ./build/scripts/download_sdk.py --branch OpenHarmony-5.0.0-Release --pro 3、download build code ``` -git clone --depth=1 https://gitee.com/openharmony/third_party_llvm-project.git third_party/llvm-project -git clone --depth=1 https://gitee.com/openharmony/third_party_rust_rust.git third_party/rust/rust +repo init -u https://gitee.com/OpenHarmony/manifest.git -b master -m rust-toolchain.xml +repo sync -c +repo forall -c 'git lfs pull' ``` 4、start to build diff --git a/rust-build/function.sh b/rust-build/function.sh index 4f478c3fd45a04adcb4d02e13465baba1103e788..321395607a28eff3b49f41293242b1be7cd0f590 100644 --- a/rust-build/function.sh +++ b/rust-build/function.sh @@ -52,14 +52,25 @@ update_config_clang_path() { sed -i "s/ar = \"${3}\"/ar = \"${sys_clang_dir}\/${3}\"/g" ${rust_source_dir}/config.toml } +update_musl_head_file_path() { + # $1:musl head file path, $2 clang name + # add musl head file path to shell tools + musl_head_file_dir="$(echo ${1} | sed 's/\//\\\//g')" + sed -i "s/-Imusl/-I${musl_head_file_dir}/g" ${rust_source_dir}/build/${2} + sed -i "s/-Imusl/-I${musl_head_file_dir}/g" ${rust_source_dir}/build/${2}++ +} + update_config_clang() { - # $1:OH clang path $2:mingw clang path + # $1:OH clang path $2:mingw clang path $3:musl head file path if [ "${host_platform}" = "linux" ] && [ ${host_cpu} = "x86_64" ]; then update_config_clang_path ${1} clang llvm-ar update_config_clang_path ${1} aarch64-unknown-linux-ohos-clang llvm-ar update_config_clang_path ${1} armv7-unknown-linux-ohos-clang llvm-ar update_config_clang_path ${1} x86_64-unknown-linux-ohos-clang llvm-ar update_config_clang_path ${2} x86_64-w64-mingw32-clang x86_64-w64-mingw32-ar + update_musl_head_file_path ${3} aarch64-unknown-linux-ohos-clang + update_musl_head_file_path ${3} armv7-unknown-linux-ohos-clang + update_musl_head_file_path ${3} x86_64-unknown-linux-ohos-clang fi } diff --git a/rust-build/ohos_ci_build.sh b/rust-build/ohos_ci_build.sh index a944fcbb68cc61f84f08f84375f3aa215b0f3b38..2b151c9011a528d94bf3f78f723da84a845f0b51 100755 --- a/rust-build/ohos_ci_build.sh +++ b/rust-build/ohos_ci_build.sh @@ -10,6 +10,7 @@ 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" readonly mingw_tools="${rust_tools}/mingw-w64/ohos/linux-x86_64/clang-mingw/bin" +readonly musl_head_file_path="${root_build_dir}/third_party/musl/include/linux" readonly old_version="xxxxx" new_version="xxxxx" @@ -44,7 +45,7 @@ main() { clean download_rust_at_net copy_config - update_config_clang ${oh_tools} ${mingw_tools} + update_config_clang ${oh_tools} ${mingw_tools} ${musl_head_file_path} get_new_version update_version move_static_rust_source ${rust_static_dir} ${rust_source_dir} diff --git a/rust-build/ohos_ci_test.sh b/rust-build/ohos_ci_test.sh index 4572feb91bb95aa4e84ac09837b96df60e872ccf..1485bb98a24bb4688232975d3a191b5ebcf32787 100755 --- a/rust-build/ohos_ci_test.sh +++ b/rust-build/ohos_ci_test.sh @@ -8,6 +8,7 @@ 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" +readonly musl_head_file_path="${root_build_dir}/third_party/musl/include/linux" exclude_file="" all_test_suite="" @@ -18,7 +19,7 @@ main() { rm -rf ${rust_source_dir}/build/* download_rust_at_net copy_config - update_config_clang ${oh_tools} ${mingw_tools} + update_config_clang ${oh_tools} ${mingw_tools} ${musl_head_file_path} 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/* diff --git a/rust-build/tools/aarch64-unknown-linux-ohos-clang b/rust-build/tools/aarch64-unknown-linux-ohos-clang index 659e8d4e4e4e59a2e9d39830b6a6a589665847c0..5734c03f25da9555b5d316898c370c6a2379bb49 100644 --- a/rust-build/tools/aarch64-unknown-linux-ohos-clang +++ b/rust-build/tools/aarch64-unknown-linux-ohos-clang @@ -1,3 +1,3 @@ #!/bin/bash -exec aarch64-unknown-linux-ohos-clang -fstack-protector-all "$@" \ No newline at end of file +exec aarch64-unknown-linux-ohos-clang -Imusl -fstack-protector-all "$@" \ No newline at end of file diff --git a/rust-build/tools/aarch64-unknown-linux-ohos-clang++ b/rust-build/tools/aarch64-unknown-linux-ohos-clang++ index f00223abbf031ad3a2e62e9f7e15441c73f25aa6..260967fbfd22f2ce62671129ef468495cf7b739a 100644 --- a/rust-build/tools/aarch64-unknown-linux-ohos-clang++ +++ b/rust-build/tools/aarch64-unknown-linux-ohos-clang++ @@ -1,3 +1,3 @@ #!/bin/bash -exec aarch64-unknown-linux-ohos-clang++ -fstack-protector-all "$@" \ No newline at end of file +exec aarch64-unknown-linux-ohos-clang++ -Imusl -fstack-protector-all "$@" \ No newline at end of file diff --git a/rust-build/tools/armv7-unknown-linux-ohos-clang b/rust-build/tools/armv7-unknown-linux-ohos-clang index 5bea12197124a3c9c15cd057c4e500c764aed827..1d5995aa913eea80a59c7195b64f6e45813e9150 100644 --- a/rust-build/tools/armv7-unknown-linux-ohos-clang +++ b/rust-build/tools/armv7-unknown-linux-ohos-clang @@ -1,3 +1,3 @@ #!/bin/bash -exec armv7-unknown-linux-ohos-clang -fstack-protector-all "$@" \ No newline at end of file +exec armv7-unknown-linux-ohos-clang -Imusl -fstack-protector-all "$@" \ No newline at end of file diff --git a/rust-build/tools/armv7-unknown-linux-ohos-clang++ b/rust-build/tools/armv7-unknown-linux-ohos-clang++ index f44064a0b798a92015354a97fde5c75b2512c5cd..64211a0159719e78f27b00951124b42fa71a618c 100644 --- a/rust-build/tools/armv7-unknown-linux-ohos-clang++ +++ b/rust-build/tools/armv7-unknown-linux-ohos-clang++ @@ -1,3 +1,3 @@ #!/bin/bash -exec armv7-unknown-linux-ohos-clang++ -fstack-protector-all "$@" \ No newline at end of file +exec armv7-unknown-linux-ohos-clang++ -Imusl -fstack-protector-all "$@" \ No newline at end of file diff --git a/rust-build/tools/x86_64-unknown-linux-ohos-clang b/rust-build/tools/x86_64-unknown-linux-ohos-clang index d9fd8a39a6e59c15d40587d497df69ed76156fd7..c25198e1b58bf5eafa8f9566d59b23032d42e1d4 100644 --- a/rust-build/tools/x86_64-unknown-linux-ohos-clang +++ b/rust-build/tools/x86_64-unknown-linux-ohos-clang @@ -1,3 +1,3 @@ #!/bin/bash -exec x86_64-unknown-linux-ohos-clang -fstack-protector-all "$@" \ No newline at end of file +exec x86_64-unknown-linux-ohos-clang -Imusl -fstack-protector-all "$@" \ No newline at end of file diff --git a/rust-build/tools/x86_64-unknown-linux-ohos-clang++ b/rust-build/tools/x86_64-unknown-linux-ohos-clang++ index dc6aabe137fd25aaac1fb48967bfb0d50c914fa6..3e3dae5b6a12664289d83049b8b6b8544f3066cc 100644 --- a/rust-build/tools/x86_64-unknown-linux-ohos-clang++ +++ b/rust-build/tools/x86_64-unknown-linux-ohos-clang++ @@ -1,3 +1,3 @@ #!/bin/bash -exec x86_64-unknown-linux-ohos-clang++ -fstack-protector-all "$@" \ No newline at end of file +exec x86_64-unknown-linux-ohos-clang++ -Imusl -fstack-protector-all "$@" \ No newline at end of file