From 7e12584d13ede596dbd8f542c3931ec388dc2f8f Mon Sep 17 00:00:00 2001 From: wuhuiquan Date: Wed, 19 Feb 2025 18:17:18 +0800 Subject: [PATCH] [build] add include musl head file path Signed-off-by: wuhuiquan --- rust-build/README.md | 5 +++-- rust-build/function.sh | 13 ++++++++++++- rust-build/ohos_ci_build.sh | 3 ++- rust-build/ohos_ci_test.sh | 3 ++- rust-build/tools/aarch64-unknown-linux-ohos-clang | 2 +- rust-build/tools/aarch64-unknown-linux-ohos-clang++ | 2 +- rust-build/tools/armv7-unknown-linux-ohos-clang | 2 +- rust-build/tools/armv7-unknown-linux-ohos-clang++ | 2 +- rust-build/tools/x86_64-unknown-linux-ohos-clang | 2 +- rust-build/tools/x86_64-unknown-linux-ohos-clang++ | 2 +- 10 files changed, 25 insertions(+), 11 deletions(-) diff --git a/rust-build/README.md b/rust-build/README.md index e2cf3d47df5..3bae7e759e1 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 4f478c3fd45..321395607a2 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 a944fcbb68c..2b151c9011a 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 4572feb91bb..1485bb98a24 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 659e8d4e4e4..5734c03f25d 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 f00223abbf0..260967fbfd2 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 5bea1219712..1d5995aa913 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 f44064a0b79..64211a01597 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 d9fd8a39a6e..c25198e1b58 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 dc6aabe137f..3e3dae5b6a1 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