Skip to content

Commit cc25963

Browse files
committed
[libcxx][libcxxabi][libunwind] Use libgcc on Android
Android doesn't have a libgcc_s and uses libgcc instead, so adjust the build accordingly. This matches compiler-rt's build setup. libc++abi and libunwind were already checking for libgcc but in a different context. This change makes them search only for libgcc on Android now, but the code to link against libgcc if it were present was already there. Reviewed By: #libc, #libc_abi, #libunwind, rprichard, srhines Differential Revision: https://reviews.llvm.org/D78787
1 parent c14ac80 commit cc25963

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

libcxx/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ function(cxx_link_system_libraries target)
757757
if (LIBCXX_BUILTINS_LIBRARY)
758758
target_link_libraries(${target} PRIVATE "${LIBCXX_BUILTINS_LIBRARY}")
759759
endif()
760+
elseif (LIBCXX_HAS_GCC_LIB)
761+
target_link_libraries(${target} PRIVATE gcc)
760762
elseif (LIBCXX_HAS_GCC_S_LIB)
761763
target_link_libraries(${target} PRIVATE gcc_s)
762764
endif()

libcxx/cmake/config-ix.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ if (NOT LIBCXX_USE_COMPILER_RT)
1616
if(WIN32 AND NOT MINGW)
1717
set(LIBCXX_HAS_GCC_S_LIB NO)
1818
else()
19-
check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
19+
if(ANDROID)
20+
check_library_exists(gcc __gcc_personality_v0 "" LIBCXX_HAS_GCC_LIB)
21+
else()
22+
check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
23+
endif()
2024
endif()
2125
endif()
2226

@@ -37,6 +41,8 @@ if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
3741
list(APPEND CMAKE_REQUIRED_FLAGS -rtlib=compiler-rt)
3842
find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY)
3943
list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBCXX_BUILTINS_LIBRARY}")
44+
elseif (LIBCXX_HAS_GCC_LIB)
45+
list(APPEND CMAKE_REQUIRED_LIBRARIES gcc)
4046
elseif (LIBCXX_HAS_GCC_S_LIB)
4147
list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
4248
endif ()

libcxxabi/cmake/config-ix.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ include(CheckCSourceCompiles)
66

77
check_library_exists(c fopen "" LIBCXXABI_HAS_C_LIB)
88
if (NOT LIBCXXABI_USE_COMPILER_RT)
9-
check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_S_LIB)
10-
check_library_exists(gcc __aeabi_uldivmod "" LIBCXXABI_HAS_GCC_LIB)
9+
if (ANDROID)
10+
check_library_exists(gcc __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_LIB)
11+
else ()
12+
check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_S_LIB)
13+
check_library_exists(gcc __aeabi_uldivmod "" LIBCXXABI_HAS_GCC_LIB)
14+
endif ()
1115
endif ()
1216

1317
# libc++abi is built with -nodefaultlibs, so we want all our checks to also

libunwind/cmake/config-ix.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ include(CheckCSourceCompiles)
88
check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)
99

1010
if (NOT LIBUNWIND_USE_COMPILER_RT)
11-
check_library_exists(gcc_s __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_S_LIB)
12-
check_library_exists(gcc __absvdi2 "" LIBUNWIND_HAS_GCC_LIB)
11+
if (ANDROID)
12+
check_library_exists(gcc __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_LIB)
13+
else ()
14+
check_library_exists(gcc_s __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_S_LIB)
15+
check_library_exists(gcc __absvdi2 "" LIBUNWIND_HAS_GCC_LIB)
16+
endif ()
1317
endif()
1418

1519
# libunwind is built with -nodefaultlibs, so we want all our checks to also

0 commit comments

Comments
 (0)