summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-10-19 00:42:41 +0000
committerEric Fiselier <eric@efcs.ca>2014-10-19 00:42:41 +0000
commita63c149ceb0e68037df3b7838ed55f6724280b33 (patch)
tree66459725f6d7ee86c2cf540e9f97e310a54715a5 /libcxx
parent8a99373812cfc7feb30c28ef5fb23c774856eb38 (diff)
downloadbcm5719-llvm-a63c149ceb0e68037df3b7838ed55f6724280b33.tar.gz
bcm5719-llvm-a63c149ceb0e68037df3b7838ed55f6724280b33.zip
[libcxx] Redo adding support for building and testing with an ABI library not along linker paths
Summary: This is the second attempt at allowing for the use of libraries that the linker cannot find. The first attempt used `CMAKE_LIBRARY_PATH` and `find_library` to select which ABI library should be used. There were a number of problems with this approach: - `find_library` didn't work with cmake targets (ie in-tree libcxxabi build) - It wasn't always possible to determine where `find_library` actually found your library. - `target_link_libraries` inserted the path of the ABI library into libc++'s RPATH when `find_library` was used. - Linking libc++ and it's ABI library is a special case. It's a lot easier to keep it simple. After discussion with @cbergstrum a new approach was decided upon. This patch achieve the same ends by simply using `LIBCXX_CXX_ABI_LIBRARY_PATH` to specify where to find the library (if the linker won't find it). When this variable is defined it is simply added as a library search path when linking libc++. It is a lot easier to duplicate this behavior in LIT. It also prevents libc++ from being linked with an RPATH. Reviewers: mclow.lists, cbergstrom, chandlerc, danalbert Reviewed By: chandlerc, danalbert Subscribers: chandlerc, cfe-commits Differential Revision: http://reviews.llvm.org/D5860 llvm-svn: 220157
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/cmake/Modules/HandleLibCXXABI.cmake26
-rw-r--r--libcxx/lib/CMakeLists.txt6
-rw-r--r--libcxx/test/lit.cfg14
-rw-r--r--libcxx/test/lit.site.cfg.in2
-rw-r--r--libcxx/www/index.html5
5 files changed, 18 insertions, 35 deletions
diff --git a/libcxx/cmake/Modules/HandleLibCXXABI.cmake b/libcxx/cmake/Modules/HandleLibCXXABI.cmake
index 8a9f8632dcb..ff830d5f28a 100644
--- a/libcxx/cmake/Modules/HandleLibCXXABI.cmake
+++ b/libcxx/cmake/Modules/HandleLibCXXABI.cmake
@@ -8,41 +8,21 @@
#
# Parameters:
# abidefines: A list of defines needed to compile libc++ with the ABI library
-# abilibs : A list of libraries to link against
+# abilib : The ABI library to link against.
# abifiles : A list of files (which may be relative paths) to copy into the
# libc++ build tree for the build. These files will also be
# installed alongside the libc++ headers.
# abidirs : A list of relative paths to create under an include directory
# in the libc++ build directory.
#
-macro(setup_abi_lib abipathvar abidefines abilibs abifiles abidirs)
+macro(setup_abi_lib abipathvar abidefines abilib abifiles abidirs)
list(APPEND LIBCXX_CXX_FEATURE_FLAGS ${abidefines})
set(${abipathvar} "${${abipathvar}}"
CACHE PATH
"Paths to C++ ABI header directories separated by ';'." FORCE
)
- # To allow for libraries installed along non-default paths we use find_library
- # to locate the ABI libraries we want. Making sure to clean the cache before
- # each run of find_library.
- set(LIBCXX_CXX_ABI_LIBRARIES "")
- foreach(alib ${abilibs})
- # cxxabi is a cmake target and not a library.
- # Handle this special case explicitly.
- # Otherwise use find_library to locate the correct binary.
- if (alib STREQUAL "cxxabi")
- list(APPEND LIBCXX_CXX_ABI_LIBRARIES cxxabi)
- else()
- unset(_Res CACHE)
- find_library(_Res ${alib})
- if (${_Res} STREQUAL "_Res-NOTFOUND")
- message(FATAL_ERROR "Failed to find ABI library: ${alib}")
- else()
- message(STATUS "Adding ABI library: ${_Res}")
- list(APPEND LIBCXX_CXX_ABI_LIBRARIES ${_Res})
- endif()
- endif()
- endforeach()
+ set(LIBCXX_CXX_ABI_LIBRARY ${abilib})
set(LIBCXX_ABILIB_FILES ${abifiles})
diff --git a/libcxx/lib/CMakeLists.txt b/libcxx/lib/CMakeLists.txt
index d56ade4f2fd..cd8553c3d36 100644
--- a/libcxx/lib/CMakeLists.txt
+++ b/libcxx/lib/CMakeLists.txt
@@ -36,13 +36,17 @@ if (DEFINED LIBCXX_CXX_ABI_DEPS)
endif()
# Generate library list.
-set(libraries ${LIBCXX_CXX_ABI_LIBRARIES})
+set(libraries ${LIBCXX_CXX_ABI_LIBRARY})
append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread)
append_if(libraries LIBCXX_HAS_C_LIB c)
append_if(libraries LIBCXX_HAS_M_LIB m)
append_if(libraries LIBCXX_HAS_RT_LIB rt)
append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s)
+#if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path.
+if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH)
+ target_link_libraries(cxx "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
+endif()
target_link_libraries(cxx ${libraries})
# Setup flags.
diff --git a/libcxx/test/lit.cfg b/libcxx/test/lit.cfg
index 6d30e5fcd91..d60c9693919 100644
--- a/libcxx/test/lit.cfg
+++ b/libcxx/test/lit.cfg
@@ -374,10 +374,13 @@ class Configuration(object):
def configure_link_flags(self):
# Configure library search paths
- lpaths = self.get_lit_conf('library_paths', '').split(';')
- lpaths = [l for l in lpaths if l.strip()]
+ abi_library_path = self.get_lit_conf('abi_library_path', '')
self.link_flags += ['-L' + self.obj_root + '/lib']
- self.link_flags += ['-L' + l for l in lpaths]
+ if not self.use_system_lib:
+ self.link_flags += ['-Wl,-rpath', '-Wl,' + self.obj_root + '/lib']
+ if abi_library_path:
+ self.link_flags += ['-L' + abi_library_path,
+ '-Wl,-rpath', '-Wl,' + abi_library_path]
# Configure libraries
self.link_flags += ['-lc++']
link_flags_str = self.get_lit_conf('link_flags')
@@ -412,11 +415,6 @@ class Configuration(object):
if link_flags_str:
self.link_flags += shlex.split(link_flags_str)
- # Configure library runtime search paths
- if not self.use_system_lib:
- self.link_flags += ['-Wl,-rpath', '-Wl,' + self.obj_root + '/lib']
- for l in lpaths:
- self.link_flags += ['-Wl,-rpath', '-Wl,' + l]
def configure_std_flag(self):
# Try and get the std version from the command line. Fall back to
diff --git a/libcxx/test/lit.site.cfg.in b/libcxx/test/lit.site.cfg.in
index 0c5f2609874..43fdb7d32bd 100644
--- a/libcxx/test/lit.site.cfg.in
+++ b/libcxx/test/lit.site.cfg.in
@@ -7,7 +7,7 @@ config.python_executable = "@PYTHON_EXECUTABLE@"
config.enable_shared = @LIBCXX_ENABLE_SHARED@
config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@"
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.library_paths = "@CMAKE_LIBRARY_PATH@"
+config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
# Let the main config do the real work.
lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")
diff --git a/libcxx/www/index.html b/libcxx/www/index.html
index b9bb1f86b73..8e1c0748341 100644
--- a/libcxx/www/index.html
+++ b/libcxx/www/index.html
@@ -448,7 +448,8 @@ End of search list.
Normally you must link libc++ against a ABI shared library that the
linker can find. If you want to build and test libc++ against an ABI
library not in the linker's path you need to set
- <code>-DCMAKE_LIBRARY_PATH=/path/to/abi/lib</code> when configuring CMake.
+ <code>-DLIBCXX_CXX_ABI_LIBRARY_PATH=/path/to/abi/lib</code> when
+ configuring CMake.
</p>
<p>
An example build using libc++abi would look like:
@@ -456,7 +457,7 @@ End of search list.
<li><code>CC=clang CXX=clang++ cmake
-DLIBCXX_CXX_ABI=libc++abi
-DLIBCXX_LIBCXXABI_INCLUDE_PATHS="/path/to/libcxxabi/include"
- -DCMAKE_LIBRARY_PATH="/path/to/libcxxabi-build/lib"
+ -DLIBCXX_CXX_ABI_LIBRARY_PATH="/path/to/libcxxabi-build/lib"
path/to/libcxx</code></li>
<li><code>make</code></li>
</ul>
OpenPOWER on IntegriCloud