diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-06-02 02:18:31 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-06-02 02:18:31 +0000 |
commit | ffd1893df575aa6dda6b37f0c942293330110907 (patch) | |
tree | c8756dd63d0d3dd93f5ea0ac055bd690b00df238 | |
parent | e44604aec73c7f8864ccd1fe295f41d80066f1ed (diff) | |
download | bcm5719-llvm-ffd1893df575aa6dda6b37f0c942293330110907.tar.gz bcm5719-llvm-ffd1893df575aa6dda6b37f0c942293330110907.zip |
[libcxxabi] Allow target flags to affect configuration tests.
Summary:
This patch changes the libc++abi CMake so that it adds certain target flags like '-m32' or '--gcc-toolchain' before including `config-ix.cmake`.
Since these flags can affect things like `check_library_exists([...])` they needed to be added before the tests are performed.
Additionally this patch adds `LIBCXXABI_BUILD_32_BITS` which defaults to `LLVM_BUILD_32_BITS`.
This patch fixes:
https://llvm.org/bugs/show_bug.cgi?id=27950
https://llvm.org/bugs/show_bug.cgi?id=27959
Reviewers: danalbert, jroelofs, bcraig, compnerd, EricWF
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D20886
llvm-svn: 271470
-rw-r--r-- | libcxxabi/CMakeLists.txt | 40 | ||||
-rw-r--r-- | libcxxabi/test/CMakeLists.txt | 2 | ||||
-rw-r--r-- | libcxxabi/test/lit.site.cfg.in | 2 |
3 files changed, 33 insertions, 11 deletions
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index 6bebf53b44d..4900b6c6e6a 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -115,6 +115,8 @@ 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) option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF) +option(LIBCXXABI_BUILD_32_BITS "Build 32 bit libc++abi." ${LLVM_BUILD_32_BITS}) +set(LIBCXXABI_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.") 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.") @@ -173,9 +175,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ) -# Configure compiler. -include(config-ix) - set(LIBCXXABI_COMPILER ${CMAKE_CXX_COMPILER}) set(LIBCXXABI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) @@ -191,6 +190,16 @@ if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH) "The path to libc++ library.") endif () + +# Check that we can build with 32 bits if requested. +if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) + if (LIBCXXABI_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(LIBCXXABI_BUILD_32_BITS) + message(FATAL_ERROR "LIBCXXABI_BUILD_32_BITS=ON is not supported on this platform.") +endif() + #=============================================================================== # Setup Compiler Flags #=============================================================================== @@ -202,11 +211,30 @@ macro(append_if list condition var) endif() endmacro() +macro(add_target_flags_if condition var) + if (${condition}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${var}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${var}") + list(APPEND LIBCXXABI_LINK_FLAGS ${var}) + endif() +endmacro() + set(LIBCXXABI_C_FLAGS "") set(LIBCXXABI_CXX_FLAGS "") set(LIBCXXABI_COMPILE_FLAGS "") set(LIBCXXABI_LINK_FLAGS "") +# Configure target flags +add_target_flags_if(LIBCXXABI_BUILD_32_BITS "-m32") +add_target_flags_if(LIBCXXABI_TARGET_TRIPLE + "-target ${LIBCXXABI_TARGET_TRIPLE}") +add_target_flags_if(LIBCXXABI_GCC_TOOLCHAIN + "-gcc-toolchain ${LIBCXXABI_GCC_TOOLCHAIN}") +add_target_flags_if(LIBCXXABI_SYSROOT + "--sysroot=${LIBCXXABI_SYSROOT}") + +# Configure compiler. Must happen after setting the target flags. +include(config-ix) if (LIBCXXABI_HAS_NOSTDINCXX_FLAG) list(APPEND LIBCXXABI_COMPILE_FLAGS -nostdinc++) @@ -312,12 +340,6 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM) add_definitions(-DLIBCXXABI_USE_LLVM_UNWINDER=1) endif() -append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_TARGET_TRIPLE - "-target ${LIBCXXABI_TARGET_TRIPLE}") -append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_GCC_TOOLCHAIN - "-gcc-toolchain ${LIBCXXABI_GCC_TOOLCHAIN}") -append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_SYSROOT - "--sysroot ${LIBCXXABI_SYSROOT}") string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}") diff --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt index a3de1b3d6d7..31b5d1dc38b 100644 --- a/libcxxabi/test/CMakeLists.txt +++ b/libcxxabi/test/CMakeLists.txt @@ -10,7 +10,7 @@ if (NOT DEFINED LIBCXX_ENABLE_SHARED) set(LIBCXX_ENABLE_SHARED ON) endif() -pythonize_bool(LLVM_BUILD_32_BITS) +pythonize_bool(LIBCXXABI_BUILD_32_BITS) pythonize_bool(LIBCXX_ENABLE_SHARED) pythonize_bool(LIBCXXABI_ENABLE_SHARED) pythonize_bool(LIBCXXABI_ENABLE_THREADS) diff --git a/libcxxabi/test/lit.site.cfg.in b/libcxxabi/test/lit.site.cfg.in index 70eee8a11db..ec4d3f75bf9 100644 --- a/libcxxabi/test/lit.site.cfg.in +++ b/libcxxabi/test/lit.site.cfg.in @@ -10,7 +10,7 @@ config.cxx_library_root = "@LIBCXXABI_LIBCXX_LIBRARY_PATH@" config.llvm_unwinder = "@LIBCXXABI_USE_LLVM_UNWINDER@" config.enable_threads = "@LIBCXXABI_ENABLE_THREADS@" config.use_sanitizer = "@LLVM_USE_SANITIZER@" -config.enable_32bit = "@LLVM_BUILD_32_BITS@" +config.enable_32bit = "@LIBCXXABI_BUILD_32_BITS@" config.target_info = "@LIBCXXABI_TARGET_INFO@" config.executor = "@LIBCXXABI_EXECUTOR@" config.thread_atexit = "@LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL@" |