From d6906be01281e9b39b12ecbbb0f1d755d52e21f7 Mon Sep 17 00:00:00 2001 From: Nenad Miksa Date: Tue, 5 Oct 2021 14:02:36 +0200 Subject: [PATCH] fix build on Alpine Linux - make sure libexecinfo gets linked into compiler-rt when building against musl c library on Alpine Linux --- compiler-rt/cmake/config-ix.cmake | 1 + compiler-rt/lib/scudo/CMakeLists.txt | 2 ++ compiler-rt/lib/scudo/standalone/CMakeLists.txt | 1 + 3 files changed, 4 insertions(+) diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index 39b9120f00adf..73d0278dae114 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -14,6 +14,7 @@ function(compiler_rt_check_linker_flag flag out_var) endfunction() check_library_exists(c fopen "" COMPILER_RT_HAS_LIBC) +check_library_exists(execinfo backtrace "" COMPILER_RT_HAS_EXECINFO) if (COMPILER_RT_USE_BUILTINS_LIBRARY) include(HandleCompilerRT) find_compiler_rt_library(builtins "" COMPILER_RT_BUILTINS_LIBRARY) diff --git a/compiler-rt/lib/scudo/CMakeLists.txt b/compiler-rt/lib/scudo/CMakeLists.txt index e580d6d1408bd..e99364169f492 100644 --- a/compiler-rt/lib/scudo/CMakeLists.txt +++ b/compiler-rt/lib/scudo/CMakeLists.txt @@ -14,11 +14,13 @@ append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread SCUDO_MINIMAL_DYNAMIC_LIBS) append_list_if(COMPILER_RT_HAS_LIBLOG log SCUDO_MINIMAL_DYNAMIC_LIBS) append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer SCUDO_CFLAGS) +append_list_if(COMPILER_RT_HAS_EXECINFO execinfo SCUDO_MINIMAL_DYNAMIC_LIBS) set(SCUDO_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}) # Use gc-sections by default to avoid unused code being pulled in. list(APPEND SCUDO_DYNAMIC_LINK_FLAGS -Wl,--gc-sections) + if(ANDROID) # Put most Sanitizer shared libraries in the global group. For more details, see # android-changes-for-ndk-developers.md#changes-to-library-search-order diff --git a/compiler-rt/lib/scudo/standalone/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/CMakeLists.txt index d6ffa448d7e09..959afedc0c0cd 100644 --- a/compiler-rt/lib/scudo/standalone/CMakeLists.txt +++ b/compiler-rt/lib/scudo/standalone/CMakeLists.txt @@ -134,6 +134,7 @@ endif() set(SCUDO_LINK_LIBS) append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread SCUDO_LINK_FLAGS) +append_list_if(COMPILER_RT_HAS_EXECINFO execinfo SCUDO_LINK_LIBS) append_list_if(FUCHSIA zircon SCUDO_LINK_LIBS)