From 68a0ef271765e3431bee4ee05a32e24c43b8942a Mon Sep 17 00:00:00 2001 From: Sukhikh Alexander Date: Mon, 19 Feb 2024 13:29:02 +0300 Subject: [PATCH 1/2] Revert "[compiler-rt] TMP: disable not working tests and runtimes" This reverts commit 1302f071d4be91f9a31544d460d7d741b28a9c80. Signed-off-by: Sukhikh Alexander --- compiler-rt/cmake/config-ix.cmake | 1 - compiler-rt/lib/CMakeLists.txt | 18 +++--------------- compiler-rt/test/CMakeLists.txt | 18 ++---------------- 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index ac88d54ccfd2..a549732afea0 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -814,7 +814,6 @@ else() endif() #TODO(kostyak): add back Android & Fuchsia when the code settles a bit. -# TODO: Add OHOS when https://gitee.com/openharmony/third_party_musl/pulls/1235 is merged if (SCUDO_STANDALONE_SUPPORTED_ARCH AND OS_NAME MATCHES "Linux" AND COMPILER_RT_HAS_AUXV) set(COMPILER_RT_HAS_SCUDO_STANDALONE TRUE) diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt index 678bc03a8df2..18eed2446dc6 100644 --- a/compiler-rt/lib/CMakeLists.txt +++ b/compiler-rt/lib/CMakeLists.txt @@ -28,11 +28,9 @@ function(compiler_rt_build_runtime runtime) if(${runtime} STREQUAL tsan) add_subdirectory(tsan/dd) endif() - # Disable standalone scudo until this PR merged - # https://gitee.com/openharmony/third_party_musl/pulls/1235/files - # if(${runtime} STREQUAL scudo) - # add_subdirectory(scudo/standalone) - # endif() + if(${runtime} STREQUAL scudo) + add_subdirectory(scudo/standalone) + endif() endif() endfunction() @@ -40,16 +38,6 @@ if(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_MEMPROF) compiler_rt_build_runtime(interception) endif() -# OHOS_LOCAL begin -if(COMPILER_RT_DEFAULT_TARGET_TRIPLE MATCHES "arm-linux-ohos|mipsel-linux-ohos") - # temporary disable scudo and gwp_asan for arm - # arm scudo build failed due to the abcsence of the `_aeabi_unwind_cpp_pr1` symbol - # on mipsel -latomic is not found. - # gwp_asan depends on scudo - list(REMOVE_ITEM COMPILER_RT_SANITIZERS_TO_BUILD "scudo" "gwp_asan") -endif() -# OHOS_LOCAL end - if(COMPILER_RT_BUILD_SANITIZERS) if(COMPILER_RT_HAS_SANITIZER_COMMON) add_subdirectory(stats) diff --git a/compiler-rt/test/CMakeLists.txt b/compiler-rt/test/CMakeLists.txt index e23d48147834..3cbfc4b0e544 100644 --- a/compiler-rt/test/CMakeLists.txt +++ b/compiler-rt/test/CMakeLists.txt @@ -58,16 +58,6 @@ function(compiler_rt_test_runtime runtime) endif() endfunction() -# OHOS_LOCAL begin -if(COMPILER_RT_DEFAULT_TARGET_TRIPLE MATCHES "arm-linux-ohos|mipsel-linux-ohos") - # temporary disable scudo and gwp_asan for arm - # arm scudo build failed due to the abcsence of the `_aeabi_unwind_cpp_pr1` symbol - # on mipsel -latomic is not found. - # gwp_asan depends on scudo - list(REMOVE_ITEM COMPILER_RT_SANITIZERS_TO_BUILD "scudo" "gwp_asan") -endif() -# OHOS_LOCAL end - # Run sanitizer tests only if we're sure that clang would produce # working binaries. if(COMPILER_RT_CAN_EXECUTE_TESTS) @@ -89,13 +79,9 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS) foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD}) # cfi testing is gated on ubsan - # OHOS_LOCAL begin - # can't test gwp-asan, because it is depends on scudo-standalone - if(NOT ${sanitizer} STREQUAL cfi AND - NOT ${sanitizer} STREQUAL gwp_asan) - compiler_rt_test_runtime(${sanitizer}) + if(NOT ${sanitizer} STREQUAL cfi) + compiler_rt_test_runtime(${sanitizer}) endif() - # OHOS_LOCAL end endforeach() endif() if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE) -- Gitee From 750fb65e0920061d62631a1c64241e5416120ea3 Mon Sep 17 00:00:00 2001 From: Sukhikh Alexander Date: Wed, 21 Feb 2024 17:28:51 +0300 Subject: [PATCH 2/2] [compiler-rt] Fix sanitizer build issues for arm and mips Issue: https://gitee.com/openharmony/third_party_llvm-project/issues/I91GO7 Change-Id: Ided87d35042e9aa79e20322a15ae843147c1a01e Signed-off-by: Sukhikh Alexander --- compiler-rt/CMakeLists.txt | 8 ++++++++ compiler-rt/cmake/config-ix.cmake | 2 +- compiler-rt/lib/scudo/standalone/CMakeLists.txt | 11 +++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index 0e3ce2ad7938..98ade77f0d76 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -565,6 +565,14 @@ if(COMPILER_RT_USE_LLVM_UNWINDER) endif() endif() +# OHOS_LOCAL begin +if (COMPILER_RT_HAS_SCUDO_STANDALONE AND + NOT COMPILER_RT_USE_LLVM_UNWINDER AND # unwinder not set yet + COMPILER_RT_DEFAULT_TARGET_TRIPLE MATCHES "^arm-.*") + list(APPEND COMPILER_RT_UNWINDER_LINK_LIBS "unwind") +endif() +# OHOS_LOCAL end + if (COMPILER_RT_CXX_LIBRARY STREQUAL "libcxx") # We are using the in-tree libc++ so avoid including the default one. append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ COMPILER_RT_COMMON_CFLAGS) diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index a549732afea0..3c6fe62e1aaf 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -814,7 +814,7 @@ else() endif() #TODO(kostyak): add back Android & Fuchsia when the code settles a bit. -if (SCUDO_STANDALONE_SUPPORTED_ARCH AND OS_NAME MATCHES "Linux" AND +if (SCUDO_STANDALONE_SUPPORTED_ARCH AND OS_NAME MATCHES "Linux|OHOS" AND COMPILER_RT_HAS_AUXV) set(COMPILER_RT_HAS_SCUDO_STANDALONE TRUE) else() diff --git a/compiler-rt/lib/scudo/standalone/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/CMakeLists.txt index 4b586bc662b4..55e97ac0dadf 100644 --- a/compiler-rt/lib/scudo/standalone/CMakeLists.txt +++ b/compiler-rt/lib/scudo/standalone/CMakeLists.txt @@ -30,7 +30,13 @@ endif() set(SCUDO_LINK_FLAGS) -list(APPEND SCUDO_LINK_FLAGS -Wl,-z,defs,-z,now,-z,relro) +# OHOS_LOCAL begin +# We do not have all symbols at build time (get_platform_gwp_asan_tls_slot), +# since musl is built without them for some reason +if (NOT OHOS) + list(APPEND SCUDO_LINK_FLAGS -Wl,-z,defs,-z,now,-z,relro) +endif() +# OHOS_LOCAL end list(APPEND SCUDO_LINK_FLAGS -ffunction-sections -fdata-sections -Wl,--gc-sections) @@ -141,7 +147,8 @@ append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread SCUDO_LINK_FLAGS) append_list_if(FUCHSIA zircon SCUDO_LINK_LIBS) -if(COMPILER_RT_DEFAULT_TARGET_ARCH MATCHES "mips|mips64|mipsel|mips64el") +if(COMPILER_RT_DEFAULT_TARGET_ARCH MATCHES "mips|mips64|mipsel|mips64el" AND + NOT OHOS) # OHOS_LOCAL OHOS uses compiler-rt list(APPEND SCUDO_LINK_LIBS atomic) endif() -- Gitee