2010-12-11 03:47:54 +08:00
|
|
|
# See www/CMake.html for instructions on how to build libcxx with CMake.
|
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Setup Project
|
|
|
|
#===============================================================================
|
2016-06-01 04:21:52 +08:00
|
|
|
cmake_minimum_required(VERSION 3.4.3)
|
2010-12-11 03:47:54 +08:00
|
|
|
|
2015-01-27 05:56:45 +08:00
|
|
|
if(POLICY CMP0042)
|
|
|
|
cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
|
|
|
|
endif()
|
2015-07-31 06:30:34 +08:00
|
|
|
if(POLICY CMP0022)
|
|
|
|
cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang
|
|
|
|
endif()
|
|
|
|
|
2010-12-11 03:47:54 +08:00
|
|
|
# Add path for custom modules
|
|
|
|
set(CMAKE_MODULE_PATH
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
|
2015-12-30 11:39:03 +08:00
|
|
|
${CMAKE_MODULE_PATH}
|
2010-12-11 03:47:54 +08:00
|
|
|
)
|
|
|
|
|
2015-12-30 11:39:03 +08:00
|
|
|
# Find the LLVM sources and simulate LLVM CMake options.
|
|
|
|
include(HandleOutOfTreeLLVM)
|
2016-02-08 11:50:18 +08:00
|
|
|
|
2016-08-19 05:31:51 +08:00
|
|
|
if (LIBCXX_STANDALONE_BUILD)
|
2016-02-08 11:50:18 +08:00
|
|
|
project(libcxx CXX C)
|
|
|
|
|
|
|
|
set(PACKAGE_NAME libcxx)
|
2016-08-09 02:01:50 +08:00
|
|
|
set(PACKAGE_VERSION 4.0.0svn)
|
2016-02-08 11:50:18 +08:00
|
|
|
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
|
|
|
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
|
2016-08-09 02:01:50 +08:00
|
|
|
endif()
|
2016-02-08 11:50:18 +08:00
|
|
|
|
2016-08-19 05:31:51 +08:00
|
|
|
if (LIBCXX_STANDALONE_BUILD AND NOT LLVM_FOUND)
|
2015-12-30 11:39:03 +08:00
|
|
|
message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: "
|
|
|
|
"llvm-config not found and LLVM_PATH not defined.\n"
|
2016-08-29 02:33:08 +08:00
|
|
|
"Reconfigure with -DLLVM_CONFIG_PATH=path/to/llvm-config "
|
2015-12-30 11:39:03 +08:00
|
|
|
"or -DLLVM_PATH=path/to/llvm-source-root.")
|
|
|
|
endif()
|
|
|
|
|
2016-02-08 11:50:18 +08:00
|
|
|
# Require out of source build.
|
|
|
|
include(MacroEnsureOutOfSourceBuild)
|
|
|
|
MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
|
|
|
|
"${PROJECT_NAME} requires an out of source build. Please create a separate
|
|
|
|
build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
|
|
|
|
)
|
|
|
|
|
2010-12-11 03:47:54 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Setup CMake Options
|
|
|
|
#===============================================================================
|
2016-09-07 09:15:10 +08:00
|
|
|
include(CMakeDependentOption)
|
2010-12-11 03:47:54 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Basic options ---------------------------------------------------------------
|
2015-07-30 07:46:55 +08:00
|
|
|
option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
|
|
|
|
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
|
2016-08-09 06:57:25 +08:00
|
|
|
option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON)
|
2016-05-04 05:30:18 +08:00
|
|
|
option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON)
|
2016-06-18 03:46:40 +08:00
|
|
|
option(LIBCXX_ENABLE_FILESYSTEM
|
|
|
|
"Build filesystem as part of libc++experimental.a" ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY})
|
2015-07-31 06:30:34 +08:00
|
|
|
option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
|
2016-10-31 06:53:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
# Benchmark options -----------------------------------------------------------
|
2016-08-30 03:50:49 +08:00
|
|
|
option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependancies" ON)
|
2016-10-31 06:53:00 +08:00
|
|
|
set(LIBCXX_BENCHMARK_NATIVE_STDLIB "" CACHE STRING
|
|
|
|
"Build the benchmarks against the specified native STL.
|
|
|
|
The value must be one of libc++/libstdc++")
|
|
|
|
set(LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN "" CACHE STRING
|
|
|
|
"Use alternate GCC toolchain when building the native benchmarks")
|
|
|
|
|
|
|
|
if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
|
|
|
|
if (NOT (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++"
|
|
|
|
OR LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++"))
|
|
|
|
message(FATAL_ERROR "Invalid value for LIBCXX_BENCHMARK_NATIVE_STDLIB: "
|
|
|
|
"'${LIBCXX_BENCHMARK_NATIVE_STDLIB}'")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-08-23 03:40:49 +08:00
|
|
|
option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS})
|
2015-07-31 06:30:34 +08:00
|
|
|
set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
|
|
|
|
"Define suffix of library directory name (32/64)")
|
|
|
|
option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
|
2015-08-27 04:18:21 +08:00
|
|
|
option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
|
2015-07-31 06:30:34 +08:00
|
|
|
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
|
2016-09-07 09:15:10 +08:00
|
|
|
cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
|
|
|
|
"Install libc++experimental.a" ON
|
|
|
|
"LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
|
2015-10-14 07:48:28 +08:00
|
|
|
set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
|
|
|
|
option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
|
2016-08-24 12:22:52 +08:00
|
|
|
option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
|
2015-07-31 06:30:34 +08:00
|
|
|
|
2016-08-09 06:57:25 +08:00
|
|
|
if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC)
|
|
|
|
message(FATAL_ERROR "libc++ must be built as either a shared or static library.")
|
|
|
|
endif()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# ABI Library options ---------------------------------------------------------
|
|
|
|
set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
|
|
|
|
"Specify C++ ABI library to use." FORCE)
|
|
|
|
set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
|
|
|
|
set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
|
|
|
|
|
2015-10-23 04:54:27 +08:00
|
|
|
# Setup the default options if LIBCXX_CXX_ABI is not specified.
|
|
|
|
if (NOT LIBCXX_CXX_ABI)
|
2016-08-19 05:31:51 +08:00
|
|
|
if (NOT DEFINED LIBCXX_STANDALONE_BUILD AND
|
2015-10-23 04:54:27 +08:00
|
|
|
IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi")
|
|
|
|
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
|
|
|
|
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include")
|
|
|
|
set(LIBCXX_CXX_ABI_INTREE 1)
|
2016-08-09 02:01:50 +08:00
|
|
|
else()
|
2015-10-23 04:54:27 +08:00
|
|
|
set(LIBCXX_CXX_ABI_LIBNAME "none")
|
2016-08-09 02:01:50 +08:00
|
|
|
endif()
|
|
|
|
else()
|
2015-10-23 04:54:27 +08:00
|
|
|
set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
|
2016-08-09 02:01:50 +08:00
|
|
|
endif()
|
2015-10-23 04:54:27 +08:00
|
|
|
|
2015-10-16 06:41:51 +08:00
|
|
|
# Use a static copy of the ABI library when linking libc++. This option
|
|
|
|
# cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT.
|
2015-07-31 06:30:34 +08:00
|
|
|
option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
|
|
|
|
|
2015-10-15 03:54:03 +08:00
|
|
|
# Generate and install a linker script inplace of libc++.so. The linker script
|
2015-10-16 06:41:51 +08:00
|
|
|
# will link libc++ to the correct ABI library. This option is on by default
|
|
|
|
# On UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
|
2015-10-23 04:50:07 +08:00
|
|
|
# is on. This option is also disabled when the ABI library is not specified
|
|
|
|
# or is specified to be "none".
|
2015-10-16 06:41:51 +08:00
|
|
|
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
|
2015-10-16 07:04:54 +08:00
|
|
|
if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY
|
2015-10-23 04:54:27 +08:00
|
|
|
AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"
|
2016-05-15 07:58:11 +08:00
|
|
|
AND PYTHONINTERP_FOUND
|
|
|
|
AND LIBCXX_ENABLE_SHARED)
|
2015-10-16 06:41:51 +08:00
|
|
|
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
|
|
|
|
endif()
|
|
|
|
|
2015-10-15 03:54:03 +08:00
|
|
|
option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT
|
2015-10-16 06:41:51 +08:00
|
|
|
"Use and install a linker script for the given ABI library"
|
2015-10-16 07:04:54 +08:00
|
|
|
${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE})
|
2015-10-15 03:54:03 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Build libc++abi with libunwind. We need this option to determine whether to
|
|
|
|
# link with libunwind or libgcc_s while running the test cases.
|
|
|
|
option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
|
|
|
|
|
|
|
|
# Target options --------------------------------------------------------------
|
|
|
|
option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS})
|
|
|
|
set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.")
|
|
|
|
set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.")
|
|
|
|
|
|
|
|
# Feature options -------------------------------------------------------------
|
|
|
|
option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON)
|
|
|
|
option(LIBCXX_ENABLE_RTTI "Use run time type information." ON)
|
Add option to disable access to the global filesystem namespace.
Systems like FreeBSD's Capsicum and Nuxi CloudABI apply the concept of
capability-based security on the way processes can interact with the
filesystem API. It is no longer possible to interact with the VFS
through calls like open(), unlink(), rename(), etc. Instead, processes
are only allowed to interact with files and directories to which they
have been granted access. The *at() functions can be used for this
purpose.
This change adds a new config switch called
_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE. If set, all functionality
that requires the global filesystem namespace will be disabled. More
concretely:
- fstream's open() function will be removed.
- cstdio will no longer pull in fopen(), rename(), etc.
- The test suite's get_temp_file_name() will be removed. This will cause
all tests that use the global filesystem namespace to break, but will
at least make all the other tests run (as get_temp_file_name will not
build anyway).
It is important to mention that this change will make fstream rather
useless on those systems for now. Still, I'd rather not have fstream
disabled entirely, as it is of course possible to come up with an
extension for fstream that would allow access to local filesystem
namespaces (e.g., by adding an openat() member function).
Differential revision: http://reviews.llvm.org/D8194
Reviewed by: jroelofs (thanks!)
llvm-svn: 232049
2015-03-12 23:44:39 +08:00
|
|
|
option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON)
|
2015-03-26 22:35:46 +08:00
|
|
|
option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON)
|
|
|
|
option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON)
|
2014-12-07 05:02:58 +08:00
|
|
|
option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON)
|
2015-06-24 16:44:38 +08:00
|
|
|
option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON)
|
2014-12-07 05:02:58 +08:00
|
|
|
option(LIBCXX_ENABLE_MONOTONIC_CLOCK
|
|
|
|
"Build libc++ with support for a monotonic clock.
|
2015-08-25 05:20:07 +08:00
|
|
|
This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON)
|
2015-11-09 18:21:04 +08:00
|
|
|
option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF)
|
2016-05-26 01:40:09 +08:00
|
|
|
option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)
|
[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
|
|
|
option(LIBCXX_HAS_EXTERNAL_THREAD_API
|
|
|
|
"Build libc++ with an externalized threading API.
|
|
|
|
This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
|
2015-07-31 06:30:34 +08:00
|
|
|
|
|
|
|
# Misc options ----------------------------------------------------------------
|
2015-10-10 11:34:52 +08:00
|
|
|
# FIXME: Turn -pedantic back ON. It is currently off because it warns
|
|
|
|
# about #include_next which is used everywhere.
|
|
|
|
option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF)
|
2015-07-31 06:30:34 +08:00
|
|
|
option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
|
2016-07-12 22:39:13 +08:00
|
|
|
option(LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS "Disable #warnings about conflicting macros." OFF)
|
2015-07-31 06:30:34 +08:00
|
|
|
|
2015-03-31 12:15:45 +08:00
|
|
|
option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF)
|
|
|
|
set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
|
2015-07-31 06:30:34 +08:00
|
|
|
"The Profile-rt library used to build with code coverage")
|
|
|
|
|
2015-08-27 04:18:21 +08:00
|
|
|
# Don't allow a user to accidentally overwrite the system libc++ installation on Darwin.
|
|
|
|
# If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for libc++
|
|
|
|
# will not be generated and a warning will be issued.
|
|
|
|
option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ installation." OFF)
|
|
|
|
mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by default.
|
|
|
|
|
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT LIBCXX_OVERRIDE_DARWIN_INSTALL)
|
|
|
|
if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
|
|
|
|
message(WARNING "Disabling libc++ install rules because installation would "
|
|
|
|
"overwrite the systems installation. Configure with "
|
|
|
|
"-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this behaviour.")
|
|
|
|
mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override option.
|
|
|
|
set(LIBCXX_INSTALL_HEADERS OFF)
|
|
|
|
set(LIBCXX_INSTALL_LIBRARY OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-12-17 07:41:05 +08:00
|
|
|
set(LIBCXX_CONFIGURE_IDE_DEFAULT OFF)
|
|
|
|
if (XCODE OR MSVC_IDE)
|
|
|
|
set(LIBCXX_CONFIGURE_IDE_DEFAULT ON)
|
|
|
|
endif()
|
|
|
|
option(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE"
|
|
|
|
${LIBCXX_CONFIGURE_IDE_DEFAULT})
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Check option configurations
|
|
|
|
#===============================================================================
|
|
|
|
|
2016-06-18 03:46:40 +08:00
|
|
|
if (LIBCXX_ENABLE_FILESYSTEM AND NOT LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"LIBCXX_ENABLE_FILESYSTEM cannot be turned on when LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF")
|
|
|
|
endif()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when
|
|
|
|
# LIBCXX_ENABLE_THREADS is on.
|
|
|
|
if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
|
|
|
|
message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF"
|
|
|
|
" when LIBCXX_ENABLE_THREADS is also set to OFF.")
|
2015-07-30 05:07:28 +08:00
|
|
|
endif()
|
|
|
|
|
2016-05-26 01:40:09 +08:00
|
|
|
if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS)
|
|
|
|
message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
|
|
|
|
" when LIBCXX_ENABLE_THREADS is also set to ON.")
|
|
|
|
endif()
|
|
|
|
|
[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_HAS_EXTERNAL_THREAD_API AND NOT LIBCXX_ENABLE_THREADS)
|
|
|
|
message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON"
|
|
|
|
" when LIBCXX_ENABLE_THREADS is also set to ON.")
|
|
|
|
endif()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
|
|
|
|
# is ON.
|
|
|
|
if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE)
|
|
|
|
message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Set LIBCXX_BUILD_32_BITS to (LIBCXX_BUILD_32_BITS OR LLVM_BUILD_32_BITS)
|
|
|
|
# and check that we can build with 32 bits if requested.
|
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
|
|
|
|
if (LIBCXX_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM
|
|
|
|
message(STATUS "Building 32 bits executables and libraries.")
|
|
|
|
endif()
|
|
|
|
elseif(LIBCXX_BUILD_32_BITS)
|
|
|
|
message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Check that this option is not enabled on Apple and emit a usage warning.
|
2015-03-03 23:59:51 +08:00
|
|
|
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
|
|
|
|
if (APPLE)
|
|
|
|
message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X")
|
|
|
|
else()
|
|
|
|
message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-10-15 03:54:03 +08:00
|
|
|
if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
|
|
|
|
if (APPLE)
|
|
|
|
message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets")
|
|
|
|
endif()
|
|
|
|
if (NOT PYTHONINTERP_FOUND)
|
|
|
|
message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT requires python but it was not found.")
|
|
|
|
endif()
|
2016-05-15 07:58:11 +08:00
|
|
|
if (NOT LIBCXX_ENABLE_SHARED)
|
|
|
|
message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT is only available for shared library builds.")
|
|
|
|
endif()
|
2015-10-15 03:54:03 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
|
|
|
|
message(FATAL_ERROR "Conflicting options given.
|
|
|
|
LIBCXX_ENABLE_STATIC_ABI_LIBRARY cannot be specified with
|
|
|
|
LIBCXX_ENABLE_ABI_LINKER_SCRIPT")
|
|
|
|
endif()
|
|
|
|
|
2015-11-09 18:21:04 +08:00
|
|
|
if (LIBCXX_HAS_MUSL_LIBC AND NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
|
|
|
|
message(FATAL_ERROR "LIBCXX_INSTALL_SUPPORT_HEADERS can not be turned off"
|
|
|
|
"when building for Musl with LIBCXX_HAS_MUSL_LIBC.")
|
|
|
|
endif()
|
|
|
|
|
2010-12-11 03:47:54 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Configure System
|
|
|
|
#===============================================================================
|
|
|
|
|
2014-12-20 11:16:55 +08:00
|
|
|
set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER})
|
|
|
|
set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
2014-12-29 20:15:47 +08:00
|
|
|
set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
|
2014-12-20 11:16:55 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
|
|
|
|
|
2014-11-15 14:26:30 +08:00
|
|
|
# Declare libc++ configuration variables.
|
|
|
|
# They are intended for use as follows:
|
|
|
|
# LIBCXX_CXX_FLAGS: General flags for both the compiler and linker.
|
|
|
|
# LIBCXX_COMPILE_FLAGS: Compile only flags.
|
|
|
|
# LIBCXX_LINK_FLAGS: Linker only flags.
|
2016-10-10 05:34:03 +08:00
|
|
|
# LIBCXX_LIBRARIES: libraries libc++ is linked to.
|
|
|
|
# LIBCXX_INTERFACE_LIBRARIES: Libraries that must be linked when using libc++
|
2016-10-10 22:45:06 +08:00
|
|
|
# These libraries are exposed in the linker script.
|
2014-11-15 14:26:30 +08:00
|
|
|
set(LIBCXX_COMPILE_FLAGS "")
|
|
|
|
set(LIBCXX_LINK_FLAGS "")
|
2015-07-31 06:30:34 +08:00
|
|
|
set(LIBCXX_LIBRARIES "")
|
2016-10-10 05:34:03 +08:00
|
|
|
set(LIBCXX_INTERFACE_LIBRARIES "")
|
2014-11-15 14:26:30 +08:00
|
|
|
|
2016-06-02 09:10:08 +08:00
|
|
|
# Include macros for adding and removing libc++ flags.
|
|
|
|
include(HandleLibcxxFlags)
|
|
|
|
|
|
|
|
# Target flags ================================================================
|
|
|
|
# These flags get added to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS so that
|
|
|
|
# 'config-ix' use them during feature checks. It also adds them to both
|
|
|
|
# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'
|
|
|
|
add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32")
|
|
|
|
add_target_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}")
|
|
|
|
add_target_flags_if(LIBCXX_SYSROOT "--sysroot=${LIBCXX_SYSROOT}")
|
|
|
|
add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}")
|
|
|
|
|
2014-11-16 01:25:23 +08:00
|
|
|
# Configure compiler.
|
|
|
|
include(config-ix)
|
2015-07-31 06:30:34 +08:00
|
|
|
|
2016-08-24 12:22:52 +08:00
|
|
|
if (LIBCXX_USE_COMPILER_RT)
|
|
|
|
list(APPEND LIBCXX_LINK_FLAGS "-rtlib=compiler-rt")
|
|
|
|
endif()
|
|
|
|
|
2015-03-31 12:15:45 +08:00
|
|
|
# Configure coverage options.
|
|
|
|
if (LIBCXX_GENERATE_COVERAGE)
|
|
|
|
include(CodeCoverage)
|
|
|
|
set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE)
|
|
|
|
endif()
|
2014-11-16 01:25:23 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
|
|
|
|
|
2014-11-16 01:25:23 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Setup Compiler Flags
|
|
|
|
#===============================================================================
|
|
|
|
|
2016-03-05 22:22:02 +08:00
|
|
|
include(HandleLibCXXABI) # Setup the ABI library flags
|
2015-07-29 08:03:51 +08:00
|
|
|
|
2016-09-27 15:55:26 +08:00
|
|
|
if (NOT LIBCXX_STANDALONE_BUILD)
|
|
|
|
# Remove flags that may have snuck in.
|
|
|
|
remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
|
|
|
|
-lc++abi -m32)
|
|
|
|
endif()
|
|
|
|
remove_flags(-stdlib=libc++ -stdlib=libstdc++)
|
2015-07-31 06:30:34 +08:00
|
|
|
|
2015-10-14 07:56:33 +08:00
|
|
|
# FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
|
2015-10-16 04:27:15 +08:00
|
|
|
# Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors
|
|
|
|
# so they don't get transformed into -Wno and -errors respectivly.
|
|
|
|
remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
|
2015-10-14 07:56:33 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Required flags ==============================================================
|
2016-08-15 06:51:54 +08:00
|
|
|
set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build dialect")
|
2016-10-24 05:48:27 +08:00
|
|
|
if (LIBCXX_HAS_MUSL_LIBC)
|
|
|
|
# musl's pthread implementations uses volatile types in their structs which is
|
|
|
|
# not a constexpr in C++11 but is in C++14, so we use C++14 with musl.
|
|
|
|
set(LIBCXX_STANDARD_VER c++14 CACHE INTERNAL "internal option to change build dialect")
|
|
|
|
endif()
|
2016-08-15 06:51:54 +08:00
|
|
|
add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER})
|
|
|
|
mangle_name("LIBCXX_SUPPORTS_STD_EQ_${LIBCXX_STANDARD_VER}_FLAG" SUPPORTS_DIALECT_NAME)
|
|
|
|
if (NOT MSVC AND NOT ${SUPPORTS_DIALECT_NAME})
|
|
|
|
message(FATAL_ERROR "C++11 or greater is required but the compiler does not support ${LIBCXX_STANDARD_VER}")
|
2013-10-05 08:07:35 +08:00
|
|
|
endif()
|
2013-10-21 23:56:35 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# On all systems the system c++ standard library headers need to be excluded.
|
|
|
|
# MSVC only has -X, which disables all default includes; including the crt.
|
|
|
|
# Thus, we do nothing and hope we don't accidentally include any of the C++
|
|
|
|
# headers
|
|
|
|
add_compile_flags_if_supported(-nostdinc++)
|
|
|
|
|
[libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions from the dylib
Summary:
This patch turns on `-fvisibility-inlines-hidden` when building the dylib. This is important so that libc++.dylib doesn't accidentally export inline-functions which are ODR used somewhere in the dylib.
On OS X this change has no effect on the current ABI of the dylib. Unfortunately on Linux there are already ~20 inline functions which are unintentionally exported by the dylib. Almost all of these are implicitly generated destructors. I believe removing these function definitions is safe because every "linkage unit" which uses these functions has its own definition, and therefore shouldn't be dependent on libc++.dylib to provide them.
Also could a FreeBSD maintainer comment on the ABI compatibility of this patch?
Reviewers: mclow.lists, emaste, dexonsmith, joker-eph-DISABLED, jroelofs, danalbert, mehdi_amini, compnerd, dim
Subscribers: beanz, mgorny, cfe-commits, modocache
Differential Revision: https://reviews.llvm.org/D25593
llvm-svn: 285101
2016-10-26 03:43:44 +08:00
|
|
|
# Hide all inline function definitions which have not explicitly been marked
|
|
|
|
# visible. This prevents new definitions for inline functions from appearing in
|
|
|
|
# the dylib when get ODR used by another function.
|
|
|
|
add_compile_flags_if_supported(-fvisibility-inlines-hidden)
|
|
|
|
|
2016-09-27 06:19:41 +08:00
|
|
|
# Let the library headers know they are currently being used to build the
|
|
|
|
# library.
|
[libc++] Add _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to support GCC ABI compatibility
Summary:
GCC and Clang handle visibility attributes on the out-of-line definition of externally instantiated templates differently. For example in the reproducer below Clang will emit both 'foo' and 'bar' with default visibility while GCC only emits a non-hidden 'foo'.
```
// RUN: g++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
// RUN: clang++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
#define INLINE_VISIBILITY __attribute__((visibility("hidden"), always_inline))
template <class T>
struct Foo {
void foo();
void bar();
};
template <class T>
void Foo<T>::foo() {}
template <class T>
inline INLINE_VISIBILITY
void Foo<T>::bar() {}
template struct Foo<int>;
```
This difference creates ABI incompatibilities between Clang and GCC built dylibs. Specifically GCC built dylibs lack definitions for various member functions of `basic_string`, `basic_istream`, `basic_ostream`, `basic_iostream`, and `basic_streambuf` (All of these types are externally instantiated).
Surprisingly these missing symbols don't cause many problems because the functions are marked `always_inline` therefore the dylib definition is rarely needed. However when an out-of-line definition is required then GCC built dylibs will fail to link. For example [GCC built dylibs cannot build Clang](http://stackoverflow.com/questions/39454262/clang-build-errors).
This patch works around this issue by adding `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` which is used to mark externally instantiated member functions as always inline. When building the library `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` sets the symbol's visibility to "default" instead of "hidden", otherwise it acts exactly the same as `_LIBCPP_INLINE_VISIBILITY`.
After applying this patch GCC dylibs now contain:
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5gbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9sputbackcEc`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setpEPcS4_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6snextcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9pubsetbufEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5pbumpEi`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE7getlineEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8in_availEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6sbumpcEv`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERc`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6snextcEv`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEmw`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE7getlineEPwl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5tellpEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERw`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEmc`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7pubsyncEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getEPcl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7pubsyncEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE6getlocEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5gbumpEi`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5tellpEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRS3_S4_E`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getEPwl`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setgEPcS4_S4_`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setgEPwS4_S4_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5pbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetcEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputnEPKcl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetnEPwl`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setpEPwS4_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetnEPcl`
* `_ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE6getlocEv`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8in_availEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6sbumpcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9sputbackcEw`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputnEPKwl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRS3_S4_E`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9pubsetbufEPwl`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputcEw`
This patch has no effect on Clang based builds.
Reviewers: mclow.lists, eugenis, danalbert, jroelofs, EricWF
Subscribers: beanz, cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D24600
llvm-svn: 281681
2016-09-16 08:00:48 +08:00
|
|
|
add_definitions(-D_LIBCPP_BUILDING_LIBRARY)
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Warning flags ===============================================================
|
|
|
|
add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
|
|
|
add_compile_flags_if_supported(
|
2016-08-30 04:43:38 +08:00
|
|
|
-Wall -Wextra -W -Wwrite-strings
|
|
|
|
-Wno-unused-parameter -Wno-long-long
|
2015-07-31 06:30:34 +08:00
|
|
|
-Werror=return-type)
|
2016-08-30 04:43:38 +08:00
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
|
|
add_compile_flags_if_supported(
|
|
|
|
-Wno-user-defined-literals
|
|
|
|
-Wno-covered-switch-default)
|
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
|
|
|
add_compile_flags_if_supported(
|
|
|
|
-Wno-literal-suffix
|
|
|
|
-Wno-c++14-compat)
|
|
|
|
endif()
|
2010-12-11 03:47:54 +08:00
|
|
|
if (LIBCXX_ENABLE_WERROR)
|
2015-07-31 06:30:34 +08:00
|
|
|
add_compile_flags_if_supported(-Werror)
|
|
|
|
add_compile_flags_if_supported(-WX)
|
2015-07-31 09:25:01 +08:00
|
|
|
else()
|
|
|
|
# TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is
|
|
|
|
# added elsewhere.
|
|
|
|
add_compile_flags_if_supported(-Wno-error)
|
2010-12-11 03:47:54 +08:00
|
|
|
endif()
|
|
|
|
if (LIBCXX_ENABLE_PEDANTIC)
|
2015-07-31 06:30:34 +08:00
|
|
|
add_compile_flags_if_supported(-pedantic)
|
2010-12-11 03:47:54 +08:00
|
|
|
endif()
|
2016-07-12 22:39:13 +08:00
|
|
|
if (LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS)
|
|
|
|
add_definitions(-D_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
|
|
|
|
endif()
|
2010-12-11 03:47:54 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Exception flags =============================================================
|
2010-12-11 03:47:54 +08:00
|
|
|
if (LIBCXX_ENABLE_EXCEPTIONS)
|
|
|
|
# Catches C++ exceptions only and tells the compiler to assume that extern C
|
|
|
|
# functions never throw a C++ exception.
|
2015-07-31 06:30:34 +08:00
|
|
|
add_compile_flags_if_supported(-EHsc)
|
2010-12-11 03:47:54 +08:00
|
|
|
else()
|
2015-07-31 06:30:34 +08:00
|
|
|
add_definitions(-D_LIBCPP_NO_EXCEPTIONS)
|
|
|
|
add_compile_flags_if_supported(-EHs- -EHa-)
|
|
|
|
add_compile_flags_if_supported(-fno-exceptions)
|
2010-12-11 03:47:54 +08:00
|
|
|
endif()
|
2015-07-31 06:30:34 +08:00
|
|
|
|
|
|
|
# RTTI flags ==================================================================
|
2010-12-11 03:47:54 +08:00
|
|
|
if (NOT LIBCXX_ENABLE_RTTI)
|
2015-07-31 06:30:34 +08:00
|
|
|
add_definitions(-D_LIBCPP_NO_RTTI)
|
|
|
|
add_compile_flags_if_supported(-GR-)
|
|
|
|
add_compile_flags_if_supported(-fno-rtti)
|
2010-12-11 03:47:54 +08:00
|
|
|
endif()
|
2015-07-31 06:30:34 +08:00
|
|
|
|
[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
|
|
|
# Threading flags =============================================================
|
|
|
|
if (LIBCXX_HAS_EXTERNAL_THREAD_API AND LIBCXX_ENABLE_SHARED)
|
|
|
|
# Need to allow unresolved symbols if this is to work with shared library builds
|
|
|
|
if (APPLE)
|
|
|
|
add_link_flags("-undefined dynamic_lookup")
|
|
|
|
else()
|
|
|
|
# Relax this restriction from HandleLLVMOptions
|
|
|
|
string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Assertion flags =============================================================
|
|
|
|
define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG)
|
|
|
|
define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG)
|
2012-08-06 01:37:39 +08:00
|
|
|
if (LIBCXX_ENABLE_ASSERTIONS)
|
2010-12-11 03:47:54 +08:00
|
|
|
# MSVC doesn't like _DEBUG on release builds. See PR 4379.
|
2015-07-31 06:30:34 +08:00
|
|
|
define_if_not(MSVC -D_DEBUG)
|
2015-07-30 07:46:55 +08:00
|
|
|
endif()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Feature flags ===============================================================
|
|
|
|
define_if(MSVC -D_CRT_SECURE_NO_WARNINGS)
|
2015-07-30 07:46:55 +08:00
|
|
|
|
2016-10-14 20:56:52 +08:00
|
|
|
# Modules flags ===============================================================
|
|
|
|
# FIXME The libc++ sources are fundamentally non-modular. They need special
|
|
|
|
# versions of the headers in order to provide C++03 and legacy ABI definitions.
|
|
|
|
# NOTE: The public headers can be used with modules in all other contexts.
|
|
|
|
if (LLVM_ENABLE_MODULES)
|
|
|
|
# Ignore that the rest of the modules flags are now unused.
|
|
|
|
add_compile_flags_if_supported(-Wno-unused-command-line-argument)
|
|
|
|
add_compile_flags(-fno-modules)
|
|
|
|
endif()
|
|
|
|
|
2015-08-25 05:20:07 +08:00
|
|
|
# Sanitizer flags =============================================================
|
2010-12-11 03:47:54 +08:00
|
|
|
|
2016-08-19 05:31:51 +08:00
|
|
|
# Configure for sanitizers. If LIBCXX_STANDALONE_BUILD then we have to do
|
2015-07-30 07:46:55 +08:00
|
|
|
# the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it.
|
2016-08-19 05:31:51 +08:00
|
|
|
if (LIBCXX_STANDALONE_BUILD)
|
2015-07-31 06:30:34 +08:00
|
|
|
set(LLVM_USE_SANITIZER "" CACHE STRING
|
|
|
|
"Define the sanitizer used to build the library and tests")
|
2015-07-30 07:46:55 +08:00
|
|
|
# NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC.
|
|
|
|
# But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do.
|
|
|
|
if (LLVM_USE_SANITIZER AND NOT MSVC)
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags_if_supported("-fno-omit-frame-pointer")
|
|
|
|
add_flags_if_supported("-gline-tables-only")
|
|
|
|
|
2015-07-30 07:46:55 +08:00
|
|
|
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND
|
|
|
|
NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags_if_supported("-gline-tables-only")
|
2015-07-30 07:46:55 +08:00
|
|
|
endif()
|
|
|
|
if (LLVM_USE_SANITIZER STREQUAL "Address")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags("-fsanitize=address")
|
2015-07-30 07:46:55 +08:00
|
|
|
elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags(-fsanitize=memory)
|
2015-07-30 07:46:55 +08:00
|
|
|
if (LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags("-fsanitize-memory-track-origins")
|
2015-07-30 07:46:55 +08:00
|
|
|
endif()
|
|
|
|
elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all")
|
2015-07-30 07:46:55 +08:00
|
|
|
elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags(-fsanitize=thread)
|
2015-07-30 07:46:55 +08:00
|
|
|
else()
|
|
|
|
message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
|
|
|
|
endif()
|
2015-07-31 06:30:34 +08:00
|
|
|
elseif(LLVM_USE_SANITIZER AND MSVC)
|
|
|
|
message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.")
|
2015-07-30 07:46:55 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
[libcxx] Capture configuration information when installing the libc++ headers
Summary:
Hi all,
This patch is a successor to D11963. However it has changed dramatically and I felt it would be best to start a new review thread.
Please read the design documentation added in this patch for a description of how it works.
Reviewers: mclow.lists, danalbert, jroelofs, EricWF
Subscribers: vkalintiris, rnk, ed, espositofulvio, asl, eugenis, cfe-commits
Differential Revision: http://reviews.llvm.org/D13407
llvm-svn: 250235
2015-10-14 06:12:02 +08:00
|
|
|
|
|
|
|
# Configuration file flags =====================================================
|
2015-10-14 07:48:28 +08:00
|
|
|
if (NOT LIBCXX_ABI_VERSION EQUAL "1")
|
|
|
|
config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
|
|
|
|
endif()
|
|
|
|
config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE)
|
|
|
|
|
[libcxx] Capture configuration information when installing the libc++ headers
Summary:
Hi all,
This patch is a successor to D11963. However it has changed dramatically and I felt it would be best to start a new review thread.
Please read the design documentation added in this patch for a description of how it works.
Reviewers: mclow.lists, danalbert, jroelofs, EricWF
Subscribers: vkalintiris, rnk, ed, espositofulvio, asl, eugenis, cfe-commits
Differential Revision: http://reviews.llvm.org/D13407
llvm-svn: 250235
2015-10-14 06:12:02 +08:00
|
|
|
config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE)
|
|
|
|
config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN)
|
|
|
|
config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT)
|
|
|
|
config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS)
|
|
|
|
config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK)
|
|
|
|
config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS)
|
|
|
|
|
2016-05-26 01:40:09 +08:00
|
|
|
config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
|
[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
|
|
|
config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL)
|
2015-11-09 18:21:04 +08:00
|
|
|
config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
|
|
|
|
|
2016-09-27 06:19:41 +08:00
|
|
|
# By default libc++ on Windows expects to use a shared library, which requires
|
|
|
|
# the headers to use DLL import/export semantics. However when building a
|
|
|
|
# static library only we modify the headers to disable DLL import/export.
|
|
|
|
if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED)
|
|
|
|
message(STATUS "Generating custom __config for non-DLL Windows build")
|
|
|
|
config_define(ON _LIBCPP_DISABLE_DLL_IMPORT_EXPORT)
|
|
|
|
endif()
|
|
|
|
|
[libcxx] Capture configuration information when installing the libc++ headers
Summary:
Hi all,
This patch is a successor to D11963. However it has changed dramatically and I felt it would be best to start a new review thread.
Please read the design documentation added in this patch for a description of how it works.
Reviewers: mclow.lists, danalbert, jroelofs, EricWF
Subscribers: vkalintiris, rnk, ed, espositofulvio, asl, eugenis, cfe-commits
Differential Revision: http://reviews.llvm.org/D13407
llvm-svn: 250235
2015-10-14 06:12:02 +08:00
|
|
|
if (LIBCXX_NEEDS_SITE_CONFIG)
|
|
|
|
configure_file(
|
|
|
|
include/__config_site.in
|
|
|
|
${LIBCXX_BINARY_DIR}/__config_site
|
|
|
|
@ONLY)
|
2015-10-14 08:22:05 +08:00
|
|
|
# Provide the config definitions by included the generated __config_site
|
|
|
|
# file at compile time.
|
|
|
|
add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site")
|
[libcxx] Capture configuration information when installing the libc++ headers
Summary:
Hi all,
This patch is a successor to D11963. However it has changed dramatically and I felt it would be best to start a new review thread.
Please read the design documentation added in this patch for a description of how it works.
Reviewers: mclow.lists, danalbert, jroelofs, EricWF
Subscribers: vkalintiris, rnk, ed, espositofulvio, asl, eugenis, cfe-commits
Differential Revision: http://reviews.llvm.org/D13407
llvm-svn: 250235
2015-10-14 06:12:02 +08:00
|
|
|
endif()
|
|
|
|
|
2010-12-11 03:47:54 +08:00
|
|
|
#===============================================================================
|
2015-07-31 06:30:34 +08:00
|
|
|
# Setup Source Code And Tests
|
2010-12-11 03:47:54 +08:00
|
|
|
#===============================================================================
|
|
|
|
include_directories(include)
|
2013-11-16 01:18:57 +08:00
|
|
|
add_subdirectory(include)
|
2010-12-11 03:47:54 +08:00
|
|
|
add_subdirectory(lib)
|
2015-08-23 03:40:49 +08:00
|
|
|
|
[libcxx] Add support for benchmark tests using Google Benchmark.
Summary:
This patch does the following:
1. Checks in a copy of the Google Benchmark library into the libc++ repo under `utils/google-benchmark`.
2. Teaches libc++ how to build Google Benchmark against both (A) in-tree libc++ and (B) the platforms native STL.
3. Allows performance benchmarks to be built as part of the libc++ build.
Building the benchmarks (and Google Benchmark) is off by default. It must be enabled using the CMake option `-DLIBCXX_INCLUDE_BENCHMARKS=ON`. When this option is enabled the tests under `libcxx/benchmarks` can be built using the `libcxx-benchmarks` target.
On Linux platforms where libstdc++ is the default STL the CMake option `-DLIBCXX_BUILD_BENCHMARKS_NATIVE_STDLIB=ON` can be used to build each benchmark test against libstdc++ as well. This is useful for comparing performance between standard libraries.
Support for benchmarks is currently very minimal. They must be manually run by the user and there is no mechanism for detecting performance regressions.
Known Issues:
* `-DLIBCXX_INCLUDE_BENCHMARKS=ON` is only supported for Clang, and not GCC, since the `-stdlib=libc++` option is needed to build Google Benchmark.
Reviewers: danalbert, dberlin, chandlerc, mclow.lists, jroelofs
Subscribers: chandlerc, dberlin, tberghammer, danalbert, srhines, hfinkel
Differential Revision: https://reviews.llvm.org/D22240
llvm-svn: 276049
2016-07-20 07:07:03 +08:00
|
|
|
if (LIBCXX_INCLUDE_BENCHMARKS)
|
|
|
|
add_subdirectory(benchmarks)
|
|
|
|
endif()
|
2015-07-31 06:30:34 +08:00
|
|
|
if (LIBCXX_INCLUDE_TESTS)
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
2015-08-23 03:40:49 +08:00
|
|
|
if (LIBCXX_INCLUDE_DOCS)
|
|
|
|
add_subdirectory(docs)
|
|
|
|
endif()
|