[libcxxabi] r271470 - [libcxxabi] Allow target flags to affect configuration tests.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 1 19:18:31 PDT 2016


Author: ericwf
Date: Wed Jun  1 21:18:31 2016
New Revision: 271470

URL: http://llvm.org/viewvc/llvm-project?rev=271470&view=rev
Log:
[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

Modified:
    libcxxabi/trunk/CMakeLists.txt
    libcxxabi/trunk/test/CMakeLists.txt
    libcxxabi/trunk/test/lit.site.cfg.in

Modified: libcxxabi/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=271470&r1=271469&r2=271470&view=diff
==============================================================================
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Wed Jun  1 21:18:31 2016
@@ -115,6 +115,8 @@ option(LIBCXXABI_ENABLE_WERROR "Fail and
 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_
   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}")

Modified: libcxxabi/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/CMakeLists.txt?rev=271470&r1=271469&r2=271470&view=diff
==============================================================================
--- libcxxabi/trunk/test/CMakeLists.txt (original)
+++ libcxxabi/trunk/test/CMakeLists.txt Wed Jun  1 21:18:31 2016
@@ -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)

Modified: libcxxabi/trunk/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/lit.site.cfg.in?rev=271470&r1=271469&r2=271470&view=diff
==============================================================================
--- libcxxabi/trunk/test/lit.site.cfg.in (original)
+++ libcxxabi/trunk/test/lit.site.cfg.in Wed Jun  1 21:18:31 2016
@@ -10,7 +10,7 @@ config.cxx_library_root         = "@LIBC
 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@"




More information about the cfe-commits mailing list