Skip to content

Commit

Permalink
[compiler-rt] Improve defaults for Android
Browse files Browse the repository at this point in the history
Android has only used libc++ for a long time, and since NDK r23, it
also always uses compiler-rt and LLVM's libunwind (which is linked
statically). Reflect these defaults in compiler-rt's build, instead of
requiring the correct settings to always be externally specified.

Reviewed By: srhines

Differential Revision: https://reviews.llvm.org/D158792
  • Loading branch information
smeenai committed Aug 29, 2023
1 parent 3789c23 commit cf403c1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions compiler-rt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ macro(handle_default_cxx_lib var)
if (APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(${var}_LIBNAME "libc++")
set(${var}_SYSTEM 1)
elseif (FUCHSIA)
elseif (ANDROID OR FUCHSIA)
set(${var}_LIBNAME "libc++")
set(${var}_INTREE 1)
else()
Expand Down Expand Up @@ -227,13 +227,19 @@ set(CXXLIBS none default libstdc++ libc++)
set_property(CACHE SANITIZER_TEST_CXX PROPERTY STRINGS ;${CXXLIBS})
handle_default_cxx_lib(SANITIZER_TEST_CXX)

option(COMPILER_RT_USE_LLVM_UNWINDER "Use the LLVM unwinder." OFF)
set(DEFAULT_COMPILER_RT_USE_LLVM_UNWINDER OFF)
if (ANDROID)
set(DEFAULT_COMPILER_RT_USE_LLVM_UNWINDER ON)
endif()

option(COMPILER_RT_USE_LLVM_UNWINDER
"Use the LLVM unwinder." ${DEFAULT_COMPILER_RT_USE_LLVM_UNWINDER})
cmake_dependent_option(COMPILER_RT_ENABLE_STATIC_UNWINDER
"Statically link the LLVM unwinder." OFF
"COMPILER_RT_USE_LLVM_UNWINDER" OFF)

set(DEFAULT_SANITIZER_USE_STATIC_LLVM_UNWINDER OFF)
if (FUCHSIA)
if (ANDROID OR FUCHSIA)
set(DEFAULT_SANITIZER_USE_STATIC_LLVM_UNWINDER ON)
elseif (DEFINED LIBUNWIND_ENABLE_SHARED AND NOT LIBUNWIND_ENABLE_SHARED)
set(DEFAULT_SANITIZER_USE_STATIC_LLVM_UNWINDER ON)
Expand Down Expand Up @@ -271,7 +277,7 @@ cmake_dependent_option(COMPILER_RT_STATIC_CXX_LIBRARY
"COMPILER_RT_CXX_LIBRARY" OFF)

set(DEFAULT_COMPILER_RT_USE_BUILTINS_LIBRARY OFF)
if (FUCHSIA)
if (ANDROID OR FUCHSIA)
set(DEFAULT_COMPILER_RT_USE_BUILTINS_LIBRARY ON)
endif()

Expand Down

0 comments on commit cf403c1

Please sign in to comment.