From c71b2d041fe197fb4e290c6bde6c4e179b5251e8 Mon Sep 17 00:00:00 2001 From: liuyifei Date: Sat, 10 May 2025 08:51:08 +0000 Subject: [PATCH 1/2] =?UTF-8?q?libcxx=5Fpatch=E6=94=AF=E6=8C=81x86?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuyifei --- llvm-build/libcxx_patch/script/build_patch.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/llvm-build/libcxx_patch/script/build_patch.sh b/llvm-build/libcxx_patch/script/build_patch.sh index 44863f92461f..15265f5312ff 100755 --- a/llvm-build/libcxx_patch/script/build_patch.sh +++ b/llvm-build/libcxx_patch/script/build_patch.sh @@ -38,10 +38,14 @@ echo "Building the patch..." echo "BUILD_PATH: $BUILD_PATH" # libc++.so -echo "Copying libc++.so..." +echo "Copying aarch64 libc++.so..." mkdir -p $BUILD_PATH/patch/llvm/system_libcxx/lib/aarch64-linux-ohos cp $LLVM_OUT_PATH/llvm-install/lib/aarch64-linux-ohos/libc++.so $BUILD_PATH/patch/llvm/system_libcxx/lib/aarch64-linux-ohos/ +echo "Copying x86_64 libc++.so..." +mkdir -p $BUILD_PATH/patch/llvm/system_libcxx/lib/x86_64-linux-ohos +cp $LLVM_OUT_PATH/llvm-install/lib/x86_64-linux-ohos/libc++.so $BUILD_PATH/patch/llvm/system_libcxx/lib/x86_64-linux-ohos/ + # __config_site echo "Copying __config_site..." mkdir -p $BUILD_PATH/patch/llvm/system_libcxx/include @@ -55,12 +59,12 @@ cp $LLVM_OUT_PATH/../build/ohos/ndk/cmake/ohos.toolchain.cmake $BUILD_PATH/patch echo "Patching cmake toolchain file..." sed -i '/elseif(OHOS_STL STREQUAL c++_shared)/a\ elseif(OHOS_STL STREQUAL system)\ - # system libcxx is only supported for aarch64-linux-ohos\ - if(OHOS_TOOLCHAIN_NAME STREQUAL aarch64-linux-ohos)\ + # system libcxx is only supported for aarch64-linux-ohos and x86_64-linux-ohos\ + if(OHOS_TOOLCHAIN_NAME STREQUAL aarch64-linux-ohos OR OHOS_TOOLCHAIN_NAME STREQUAL x86_64-linux-ohos)\ include_directories("${OHOS_SDK_NATIVE}/llvm/system_libcxx/include")\ link_directories("${OHOS_SDK_NATIVE}/llvm/system_libcxx/lib/${OHOS_TOOLCHAIN_NAME}")\ else()\ - message(FATAL_ERROR "Unsupported STL configuration: ${OHOS_STL} which is only available for aarch64-linux-ohos.")\ + message(FATAL_ERROR "Unsupported STL configuration: ${OHOS_STL} which is only available for aarch64-linux-ohos and x86_64-linux-ohos.")\ endif()' $BUILD_PATH/patch/build/cmake/ohos.toolchain.cmake # script.sh -- Gitee From 640d48346b91c7b4a7dbdaf15d4a4aba43bfc9b6 Mon Sep 17 00:00:00 2001 From: liuyifei Date: Tue, 13 May 2025 07:52:35 +0000 Subject: [PATCH 2/2] =?UTF-8?q?libcxx=5Fpatch=E6=94=AF=E6=8C=81x86?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0-2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuyifei --- llvm-build/libcxx_patch/script/install.sh | 46 +++++++++++---------- llvm-build/libcxx_patch/test/CMakeLists.txt | 1 - 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/llvm-build/libcxx_patch/script/install.sh b/llvm-build/libcxx_patch/script/install.sh index b535caff2e5f..18abeded0d08 100755 --- a/llvm-build/libcxx_patch/script/install.sh +++ b/llvm-build/libcxx_patch/script/install.sh @@ -62,30 +62,34 @@ fi # == test c++_shared == # build the test -BUILD_PATH_SHARED=/tmp/libcxx_patch_c++_shared_$(($RANDOM + $(date +%s))) -echo "Testing OHOS_STL=c++_shared..." -$CMAKE -DOHOS_STL=c++_shared -DCMAKE_TOOLCHAIN_FILE=$INSTALL_PATH/build/cmake/ohos.toolchain.cmake -B $BUILD_PATH_SHARED -S $SCRIPT_PATH/../test > /dev/null -$CMAKE --build $BUILD_PATH_SHARED > /dev/null -# check the shared library using readelf -$READELF -d $BUILD_PATH_SHARED/test | grep libc++_shared.so -if [ $? -ne 0 ]; then - echo "Error: Test failed: The libc++_shared.so is not linked." - exit 1 -fi +ARCH_LIST=("arm64-v8a" "x86_64") +for ARCH in "${ARCH_LIST[@]}"; do + BUILD_PATH_SHARED=/tmp/libcxx_patch_c++_shared_$(($RANDOM + $(date +%s))) + echo "Testing OHOS_STL=c++_shared with OHOS_ARCH=${ARCH}..." + $CMAKE -DOHOS_STL=c++_shared -DCMAKE_TOOLCHAIN_FILE=$INSTALL_PATH/build/cmake/ohos.toolchain.cmake -DOHOS_ARCH=$ARCH -B $BUILD_PATH_SHARED -S $SCRIPT_PATH/../test > /dev/null + $CMAKE --build $BUILD_PATH_SHARED > /dev/null + # check the shared library using readelf + $READELF -d $BUILD_PATH_SHARED/test | grep libc++_shared.so + if [ $? -ne 0 ]; then + echo "Error: Test failed: The libc++_shared.so is not linked for OHOS_ARCH=${ARCH}." + exit 1 + fi +done # == test system == # build the test - -BUILD_PATH_SYSTEM=/tmp/libcxx_patch_c++_system_$(($RANDOM + $(date +%s))) -echo "Testing OHOS_STL=system..." -$CMAKE -DOHOS_STL=system -DCMAKE_TOOLCHAIN_FILE=$INSTALL_PATH/build/cmake/ohos.toolchain.cmake -B $BUILD_PATH_SYSTEM -S $SCRIPT_PATH/../test > /dev/null -$CMAKE --build $BUILD_PATH_SYSTEM > /dev/null -# check the shared library using readelf -$READELF -d $BUILD_PATH_SYSTEM/test | grep libc++.so -if [ $? -ne 0 ]; then - echo "Error: Test failed: The libc++.so is not linked." - exit 1 -fi +for ARCH in "${ARCH_LIST[@]}"; do + BUILD_PATH_SYSTEM=/tmp/libcxx_patch_c++_system_$(($RANDOM + $(date +%s))) + echo "Testing OHOS_STL=system with OHOS_ARCH=${ARCH}..." + $CMAKE -DOHOS_STL=system -DCMAKE_TOOLCHAIN_FILE=$INSTALL_PATH/build/cmake/ohos.toolchain.cmake -DOHOS_ARCH=$ARCH -B $BUILD_PATH_SYSTEM -S $SCRIPT_PATH/../test > /dev/null + $CMAKE --build $BUILD_PATH_SYSTEM > /dev/null + # check the shared library using readelf + $READELF -d $BUILD_PATH_SYSTEM/test | grep libc++.so + if [ $? -ne 0 ]; then + echo "Error: Test failed: The libc++.so is not linked for OHOS_ARCH=${ARCH}." + exit 1 + fi +done echo "All tests passed." echo "Patch installed successfully." diff --git a/llvm-build/libcxx_patch/test/CMakeLists.txt b/llvm-build/libcxx_patch/test/CMakeLists.txt index a58165fed428..ea7c882f6ac8 100644 --- a/llvm-build/libcxx_patch/test/CMakeLists.txt +++ b/llvm-build/libcxx_patch/test/CMakeLists.txt @@ -15,7 +15,6 @@ cmake_minimum_required(VERSION 3.16) project(ndk-patch-test) -set(OHOS_ARCH arm64-v8a) set(OHOS_PLATFORM OHOS) add_compile_options(-Wno-unused-command-line-argument) -- Gitee