Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -116,9 +116,9 @@ option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON) -set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE STRING "GCC toolchain for cross compiling.") -set(LIBCXXABI_SYSROOT "" CACHE STRING "Sysroot for cross compiling.") -set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE STRING "The path to libc++ library.") +set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.") +set(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.") +set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.") # Default to building a shared library so that the default options still test # the libc++abi that is being built. There are two problems with testing a @@ -182,6 +182,13 @@ set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) +# By default, for non-standalone builds, libcxx and libcxxabi share a library +# directory. +if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH) + set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH + "The path to libc++ library.") +endif () + #=============================================================================== # Setup Compiler Flags #=============================================================================== @@ -338,14 +345,16 @@ # soname, etc... add_subdirectory(src) -if(NOT LIBCXXABI_ENABLE_SHARED) - # TODO: Fix the libc++ cmake files so that libc++abi can be statically linked. - # As it is now, libc++ will prefer linking against a dynamic libc++abi in the - # system library paths over a static libc++abi in the out directory. This - # would test the system library rather than the one we just built, which isn't - # very helpful. - message(WARNING "The libc++abi tests are currently only valid when " - "LIBCXXABI_ENABLE_SHARED is on, no check target will be " +if (LIBCXXABI_BUILT_STANDALONE AND NOT LIBCXXABI_ENABLE_SHARED) + # We can't reasonably test the system C++ library with a static libc++abi. + # We either need to be able to replace libc++abi at run time (with a shared + # libc++abi), or we need to be able to replace the C++ runtime (with a non- + # standalone build). + message(WARNING "The libc++abi tests aren't valid when libc++abi is built " + "standalone (i.e. outside of llvm/projects/libcxxabi ) and " + "is built without a shared library. Either build a shared " + "library, build libc++abi at the same time as you build " + "libc++, or do without testing. No check target will be " "available!") else() add_subdirectory(test) Index: test/CMakeLists.txt =================================================================== --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -6,7 +6,12 @@ endif() endmacro() +if (NOT DEFINED LIBCXX_ENABLE_SHARED) + set(LIBCXX_ENABLE_SHARED ON) +endif() + pythonize_bool(LLVM_BUILD_32_BITS) +pythonize_bool(LIBCXX_ENABLE_SHARED) pythonize_bool(LIBCXXABI_ENABLE_SHARED) pythonize_bool(LIBCXXABI_ENABLE_THREADS) pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) @@ -22,7 +27,12 @@ ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg @ONLY) -set(LIBCXXABI_TEST_DEPS cxxabi_shared) +if (LIBCXXABI_ENABLE_SHARED) + set(LIBCXXABI_TEST_DEPS cxxabi_shared) +else() + set(LIBCXXABI_TEST_DEPS cxxabi_static) +endif() + if (NOT LIBCXXABI_BUILT_STANDALONE) list(APPEND LIBCXXABI_TEST_DEPS cxx) endif() Index: test/libcxxabi/test/config.py =================================================================== --- test/libcxxabi/test/config.py +++ test/libcxxabi/test/config.py @@ -68,13 +68,3 @@ def configure_compile_flags_rtti(self): pass - - # TODO(ericwf): Remove this. This is a hack for OS X. - # libc++ *should* export all of the symbols found in libc++abi on OS X. - # For this reason LibcxxConfiguration will not link libc++abi in OS X. - # However __cxa_throw_bad_new_array_length doesn't get exported into libc++ - # yet so we still need to explicitly link libc++abi. - # See PR22654. - def configure_link_flags_abi_library(self): - self.cxx.link_flags += ['-lc++abi'] - Index: test/lit.site.cfg.in =================================================================== --- test/lit.site.cfg.in +++ test/lit.site.cfg.in @@ -14,6 +14,8 @@ config.target_info = "@LIBCXXABI_TARGET_INFO@" config.executor = "@LIBCXXABI_EXECUTOR@" config.thread_atexit = "@LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL@" +config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@" +config.enable_shared = "@LIBCXX_ENABLE_SHARED@" # Let the main config do the real work. lit_config.load_config(config, "@LIBCXXABI_SOURCE_DIR@/test/lit.cfg")