Skip to content

Commit

Permalink
Create new library 'libc++experimental.a' for packaging TS symbols.
Browse files Browse the repository at this point in the history
Summary:
Out-of-line symbols for <experimental/...> headers are not ABI or API stable and cannot live in the 'libc++.dylib'. Currently they have nowhere to live. I would like to add a new library target `libc++experimental.a` to fix this. 

Previously I had suggested different libraries for different TS's (`libc++filesystem.a`, 'libc++LFTS.a`, ect). I no longer think this is the right approach.
Instead `c++experimental` will hold *all* TS implementations as a single monolithic library. I see two main benefits to this:

1. Users only have to know about and manually link one library.
2. It makes it easy to implement TS's with one or two out-of-line symbols. (Ex. PMRs)

`c++experimental` provides NO ABI compatibility. Symbols can freely be added/removed/changed without concern for ABI stability.
I will add documentation for this after landing this patch (but before adding anything to it).

`c++experimental` only builds as a static library. By default CMake will build/test this library but will *NOT* install it.

This patch adds the CMake and LIT logic needed to build/test the new library. Once this lands I plan on using it to implement parts of `<experimental/memory_resource>`.



Reviewers: mclow.lists

Subscribers: cfe-commits, theraven, krememek, dexonsmith, bcraig, beanz, danalbert

Differential Revision: http://reviews.llvm.org/D19856

llvm-svn: 268443
  • Loading branch information
EricWF committed May 3, 2016
1 parent c91e0b2 commit 27cb2f1
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
3 changes: 2 additions & 1 deletion libcxx/CMakeLists.txt
Expand Up @@ -52,14 +52,15 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
# Basic options ---------------------------------------------------------------
option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)

option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON)
option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS})
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)
option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY "Install libc++experimental.a" OFF)
set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)

Expand Down
23 changes: 21 additions & 2 deletions libcxx/lib/CMakeLists.txt
Expand Up @@ -138,6 +138,17 @@ set_target_properties(cxx
SOVERSION "${LIBCXX_ABI_VERSION}"
)

if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp)
add_library(cxx_experimental STATIC ${LIBCXX_EXPERIMENTAL_SOURCES})
target_link_libraries(cxx_experimental cxx)
set_target_properties(cxx_experimental
PROPERTIES
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
OUTPUT_NAME "c++experimental"
)
endif()

# Generate a linker script inplace of a libc++.so symlink. Rerun this command
# after cxx builds.
if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
Expand All @@ -160,7 +171,10 @@ if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
endif()

if (LIBCXX_INSTALL_LIBRARY)
install(TARGETS cxx
if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
set(experimental_lib cxx_experimental)
endif()
install(TARGETS cxx ${experimental_lib}
LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
)
Expand All @@ -180,11 +194,16 @@ if (NOT CMAKE_CONFIGURATION_TYPES AND (LIBCXX_INSTALL_LIBRARY OR
if(LIBCXX_INSTALL_LIBRARY)
set(lib_install_target cxx)
endif()
if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
set(experimental_lib_install_target cxx_experimental)
endif()
if(LIBCXX_INSTALL_HEADERS)
set(header_install_target install-libcxx-headers)
endif()
add_custom_target(install-libcxx
DEPENDS ${lib_install_target} ${header_install_target}
DEPENDS ${lib_install_target}
${experimental_lib_install_target}
${header_install_target}
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=libcxx
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
Expand Down
14 changes: 14 additions & 0 deletions libcxx/src/experimental/placeholder.cpp
@@ -0,0 +1,14 @@
//===--------------------------- TODO.cpp ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "experimental/__config"

_LIBCPP_BEGIN_NAMESPACE_LFTS

_LIBCPP_END_NAMESPACE_LFTS
1 change: 1 addition & 0 deletions libcxx/test/CMakeLists.txt
Expand Up @@ -10,6 +10,7 @@ set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
"Configuration variant to use for LIT.")

pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
pythonize_bool(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
pythonize_bool(LIBCXX_ENABLE_RTTI)
pythonize_bool(LIBCXX_ENABLE_SHARED)
pythonize_bool(LIBCXX_BUILD_32_BITS)
Expand Down
4 changes: 4 additions & 0 deletions libcxx/test/libcxx/test/config.py
Expand Up @@ -456,6 +456,10 @@ def configure_link_flags_abi_library_path(self):
'-Wl,-rpath,' + self.abi_library_root]

def configure_link_flags_cxx_library(self):
libcxx_experimental = self.get_lit_bool('enable_experimental', default=False)
if libcxx_experimental:
self.config.available_features.add('c++experimental')
self.cxx.link_flags += ['-lc++experimental']
libcxx_shared = self.get_lit_bool('enable_shared', default=True)
if libcxx_shared:
self.cxx.link_flags += ['-lc++']
Expand Down
1 change: 1 addition & 0 deletions libcxx/test/lit.site.cfg.in
Expand Up @@ -5,6 +5,7 @@ config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@"
config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@"
config.cxx_library_root = "@LIBCXX_LIBRARY_DIR@"
config.enable_exceptions = "@LIBCXX_ENABLE_EXCEPTIONS@"
config.enable_experimental = "@LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY@"
config.enable_rtti = "@LIBCXX_ENABLE_RTTI@"
config.enable_shared = "@LIBCXX_ENABLE_SHARED@"
config.enable_32bit = "@LIBCXX_BUILD_32_BITS@"
Expand Down

0 comments on commit 27cb2f1

Please sign in to comment.