From 223ed705d0d3c3b07f00202a04447df836c05df8 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 2 May 2019 17:43:48 +0000 Subject: [PATCH] [libc++][CMake] Link against libSystem on Apple platforms Instead of manually linking against libm/librt/libpthread, we should be linking against libSystem on Apple platforms, and only that. libm and libpthread are symlinks to libSystem anyway. llvm-svn: 359808 --- libcxx/cmake/config-ix.cmake | 7 +++++++ libcxx/src/CMakeLists.txt | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake index 730ee7e164a6..23ae71025e54 100644 --- a/libcxx/cmake/config-ix.cmake +++ b/libcxx/cmake/config-ix.cmake @@ -80,8 +80,15 @@ if(WIN32 AND NOT MINGW) set(LIBCXX_HAS_PTHREAD_LIB NO) set(LIBCXX_HAS_M_LIB NO) set(LIBCXX_HAS_RT_LIB NO) + set(LIBCXX_HAS_SYSTEM_LIB NO) +elseif(APPLE) + check_library_exists(System write "" LIBCXX_HAS_SYSTEM_LIB) + set(LIBCXX_HAS_PTHREAD_LIB NO) + set(LIBCXX_HAS_M_LIB NO) + set(LIBCXX_HAS_RT_LIB NO) else() check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB) check_library_exists(m ccos "" LIBCXX_HAS_M_LIB) check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB) + set(LIBCXX_HAS_SYSTEM_LIB NO) endif() diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt index 3c31548c2c4c..5d9cc01d165f 100644 --- a/libcxx/src/CMakeLists.txt +++ b/libcxx/src/CMakeLists.txt @@ -140,6 +140,10 @@ function(cxx_link_system_libraries target) target_add_compile_flags_if_supported(${target} PRIVATE "/Zl") target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib") + if (LIBCXX_HAS_SYSTEM_LIB) + target_link_libraries(${target} PUBLIC System) + endif() + if (LIBCXX_HAS_PTHREAD_LIB) target_link_libraries(${target} PUBLIC pthread) endif()