2015-03-31 12:15:45 +08:00
|
|
|
set(LIBCXX_LIB_CMAKEFILES_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}" PARENT_SCOPE)
|
|
|
|
|
2010-12-11 03:47:54 +08:00
|
|
|
# Get sources
|
2019-05-01 14:40:36 +08:00
|
|
|
set(LIBCXX_SOURCES
|
|
|
|
algorithm.cpp
|
|
|
|
any.cpp
|
2020-02-18 22:58:34 +08:00
|
|
|
atomic.cpp
|
|
|
|
barrier.cpp
|
2019-05-01 14:40:36 +08:00
|
|
|
bind.cpp
|
|
|
|
charconv.cpp
|
|
|
|
chrono.cpp
|
|
|
|
condition_variable.cpp
|
2019-07-08 01:24:03 +08:00
|
|
|
condition_variable_destructor.cpp
|
2019-05-01 14:40:36 +08:00
|
|
|
exception.cpp
|
2020-11-27 02:12:18 +08:00
|
|
|
format.cpp
|
2019-05-01 14:40:36 +08:00
|
|
|
functional.cpp
|
|
|
|
future.cpp
|
|
|
|
hash.cpp
|
|
|
|
include/apple_availability.h
|
|
|
|
include/atomic_support.h
|
|
|
|
include/config_elast.h
|
|
|
|
include/refstring.h
|
|
|
|
memory.cpp
|
|
|
|
mutex.cpp
|
2019-07-07 09:20:54 +08:00
|
|
|
mutex_destructor.cpp
|
2019-05-01 14:40:36 +08:00
|
|
|
new.cpp
|
|
|
|
optional.cpp
|
2020-07-01 00:42:44 +08:00
|
|
|
random_shuffle.cpp
|
2019-05-01 14:40:36 +08:00
|
|
|
shared_mutex.cpp
|
|
|
|
stdexcept.cpp
|
|
|
|
string.cpp
|
|
|
|
support/runtime/exception_fallback.ipp
|
|
|
|
support/runtime/exception_glibcxx.ipp
|
|
|
|
support/runtime/exception_libcxxabi.ipp
|
|
|
|
support/runtime/exception_libcxxrt.ipp
|
|
|
|
support/runtime/exception_msvc.ipp
|
|
|
|
support/runtime/exception_pointer_cxxabi.ipp
|
|
|
|
support/runtime/exception_pointer_glibcxx.ipp
|
|
|
|
support/runtime/exception_pointer_msvc.ipp
|
|
|
|
support/runtime/exception_pointer_unimplemented.ipp
|
|
|
|
support/runtime/new_handler_fallback.ipp
|
|
|
|
support/runtime/stdexcept_default.ipp
|
|
|
|
support/runtime/stdexcept_vcruntime.ipp
|
|
|
|
system_error.cpp
|
|
|
|
thread.cpp
|
|
|
|
typeinfo.cpp
|
|
|
|
utility.cpp
|
|
|
|
valarray.cpp
|
|
|
|
variant.cpp
|
|
|
|
vector.cpp
|
|
|
|
)
|
|
|
|
|
2020-10-10 02:39:20 +08:00
|
|
|
if (LIBCXX_ENABLE_DEBUG_MODE_SUPPORT)
|
2020-10-07 22:33:40 +08:00
|
|
|
list(APPEND LIBCXX_SOURCES
|
|
|
|
debug.cpp
|
|
|
|
)
|
2020-10-07 04:46:58 +08:00
|
|
|
endif()
|
|
|
|
|
2020-10-15 22:32:09 +08:00
|
|
|
if (LIBCXX_ENABLE_RANDOM_DEVICE)
|
|
|
|
list(APPEND LIBCXX_SOURCES
|
|
|
|
random.cpp
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2020-10-10 03:31:05 +08:00
|
|
|
if (LIBCXX_ENABLE_LOCALIZATION)
|
|
|
|
list(APPEND LIBCXX_SOURCES
|
|
|
|
ios.cpp
|
2020-11-02 23:30:29 +08:00
|
|
|
ios.instantiations.cpp
|
2020-10-10 03:31:05 +08:00
|
|
|
iostream.cpp
|
|
|
|
locale.cpp
|
|
|
|
regex.cpp
|
|
|
|
strstream.cpp
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2011-09-23 03:10:18 +08:00
|
|
|
if(WIN32)
|
2019-05-01 14:40:36 +08:00
|
|
|
list(APPEND LIBCXX_SOURCES
|
|
|
|
support/win32/locale_win32.cpp
|
|
|
|
support/win32/support.cpp
|
|
|
|
)
|
2021-02-16 23:03:04 +08:00
|
|
|
|
|
|
|
if (NOT LIBCXX_HAS_PTHREAD_API)
|
|
|
|
list(APPEND LIBCXX_SOURCES
|
|
|
|
support/win32/thread_win32.cpp
|
|
|
|
)
|
|
|
|
endif()
|
2014-11-26 05:57:41 +08:00
|
|
|
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
|
2019-05-01 14:40:36 +08:00
|
|
|
list(APPEND LIBCXX_SOURCES
|
|
|
|
support/solaris/mbsnrtowcs.inc
|
|
|
|
support/solaris/wcsnrtombs.inc
|
|
|
|
support/solaris/xlocale.cpp
|
|
|
|
)
|
2021-03-09 03:20:22 +08:00
|
|
|
elseif(ZOS)
|
|
|
|
list(APPEND LIBCXX_SOURCES
|
|
|
|
support/ibm/xlocale_zos.cpp
|
|
|
|
)
|
2011-09-23 03:10:18 +08:00
|
|
|
endif()
|
2010-12-11 03:47:54 +08:00
|
|
|
|
2019-03-21 08:04:31 +08:00
|
|
|
if (LIBCXX_ENABLE_FILESYSTEM)
|
2019-05-01 14:40:36 +08:00
|
|
|
list(APPEND LIBCXX_SOURCES
|
|
|
|
filesystem/filesystem_common.h
|
|
|
|
filesystem/operations.cpp
|
|
|
|
filesystem/directory_iterator.cpp
|
2020-11-04 22:59:07 +08:00
|
|
|
filesystem/posix_compat.h
|
2019-05-01 14:40:36 +08:00
|
|
|
)
|
2019-03-21 08:04:31 +08:00
|
|
|
# Filesystem uses __int128_t, which requires a definition of __muloi4 when
|
|
|
|
# compiled with UBSAN. This definition is not provided by libgcc_s, but is
|
|
|
|
# provided by compiler-rt. So we need to disable it to avoid having multiple
|
|
|
|
# definitions. See filesystem/int128_builtins.cpp.
|
|
|
|
if (NOT LIBCXX_USE_COMPILER_RT)
|
2019-05-01 14:40:36 +08:00
|
|
|
list(APPEND LIBCXX_SOURCES
|
|
|
|
filesystem/int128_builtins.cpp
|
|
|
|
)
|
2019-03-21 08:04:31 +08:00
|
|
|
endif()
|
[libc++] Build <filesystem> support as part of the dylib
Summary:
This patch treats <filesystem> as a first-class citizen of the dylib,
like all other sub-libraries (e.g. <chrono>). As such, it also removes
all special handling for installing the filesystem library separately
or disabling part of the test suite from the lit command line.
Unlike the previous attempt (r356500), this doesn't remove all the
filesystem tests.
Reviewers: mclow.lists, EricWF, serge-sans-paille
Subscribers: mgorny, christof, jkorous, dexonsmith, jfb, jdoerfert, libcxx-commits
Differential Revision: https://reviews.llvm.org/D59152
llvm-svn: 356518
2019-03-20 04:56:13 +08:00
|
|
|
endif()
|
|
|
|
|
2010-12-11 03:47:54 +08:00
|
|
|
# Add all the headers to the project for IDEs.
|
2015-12-17 07:41:05 +08:00
|
|
|
if (LIBCXX_CONFIGURE_IDE)
|
2012-03-19 23:40:23 +08:00
|
|
|
file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
|
2011-09-23 03:10:18 +08:00
|
|
|
if(WIN32)
|
2021-02-03 05:58:38 +08:00
|
|
|
file( GLOB LIBCXX_WIN32_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/__support/win32/*.h)
|
2012-03-19 23:40:23 +08:00
|
|
|
list(APPEND LIBCXX_HEADERS ${LIBCXX_WIN32_HEADERS})
|
2011-09-23 03:10:18 +08:00
|
|
|
endif()
|
2010-12-11 03:47:54 +08:00
|
|
|
# Force them all into the headers dir on MSVC, otherwise they end up at
|
|
|
|
# project scope because they don't have extensions.
|
|
|
|
if (MSVC_IDE)
|
2012-03-19 23:40:23 +08:00
|
|
|
source_group("Header Files" FILES ${LIBCXX_HEADERS})
|
2010-12-11 03:47:54 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-12-04 02:52:54 +08:00
|
|
|
if(NOT LIBCXX_INSTALL_LIBRARY)
|
|
|
|
set(exclude_from_all EXCLUDE_FROM_ALL)
|
|
|
|
endif()
|
|
|
|
|
2017-01-04 13:49:55 +08:00
|
|
|
# If LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path.
|
|
|
|
add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH
|
|
|
|
"${CMAKE_LIBRARY_PATH_FLAG}${LIBCXX_CXX_ABI_LIBRARY_PATH}")
|
2015-07-30 05:07:28 +08:00
|
|
|
|
2017-03-11 11:24:18 +08:00
|
|
|
|
|
|
|
if (LIBCXX_GENERATE_COVERAGE AND NOT LIBCXX_COVERAGE_LIBRARY)
|
|
|
|
find_compiler_rt_library(profile LIBCXX_COVERAGE_LIBRARY)
|
|
|
|
endif()
|
2015-07-31 06:30:34 +08:00
|
|
|
add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
|
|
|
|
|
2015-07-22 08:33:36 +08:00
|
|
|
if (APPLE AND LLVM_USE_SANITIZER)
|
2016-09-15 19:04:53 +08:00
|
|
|
if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR
|
|
|
|
("${LLVM_USE_SANITIZER}" STREQUAL "Address;Undefined") OR
|
|
|
|
("${LLVM_USE_SANITIZER}" STREQUAL "Undefined;Address"))
|
2015-07-22 08:33:36 +08:00
|
|
|
set(LIBFILE "libclang_rt.asan_osx_dynamic.dylib")
|
|
|
|
elseif("${LLVM_USE_SANITIZER}" STREQUAL "Undefined")
|
|
|
|
set(LIBFILE "libclang_rt.ubsan_osx_dynamic.dylib")
|
2016-09-14 22:12:50 +08:00
|
|
|
elseif("${LLVM_USE_SANITIZER}" STREQUAL "Thread")
|
|
|
|
set(LIBFILE "libclang_rt.tsan_osx_dynamic.dylib")
|
2015-07-22 08:33:36 +08:00
|
|
|
else()
|
|
|
|
message(WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not supported on OS X")
|
|
|
|
endif()
|
|
|
|
if (LIBFILE)
|
2017-03-11 11:24:18 +08:00
|
|
|
find_compiler_rt_dir(LIBDIR)
|
2015-07-22 08:33:36 +08:00
|
|
|
if (NOT IS_DIRECTORY "${LIBDIR}")
|
|
|
|
message(FATAL_ERROR "Cannot find compiler-rt directory on OS X required for LLVM_USE_SANITIZER")
|
|
|
|
endif()
|
|
|
|
set(LIBCXX_SANITIZER_LIBRARY "${LIBDIR}/${LIBFILE}")
|
|
|
|
set(LIBCXX_SANITIZER_LIBRARY "${LIBCXX_SANITIZER_LIBRARY}" PARENT_SCOPE)
|
|
|
|
message(STATUS "Manually linking compiler-rt library: ${LIBCXX_SANITIZER_LIBRARY}")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_library_flags("${LIBCXX_SANITIZER_LIBRARY}")
|
|
|
|
add_link_flags("-Wl,-rpath,${LIBDIR}")
|
2015-07-22 08:33:36 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-08-06 02:29:14 +08:00
|
|
|
if (LIBCXX_ENABLE_PARALLEL_ALGORITHMS AND NOT TARGET pstl::ParallelSTL)
|
|
|
|
message(FATAL_ERROR "Could not find ParallelSTL")
|
|
|
|
endif()
|
|
|
|
|
[libc++] Do not share an object library to create the static/shared libraries
Summary:
The problem with using an object library for doing this is that it prevents
the shared library and the static library from being built with the right
default flags. For example, CMake will build shared libraries with -fPIC
by default, but not static libraries. Using an object library to create
the shared library will prevent the right default flags for shared
libraries from being used.
As a side effect, this patch also localizes the logic related to building
a hermetic static library to the static library case, making clear that
this has no effect on the shared library.
Reviewers: phosek, EricWF
Subscribers: mgorny, christof, jkorous, dexonsmith, jdoerfert, libcxx-commits
Differential Revision: https://reviews.llvm.org/D59248
llvm-svn: 356150
2019-03-14 22:19:08 +08:00
|
|
|
function(cxx_set_common_defines name)
|
2019-01-06 14:14:31 +08:00
|
|
|
if(LIBCXX_CXX_ABI_HEADER_TARGET)
|
|
|
|
add_dependencies(${name} ${LIBCXX_CXX_ABI_HEADER_TARGET})
|
|
|
|
endif()
|
2019-08-06 02:29:14 +08:00
|
|
|
|
|
|
|
if (LIBCXX_ENABLE_PARALLEL_ALGORITHMS)
|
|
|
|
target_link_libraries(${name} PUBLIC pstl::ParallelSTL)
|
|
|
|
endif()
|
[libc++] Do not share an object library to create the static/shared libraries
Summary:
The problem with using an object library for doing this is that it prevents
the shared library and the static library from being built with the right
default flags. For example, CMake will build shared libraries with -fPIC
by default, but not static libraries. Using an object library to create
the shared library will prevent the right default flags for shared
libraries from being used.
As a side effect, this patch also localizes the logic related to building
a hermetic static library to the static library case, making clear that
this has no effect on the shared library.
Reviewers: phosek, EricWF
Subscribers: mgorny, christof, jkorous, dexonsmith, jdoerfert, libcxx-commits
Differential Revision: https://reviews.llvm.org/D59248
llvm-svn: 356150
2019-03-14 22:19:08 +08:00
|
|
|
endfunction()
|
2019-01-06 14:14:31 +08:00
|
|
|
|
[libc++] Do not share an object library to create the static/shared libraries
Summary:
The problem with using an object library for doing this is that it prevents
the shared library and the static library from being built with the right
default flags. For example, CMake will build shared libraries with -fPIC
by default, but not static libraries. Using an object library to create
the shared library will prevent the right default flags for shared
libraries from being used.
As a side effect, this patch also localizes the logic related to building
a hermetic static library to the static library case, making clear that
this has no effect on the shared library.
Reviewers: phosek, EricWF
Subscribers: mgorny, christof, jkorous, dexonsmith, jdoerfert, libcxx-commits
Differential Revision: https://reviews.llvm.org/D59248
llvm-svn: 356150
2019-03-14 22:19:08 +08:00
|
|
|
split_list(LIBCXX_COMPILE_FLAGS)
|
|
|
|
split_list(LIBCXX_LINK_FLAGS)
|
2016-08-09 06:57:25 +08:00
|
|
|
|
|
|
|
# Build the shared library.
|
|
|
|
if (LIBCXX_ENABLE_SHARED)
|
[libc++] Do not share an object library to create the static/shared libraries
Summary:
The problem with using an object library for doing this is that it prevents
the shared library and the static library from being built with the right
default flags. For example, CMake will build shared libraries with -fPIC
by default, but not static libraries. Using an object library to create
the shared library will prevent the right default flags for shared
libraries from being used.
As a side effect, this patch also localizes the logic related to building
a hermetic static library to the static library case, making clear that
this has no effect on the shared library.
Reviewers: phosek, EricWF
Subscribers: mgorny, christof, jkorous, dexonsmith, jdoerfert, libcxx-commits
Differential Revision: https://reviews.llvm.org/D59248
llvm-svn: 356150
2019-03-14 22:19:08 +08:00
|
|
|
add_library(cxx_shared SHARED ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
|
2020-06-27 04:05:55 +08:00
|
|
|
target_link_libraries(cxx_shared PUBLIC cxx-headers
|
|
|
|
PRIVATE ${LIBCXX_LIBRARIES})
|
2016-08-09 06:57:25 +08:00
|
|
|
set_target_properties(cxx_shared
|
|
|
|
PROPERTIES
|
[libc++] Do not share an object library to create the static/shared libraries
Summary:
The problem with using an object library for doing this is that it prevents
the shared library and the static library from being built with the right
default flags. For example, CMake will build shared libraries with -fPIC
by default, but not static libraries. Using an object library to create
the shared library will prevent the right default flags for shared
libraries from being used.
As a side effect, this patch also localizes the logic related to building
a hermetic static library to the static library case, making clear that
this has no effect on the shared library.
Reviewers: phosek, EricWF
Subscribers: mgorny, christof, jkorous, dexonsmith, jdoerfert, libcxx-commits
Differential Revision: https://reviews.llvm.org/D59248
llvm-svn: 356150
2019-03-14 22:19:08 +08:00
|
|
|
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
|
2016-08-09 06:57:25 +08:00
|
|
|
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
|
|
|
|
OUTPUT_NAME "c++"
|
|
|
|
VERSION "${LIBCXX_ABI_VERSION}.0"
|
|
|
|
SOVERSION "${LIBCXX_ABI_VERSION}"
|
2019-03-15 01:15:47 +08:00
|
|
|
DEFINE_SYMBOL ""
|
2010-12-11 03:47:54 +08:00
|
|
|
)
|
2019-10-05 06:50:23 +08:00
|
|
|
cxx_add_common_build_flags(cxx_shared)
|
[libc++] Do not share an object library to create the static/shared libraries
Summary:
The problem with using an object library for doing this is that it prevents
the shared library and the static library from being built with the right
default flags. For example, CMake will build shared libraries with -fPIC
by default, but not static libraries. Using an object library to create
the shared library will prevent the right default flags for shared
libraries from being used.
As a side effect, this patch also localizes the logic related to building
a hermetic static library to the static library case, making clear that
this has no effect on the shared library.
Reviewers: phosek, EricWF
Subscribers: mgorny, christof, jkorous, dexonsmith, jdoerfert, libcxx-commits
Differential Revision: https://reviews.llvm.org/D59248
llvm-svn: 356150
2019-03-14 22:19:08 +08:00
|
|
|
cxx_set_common_defines(cxx_shared)
|
|
|
|
|
2019-04-18 05:41:09 +08:00
|
|
|
# Link against LLVM libunwind
|
|
|
|
if (LIBCXXABI_USE_LLVM_UNWINDER)
|
|
|
|
if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
|
2019-04-30 23:44:19 +08:00
|
|
|
target_link_libraries(cxx_shared PUBLIC unwind_shared)
|
2019-04-18 05:41:09 +08:00
|
|
|
elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND))
|
|
|
|
# libunwind is already included in libc++abi
|
|
|
|
else()
|
2019-10-09 05:10:20 +08:00
|
|
|
target_link_libraries(cxx_shared PUBLIC unwind)
|
2019-04-18 05:41:09 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-04-06 04:29:54 +08:00
|
|
|
# Link against libc++abi
|
|
|
|
if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
|
|
|
|
if (APPLE)
|
2019-04-09 22:31:09 +08:00
|
|
|
target_link_libraries(cxx_shared PRIVATE "-Wl,-force_load" "${LIBCXX_CXX_STATIC_ABI_LIBRARY}")
|
2019-04-06 04:29:54 +08:00
|
|
|
else()
|
2019-04-09 22:31:09 +08:00
|
|
|
target_link_libraries(cxx_shared PRIVATE "-Wl,--whole-archive,-Bstatic" "${LIBCXX_CXX_STATIC_ABI_LIBRARY}" "-Wl,-Bdynamic,--no-whole-archive")
|
2019-04-06 04:29:54 +08:00
|
|
|
endif()
|
|
|
|
else()
|
2019-04-30 23:44:19 +08:00
|
|
|
target_link_libraries(cxx_shared PUBLIC "${LIBCXX_CXX_SHARED_ABI_LIBRARY}")
|
2019-04-06 04:29:54 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Maybe re-export symbols from libc++abi
|
2021-01-23 01:39:17 +08:00
|
|
|
# In particular, we don't re-export the symbols if libc++abi is merged statically
|
|
|
|
# into libc++ because in that case there's no dylib to re-export from.
|
2019-04-06 04:29:54 +08:00
|
|
|
if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
|
|
|
|
LIBCXX_CXX_ABI_LIBNAME STREQUAL "default")
|
2021-01-23 01:39:17 +08:00
|
|
|
AND NOT DEFINED LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS
|
|
|
|
AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
|
2019-04-06 04:29:54 +08:00
|
|
|
set(LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS)
|
|
|
|
target_link_libraries(cxx_shared PRIVATE
|
2019-05-01 14:40:36 +08:00
|
|
|
"-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++unexp.exp"
|
2020-04-20 17:22:20 +08:00
|
|
|
"-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++abi.v${LIBCXX_LIBCPPABI_VERSION}.exp"
|
2020-10-05 23:42:13 +08:00
|
|
|
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
|
|
|
|
"-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp")
|
2020-10-23 22:02:14 +08:00
|
|
|
|
2020-10-24 04:27:41 +08:00
|
|
|
target_link_libraries(cxx_shared PRIVATE $<TARGET_NAME_IF_EXISTS:cxxabi-reexports>)
|
2019-04-06 04:29:54 +08:00
|
|
|
endif()
|
|
|
|
|
2019-10-09 05:10:20 +08:00
|
|
|
# Generate a linker script in place of a libc++.so symlink.
|
2019-04-06 04:29:54 +08:00
|
|
|
if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
|
2019-10-09 05:10:20 +08:00
|
|
|
include(DefineLinkerScript)
|
|
|
|
define_linker_script(cxx_shared)
|
2019-04-06 04:29:54 +08:00
|
|
|
endif()
|
|
|
|
|
2018-07-25 07:27:51 +08:00
|
|
|
list(APPEND LIBCXX_BUILD_TARGETS "cxx_shared")
|
2017-01-03 05:09:19 +08:00
|
|
|
if(WIN32 AND NOT MINGW AND NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
|
|
|
|
# Since we most likely do not have a mt.exe replacement, disable the
|
|
|
|
# manifest bundling. This allows a normal cmake invocation to pass which
|
|
|
|
# will attempt to use the manifest tool to generate the bundled manifest
|
|
|
|
set_target_properties(cxx_shared PROPERTIES
|
|
|
|
APPEND_STRING PROPERTY LINK_FLAGS " /MANIFEST:NO")
|
|
|
|
endif()
|
2016-08-09 06:57:25 +08:00
|
|
|
endif()
|
|
|
|
|
2021-03-23 19:23:16 +08:00
|
|
|
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
|
|
|
|
|
2016-08-09 06:57:25 +08:00
|
|
|
# Build the static library.
|
|
|
|
if (LIBCXX_ENABLE_STATIC)
|
[libc++] Do not share an object library to create the static/shared libraries
Summary:
The problem with using an object library for doing this is that it prevents
the shared library and the static library from being built with the right
default flags. For example, CMake will build shared libraries with -fPIC
by default, but not static libraries. Using an object library to create
the shared library will prevent the right default flags for shared
libraries from being used.
As a side effect, this patch also localizes the logic related to building
a hermetic static library to the static library case, making clear that
this has no effect on the shared library.
Reviewers: phosek, EricWF
Subscribers: mgorny, christof, jkorous, dexonsmith, jdoerfert, libcxx-commits
Differential Revision: https://reviews.llvm.org/D59248
llvm-svn: 356150
2019-03-14 22:19:08 +08:00
|
|
|
add_library(cxx_static STATIC ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
|
2020-06-27 04:05:55 +08:00
|
|
|
target_link_libraries(cxx_static PUBLIC cxx-headers
|
|
|
|
PRIVATE ${LIBCXX_LIBRARIES})
|
2016-08-09 06:57:25 +08:00
|
|
|
set_target_properties(cxx_static
|
|
|
|
PROPERTIES
|
[libc++] Do not share an object library to create the static/shared libraries
Summary:
The problem with using an object library for doing this is that it prevents
the shared library and the static library from being built with the right
default flags. For example, CMake will build shared libraries with -fPIC
by default, but not static libraries. Using an object library to create
the shared library will prevent the right default flags for shared
libraries from being used.
As a side effect, this patch also localizes the logic related to building
a hermetic static library to the static library case, making clear that
this has no effect on the shared library.
Reviewers: phosek, EricWF
Subscribers: mgorny, christof, jkorous, dexonsmith, jdoerfert, libcxx-commits
Differential Revision: https://reviews.llvm.org/D59248
llvm-svn: 356150
2019-03-14 22:19:08 +08:00
|
|
|
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
|
2016-08-09 06:57:25 +08:00
|
|
|
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
|
2017-05-26 06:37:15 +08:00
|
|
|
OUTPUT_NAME "c++"
|
2016-08-09 06:57:25 +08:00
|
|
|
)
|
2019-10-05 06:50:23 +08:00
|
|
|
cxx_add_common_build_flags(cxx_static)
|
2019-03-14 22:52:26 +08:00
|
|
|
cxx_set_common_defines(cxx_static)
|
[libc++] Do not share an object library to create the static/shared libraries
Summary:
The problem with using an object library for doing this is that it prevents
the shared library and the static library from being built with the right
default flags. For example, CMake will build shared libraries with -fPIC
by default, but not static libraries. Using an object library to create
the shared library will prevent the right default flags for shared
libraries from being used.
As a side effect, this patch also localizes the logic related to building
a hermetic static library to the static library case, making clear that
this has no effect on the shared library.
Reviewers: phosek, EricWF
Subscribers: mgorny, christof, jkorous, dexonsmith, jdoerfert, libcxx-commits
Differential Revision: https://reviews.llvm.org/D59248
llvm-svn: 356150
2019-03-14 22:19:08 +08:00
|
|
|
|
|
|
|
if (LIBCXX_HERMETIC_STATIC_LIBRARY)
|
2019-05-06 09:22:28 +08:00
|
|
|
# If the hermetic library doesn't define the operator new/delete functions
|
|
|
|
# then its code shouldn't declare them with hidden visibility. They might
|
|
|
|
# actually be provided by a shared library at link time.
|
|
|
|
if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
|
|
|
|
append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden)
|
|
|
|
endif()
|
[libc++] Do not share an object library to create the static/shared libraries
Summary:
The problem with using an object library for doing this is that it prevents
the shared library and the static library from being built with the right
default flags. For example, CMake will build shared libraries with -fPIC
by default, but not static libraries. Using an object library to create
the shared library will prevent the right default flags for shared
libraries from being used.
As a side effect, this patch also localizes the logic related to building
a hermetic static library to the static library case, making clear that
this has no effect on the shared library.
Reviewers: phosek, EricWF
Subscribers: mgorny, christof, jkorous, dexonsmith, jdoerfert, libcxx-commits
Differential Revision: https://reviews.llvm.org/D59248
llvm-svn: 356150
2019-03-14 22:19:08 +08:00
|
|
|
target_compile_options(cxx_static PRIVATE ${CXX_STATIC_LIBRARY_FLAGS})
|
|
|
|
target_compile_definitions(cxx_static PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
|
|
|
endif()
|
|
|
|
|
2018-07-25 07:27:51 +08:00
|
|
|
list(APPEND LIBCXX_BUILD_TARGETS "cxx_static")
|
2016-11-19 03:53:45 +08:00
|
|
|
# Attempt to merge the libc++.a archive and the ABI library archive into one.
|
2018-07-24 15:06:17 +08:00
|
|
|
if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY)
|
2016-11-19 03:53:45 +08:00
|
|
|
set(MERGE_ARCHIVES_SEARCH_PATHS "")
|
|
|
|
if (LIBCXX_CXX_ABI_LIBRARY_PATH)
|
|
|
|
set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
|
|
|
|
endif()
|
2019-04-03 09:33:14 +08:00
|
|
|
if (TARGET "${LIBCXX_CXX_STATIC_ABI_LIBRARY}" OR HAVE_LIBCXXABI)
|
|
|
|
set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:${LIBCXX_CXX_STATIC_ABI_LIBRARY}>")
|
2016-11-19 03:53:45 +08:00
|
|
|
else()
|
2017-01-04 13:49:57 +08:00
|
|
|
set(MERGE_ARCHIVES_ABI_TARGET
|
2019-04-03 09:33:14 +08:00
|
|
|
"${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_STATIC_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
2021-03-19 01:51:10 +08:00
|
|
|
if (LIBCXX_CXX_ABI_LIBRARY_PATH)
|
|
|
|
set(MERGE_ARCHIVES_ABI_TARGET "${LIBCXX_CXX_ABI_LIBRARY_PATH}/${MERGE_ARCHIVES_ABI_TARGET}")
|
|
|
|
endif ()
|
2016-11-19 03:53:45 +08:00
|
|
|
endif()
|
2019-06-02 09:14:31 +08:00
|
|
|
if (APPLE)
|
|
|
|
set(MERGE_ARCHIVES_LIBTOOL "--use-libtool" "--libtool" "${CMAKE_LIBTOOL}")
|
|
|
|
endif()
|
2016-11-19 03:53:45 +08:00
|
|
|
add_custom_command(TARGET cxx_static POST_BUILD
|
|
|
|
COMMAND
|
2020-04-29 03:50:12 +08:00
|
|
|
${Python3_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/merge_archives.py
|
2016-11-19 03:53:45 +08:00
|
|
|
ARGS
|
|
|
|
-o $<TARGET_LINKER_FILE:cxx_static>
|
2017-09-13 14:55:44 +08:00
|
|
|
--ar "${CMAKE_AR}"
|
2019-06-02 09:14:31 +08:00
|
|
|
${MERGE_ARCHIVES_LIBTOOL}
|
2016-11-19 03:53:45 +08:00
|
|
|
"$<TARGET_LINKER_FILE:cxx_static>"
|
|
|
|
"${MERGE_ARCHIVES_ABI_TARGET}"
|
|
|
|
"${MERGE_ARCHIVES_SEARCH_PATHS}"
|
|
|
|
WORKING_DIRECTORY ${LIBCXX_BUILD_DIR}
|
2021-03-19 01:51:10 +08:00
|
|
|
DEPENDS ${MERGE_ARCHIVES_ABI_TARGET}
|
2016-11-19 03:53:45 +08:00
|
|
|
)
|
|
|
|
endif()
|
2016-08-09 06:57:25 +08:00
|
|
|
endif()
|
|
|
|
|
2018-07-27 11:47:46 +08:00
|
|
|
# Add a meta-target for both libraries.
|
2020-06-27 04:05:55 +08:00
|
|
|
add_custom_target(cxx DEPENDS ${LIBCXX_BUILD_TARGETS})
|
2018-07-27 11:47:46 +08:00
|
|
|
|
2016-05-04 05:30:18 +08:00
|
|
|
if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
|
2019-05-01 14:40:36 +08:00
|
|
|
set(LIBCXX_EXPERIMENTAL_SOURCES
|
|
|
|
experimental/memory_resource.cpp
|
|
|
|
)
|
Implement <filesystem>
This patch implements the <filesystem> header and uses that
to provide <experimental/filesystem>.
Unlike other standard headers, the symbols needed for <filesystem>
have not yet been placed in libc++.so. Instead they live in the
new libc++fs.a library. Users of filesystem are required to link this
library. (Also note that libc++experimental no longer contains the
definition of <experimental/filesystem>, which now requires linking libc++fs).
The reason for keeping <filesystem> out of the dylib for now is that
it's still somewhat experimental, and the possibility of requiring an
ABI breaking change is very real. In the future the symbols will likely
be moved into the dylib, or the dylib will be made to link libc++fs automagically).
Note that moving the symbols out of libc++experimental may break user builds
until they update to -lc++fs. This should be OK, because the experimental
library provides no stability guarantees. However, I plan on looking into
ways we can force libc++experimental to automagically link libc++fs.
In order to use a single implementation and set of tests for <filesystem>, it
has been placed in a special `__fs` namespace. This namespace is inline in
C++17 onward, but not before that. As such implementation is available
in C++11 onward, but no filesystem namespace is present "directly", and
as such name conflicts shouldn't occur in C++11 or C++14.
llvm-svn: 338093
2018-07-27 11:07:09 +08:00
|
|
|
add_library(cxx_experimental STATIC ${LIBCXX_EXPERIMENTAL_SOURCES})
|
2016-08-09 06:57:25 +08:00
|
|
|
if (LIBCXX_ENABLE_SHARED)
|
2019-10-09 00:26:24 +08:00
|
|
|
target_link_libraries(cxx_experimental PRIVATE cxx_shared)
|
2016-08-09 06:57:25 +08:00
|
|
|
else()
|
2019-10-09 00:26:24 +08:00
|
|
|
target_link_libraries(cxx_experimental PRIVATE cxx_static)
|
2016-08-09 06:57:25 +08:00
|
|
|
endif()
|
2016-05-11 00:17:43 +08:00
|
|
|
|
2016-05-04 05:30:18 +08:00
|
|
|
set_target_properties(cxx_experimental
|
|
|
|
PROPERTIES
|
2019-10-05 06:50:23 +08:00
|
|
|
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
|
2016-05-04 05:30:18 +08:00
|
|
|
OUTPUT_NAME "c++experimental"
|
|
|
|
)
|
2019-10-05 07:08:20 +08:00
|
|
|
cxx_add_common_build_flags(cxx_experimental)
|
2016-05-04 05:30:18 +08:00
|
|
|
endif()
|
2019-10-05 06:50:23 +08:00
|
|
|
|
2016-05-04 05:30:18 +08:00
|
|
|
|
2017-01-07 04:05:40 +08:00
|
|
|
if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
|
2020-09-01 19:41:21 +08:00
|
|
|
set(LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/../test/support/external_threads.cpp")
|
[libcxx] Introduce an externally-threaded libc++ variant.
This patch further decouples libc++ from pthread, allowing libc++ to be built
against other threading systems. There are two main use cases:
- Building libc++ against a thread library other than pthreads.
- Building libc++ with an "external" thread API, allowing a separate library to
provide the implementation of that API.
The two use cases are quite similar, the second one being sligtly more
de-coupled than the first. The cmake option LIBCXX_HAS_EXTERNAL_THREAD_API
enables both kinds of builds. One needs to place an <__external_threading>
header file containing an implementation of the "libc++ thread API" declared
in the <__threading_support> header.
For the second use case, the implementation of the libc++ thread API can
delegate to a custom "external" thread API where the implementation of this
external API is provided in a seperate library. This mechanism allows toolchain
vendors to distribute a build of libc++ with a custom thread-porting-layer API
(which is the "external" API above), platform vendors (recipients of the
toolchain/libc++) are then required to provide their implementation of this API
to be linked with (end-user) C++ programs.
Note that the second use case still requires establishing the basic types that
get passed between the external thread library and the libc++ library
(e.g. __libcpp_mutex_t). These cannot be opaque pointer types (libc++ sources
won't compile otherwise). It should also be noted that the second use case can
have a slight performance penalty; as all the thread constructs need to cross a
library boundary through an additional function call.
When the header <__external_threading> is omitted, libc++ is built with the
"libc++ thread API" (declared in <__threading_support>) as the "external" thread
API (basic types are pthread based). An implementation (pthread based) of this
API is provided in test/support/external_threads.cpp, which is built into a
separate DSO and linked in when running the libc++ test suite. A test run
therefore demonstrates the second use case (less the intermediate custom API).
Differential revision: https://reviews.llvm.org/D21968
Reviewers: bcraig, compnerd, EricWF, mclow.lists
llvm-svn: 281179
2016-09-12 05:46:40 +08:00
|
|
|
|
|
|
|
if (LIBCXX_ENABLE_SHARED)
|
|
|
|
add_library(cxx_external_threads SHARED ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES})
|
|
|
|
else()
|
|
|
|
add_library(cxx_external_threads STATIC ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set_target_properties(cxx_external_threads
|
|
|
|
PROPERTIES
|
|
|
|
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
|
|
|
|
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
|
|
|
|
OUTPUT_NAME "c++external_threads"
|
|
|
|
)
|
2020-09-01 19:41:21 +08:00
|
|
|
|
|
|
|
target_link_libraries(cxx_external_threads PRIVATE cxx-headers)
|
[libcxx] Introduce an externally-threaded libc++ variant.
This patch further decouples libc++ from pthread, allowing libc++ to be built
against other threading systems. There are two main use cases:
- Building libc++ against a thread library other than pthreads.
- Building libc++ with an "external" thread API, allowing a separate library to
provide the implementation of that API.
The two use cases are quite similar, the second one being sligtly more
de-coupled than the first. The cmake option LIBCXX_HAS_EXTERNAL_THREAD_API
enables both kinds of builds. One needs to place an <__external_threading>
header file containing an implementation of the "libc++ thread API" declared
in the <__threading_support> header.
For the second use case, the implementation of the libc++ thread API can
delegate to a custom "external" thread API where the implementation of this
external API is provided in a seperate library. This mechanism allows toolchain
vendors to distribute a build of libc++ with a custom thread-porting-layer API
(which is the "external" API above), platform vendors (recipients of the
toolchain/libc++) are then required to provide their implementation of this API
to be linked with (end-user) C++ programs.
Note that the second use case still requires establishing the basic types that
get passed between the external thread library and the libc++ library
(e.g. __libcpp_mutex_t). These cannot be opaque pointer types (libc++ sources
won't compile otherwise). It should also be noted that the second use case can
have a slight performance penalty; as all the thread constructs need to cross a
library boundary through an additional function call.
When the header <__external_threading> is omitted, libc++ is built with the
"libc++ thread API" (declared in <__threading_support>) as the "external" thread
API (basic types are pthread based). An implementation (pthread based) of this
API is provided in test/support/external_threads.cpp, which is built into a
separate DSO and linked in when running the libc++ test suite. A test run
therefore demonstrates the second use case (less the intermediate custom API).
Differential revision: https://reviews.llvm.org/D21968
Reviewers: bcraig, compnerd, EricWF, mclow.lists
llvm-svn: 281179
2016-09-12 05:46:40 +08:00
|
|
|
endif()
|
|
|
|
|
2020-10-10 03:04:12 +08:00
|
|
|
if (LIBCXX_INSTALL_SHARED_LIBRARY)
|
|
|
|
install(TARGETS cxx_shared
|
2021-04-01 08:34:05 +08:00
|
|
|
ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
|
|
|
|
LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
|
|
|
|
RUNTIME DESTINATION bin COMPONENT cxx)
|
2020-10-10 03:04:12 +08:00
|
|
|
endif()
|
2019-07-10 05:43:01 +08:00
|
|
|
|
2020-10-10 03:04:12 +08:00
|
|
|
if (LIBCXX_INSTALL_STATIC_LIBRARY)
|
|
|
|
install(TARGETS cxx_static
|
2021-04-01 08:34:05 +08:00
|
|
|
ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
|
|
|
|
LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
|
|
|
|
RUNTIME DESTINATION bin COMPONENT cxx)
|
2020-10-10 03:04:12 +08:00
|
|
|
endif()
|
2019-07-10 05:43:01 +08:00
|
|
|
|
2020-10-10 03:04:12 +08:00
|
|
|
if(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
|
|
|
|
install(TARGETS cxx_experimental
|
2021-04-01 08:34:05 +08:00
|
|
|
LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
|
|
|
|
ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
|
|
|
|
RUNTIME DESTINATION bin COMPONENT cxx)
|
2020-10-10 03:04:12 +08:00
|
|
|
endif()
|
2019-07-10 05:43:01 +08:00
|
|
|
|
2020-10-10 03:04:12 +08:00
|
|
|
# NOTE: This install command must go after the cxx install command otherwise
|
|
|
|
# it will not be executed after the library symlinks are installed.
|
|
|
|
if (LIBCXX_ENABLE_SHARED AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
|
2021-02-24 07:26:15 +08:00
|
|
|
install(FILES "$<TARGET_LINKER_FILE:cxx_shared>"
|
2021-04-01 08:34:05 +08:00
|
|
|
DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR}
|
2020-10-10 03:04:12 +08:00
|
|
|
COMPONENT libcxx)
|
2015-08-27 04:18:21 +08:00
|
|
|
endif()
|
2015-08-20 01:41:53 +08:00
|
|
|
|
2020-10-10 03:04:12 +08:00
|
|
|
if (NOT CMAKE_CONFIGURATION_TYPES)
|
2015-12-04 02:52:54 +08:00
|
|
|
if(LIBCXX_INSTALL_LIBRARY)
|
2016-05-03 13:34:38 +08:00
|
|
|
set(lib_install_target cxx)
|
2015-12-04 02:52:54 +08:00
|
|
|
endif()
|
2016-05-04 05:30:18 +08:00
|
|
|
if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
|
|
|
|
set(experimental_lib_install_target cxx_experimental)
|
|
|
|
endif()
|
2016-04-30 06:17:15 +08:00
|
|
|
if(LIBCXX_INSTALL_HEADERS)
|
2016-08-25 06:17:06 +08:00
|
|
|
set(header_install_target install-cxx-headers)
|
2016-04-30 06:17:15 +08:00
|
|
|
endif()
|
2020-07-09 03:00:31 +08:00
|
|
|
if (LIBCXX_ENABLE_PARALLEL_ALGORITHMS)
|
|
|
|
set(pstl_install_target install-pstl)
|
|
|
|
endif()
|
2016-08-25 06:17:06 +08:00
|
|
|
add_custom_target(install-cxx
|
2016-05-04 05:30:18 +08:00
|
|
|
DEPENDS ${lib_install_target}
|
|
|
|
${experimental_lib_install_target}
|
|
|
|
${header_install_target}
|
2020-07-09 03:00:31 +08:00
|
|
|
${pstl_install_target}
|
2015-08-27 04:18:21 +08:00
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
2016-08-25 06:17:06 +08:00
|
|
|
-DCMAKE_INSTALL_COMPONENT=cxx
|
2015-08-27 04:18:21 +08:00
|
|
|
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
|
2017-12-07 05:03:42 +08:00
|
|
|
add_custom_target(install-cxx-stripped
|
|
|
|
DEPENDS ${lib_install_target}
|
|
|
|
${experimental_lib_install_target}
|
|
|
|
${header_install_target}
|
2020-07-09 03:00:31 +08:00
|
|
|
${pstl_install_target}
|
2017-12-07 05:03:42 +08:00
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
-DCMAKE_INSTALL_COMPONENT=cxx
|
|
|
|
-DCMAKE_INSTALL_DO_STRIP=1
|
|
|
|
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
|
2015-08-20 01:41:53 +08:00
|
|
|
endif()
|