forked from OSchip/llvm-project
[libcxx] Make libc++.so a linker script by default on most platforms.
Summary: This patch turns on `LIBCXX_ENABLE_ABI_LINKER_SCRIPT` by default whenever `LLVM_HAVE_LINK_VERSION_SCRIPT` is ON. This turns out to be whenever: 1. WIN32 is not defined. 2 UNIX is defined. 3. APPLE is not defined. While `LLVM_HAVE_LINK_VERSION_SCRIPT` is meant to reflect exactly what we are asking I think it's close enough. After committing this patch Linux users will no longer have to use "-lc++abi" explicitly! Reviewers: mclow.lists, danalbert, compnerd, jroelofs Subscribers: emaste, rengolin, cbergstrom, cfe-commits Differential Revision: http://reviews.llvm.org/D13739 llvm-svn: 250469
This commit is contained in:
parent
0f629153af
commit
1ab69fc532
|
@ -67,12 +67,22 @@ set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
|
||||||
set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
|
set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
|
||||||
set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
|
set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
|
||||||
|
|
||||||
|
# Use a static copy of the ABI library when linking libc++. This option
|
||||||
|
# cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT.
|
||||||
option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
|
option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
|
||||||
|
|
||||||
# Generate and install a linker script inplace of libc++.so. The linker script
|
# Generate and install a linker script inplace of libc++.so. The linker script
|
||||||
# will link libc++ to the correct ABI library.
|
# 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'
|
||||||
|
# is on.
|
||||||
|
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
|
||||||
|
if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
|
||||||
|
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT
|
option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT
|
||||||
"Use and install a linker script for the given ABI library" OFF)
|
"Use and install a linker script for the given ABI library"
|
||||||
|
${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE})
|
||||||
|
|
||||||
# Build libc++abi with libunwind. We need this option to determine whether to
|
# Build libc++abi with libunwind. We need this option to determine whether to
|
||||||
# link with libunwind or libgcc_s while running the test cases.
|
# link with libunwind or libgcc_s while running the test cases.
|
||||||
|
|
|
@ -109,6 +109,30 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
message(STATUS "Sphinx disabled.")
|
message(STATUS "Sphinx disabled.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# FIXME - This is cribbed from HandleLLVMOptions.cmake.
|
||||||
|
if(WIN32)
|
||||||
|
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
|
||||||
|
if(CYGWIN)
|
||||||
|
set(LLVM_ON_WIN32 0)
|
||||||
|
set(LLVM_ON_UNIX 1)
|
||||||
|
else(CYGWIN)
|
||||||
|
set(LLVM_ON_WIN32 1)
|
||||||
|
set(LLVM_ON_UNIX 0)
|
||||||
|
endif(CYGWIN)
|
||||||
|
else(WIN32)
|
||||||
|
if(UNIX)
|
||||||
|
set(LLVM_ON_WIN32 0)
|
||||||
|
set(LLVM_ON_UNIX 1)
|
||||||
|
if(APPLE)
|
||||||
|
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
|
||||||
|
else(APPLE)
|
||||||
|
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
|
||||||
|
endif(APPLE)
|
||||||
|
else(UNIX)
|
||||||
|
MESSAGE(SEND_ERROR "Unable to determine platform")
|
||||||
|
endif(UNIX)
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
# Add LLVM Functions --------------------------------------------------------
|
# Add LLVM Functions --------------------------------------------------------
|
||||||
include(AddLLVM OPTIONAL)
|
include(AddLLVM OPTIONAL)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -170,6 +170,14 @@ ABI Library Specific Options
|
||||||
If this option is enabled, libc++ will try and link the selected ABI library
|
If this option is enabled, libc++ will try and link the selected ABI library
|
||||||
statically.
|
statically.
|
||||||
|
|
||||||
|
.. option:: LIBCXX_ENABLE_ABI_LINKER_SCRIPT:BOOL
|
||||||
|
|
||||||
|
**Default**: ``ON`` by default on UNIX platforms other than Apple unless
|
||||||
|
'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' is ON. Otherwise the default value is ``OFF``.
|
||||||
|
|
||||||
|
This option generate and installs a linker script as ``libc++.so`` which
|
||||||
|
links the correct ABI library.
|
||||||
|
|
||||||
.. option:: LIBCXXABI_USE_LLVM_UNWINDER:BOOL
|
.. option:: LIBCXXABI_USE_LLVM_UNWINDER:BOOL
|
||||||
|
|
||||||
**Default**: ``OFF``
|
**Default**: ``OFF``
|
||||||
|
|
|
@ -54,10 +54,10 @@ An example of using ``LD_LIBRARY_PATH``:
|
||||||
Using libc++ on Linux
|
Using libc++ on Linux
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
On Linux libc++ typically links to a shared version of libc++abi. Unfortunately
|
On Linux libc++ can typically be used with only '-stdlib=libc++'. However
|
||||||
you can't simply run clang with "-stdlib=libc++" as clang is not set up to
|
some libc++ installations require the user manually link libc++abi themselves.
|
||||||
link for this configuration. To get around this you'll have to manually
|
If you are running into linker errors when using libc++ try adding '-lc++abi'
|
||||||
link libc++abi yourself. For example:
|
to the link line. For example:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue