[cfe-commits] [PATCH] [libcxx][CMake] Add initial support for selecting a specific c++ abi to use.

Michael Spencer bigcheesegs at gmail.com
Fri Nov 2 12:02:57 PDT 2012


On Thu, Oct 25, 2012 at 1:19 PM, Michael Spencer <bigcheesegs at gmail.com> wrote:
> This patch adds initial support for selecting which c++ abi library to use and install. It currently only handles libsupc++. This change makes libc++ significantly easier to use on Linux and provides cxxabi.h in the expected location.
>
> http://llvm-reviews.chandlerc.com/D82
>
> Files:
>   CMakeLists.txt
>   lib/CMakeLists.txt
>   src/exception.cpp
>
> Index: CMakeLists.txt
> ===================================================================
> --- CMakeLists.txt
> +++ CMakeLists.txt
> @@ -39,6 +39,11 @@
>  option(LIBCXX_ENABLE_CXX0X "Enable -std=c++0x and use of c++0x language features if the compiler supports it." ON)
>  option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
>
> +set(CXXABIS none libcxxabi libcxxrt libsupc++)
> +set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
> +    "Specify C++ ABI library to use." FORCE)
> +set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS "";${CXXABIS})
> +
>  #===============================================================================
>  # Configure System
>  #===============================================================================
> @@ -58,6 +63,44 @@
>    )
>  set(LIBCXX_TARGET_TRIPLE ${LIBCXX_TARGET_TRIPLE} CACHE STRING "Target triple.")
>
> +if (${LIBCXX_CXX_ABI} STREQUAL "libsupc++")
> +  set(LIBCXX_LIBSUPCXX_INCLUDE_PATHS "" CACHE STRINGS
> +      "Paths to libsupc++ include directories. Separate by system separator")
> +  set(LIBCXX_CXX_ABI_LIBRARIES stdc++)
> +  set(LIBCXX_LIBSUPCXX_FILES
> +      cxxabi.h
> +      bits/c++config.h
> +      bits/os_defines.h
> +      bits/cpu_defines.h
> +      bits/cxxabi_tweaks.h
> +      bits/cxxabi_forced.h
> +      )
> +  set(LIBCXX_LIBSUPCXX_FILE_PATHS)
> +  foreach(file ${LIBCXX_LIBSUPCXX_FILES})
> +    set(found FALSE)
> +    foreach(incpath ${LIBCXX_LIBSUPCXX_INCLUDE_PATHS})
> +      if (EXISTS "${incpath}/${file}")
> +        set(found TRUE)
> +        get_filename_component(dstdir ${file} PATH)
> +        file(COPY "${incpath}/${file}"
> +             DESTINATION "${CMAKE_BINARY_DIR}/include/${dstdir}")
> +      endif()
> +    endforeach()
> +    if (NOT found)
> +      message(FATAL_ERROR "Failed to find ${file}")
> +    endif()
> +  endforeach()
> +  include_directories("${CMAKE_BINARY_DIR}/include")
> +  install(DIRECTORY "${CMAKE_BINARY_DIR}/include/"
> +    DESTINATION include/c++/v1
> +    FILES_MATCHING
> +    PATTERN "*"
> +    )
> +elseif (${LIBCXX_CXX_ABI} NOT STREQUAL "none")
> +  message(FATAL_ERROR
> +          "Currently only none and libsupc++ are supported for c++ abi.")
> +endif ()
> +
>  # Configure compiler.
>  include(config-ix)
>
> Index: lib/CMakeLists.txt
> ===================================================================
> --- lib/CMakeLists.txt
> +++ lib/CMakeLists.txt
> @@ -32,6 +32,7 @@
>  endif()
>
>  # Generate library list.
> +set(libraries ${LIBCXX_CXX_ABI_LIBRARIES})
>  append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread)
>  append_if(libraries LIBCXX_HAS_C_LIB c)
>  append_if(libraries LIBCXX_HAS_M_LIB m)
> Index: src/exception.cpp
> ===================================================================
> --- src/exception.cpp
> +++ src/exception.cpp
> @@ -41,7 +41,7 @@
>  namespace std
>  {
>
> -#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
> +#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__)
>
>  // libcxxrt provides implementations of these functions itself.
>  unexpected_handler
> @@ -99,7 +99,7 @@
>  }
>  #endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
>
> -#ifndef LIBCXXRT
> +#if !defined(LIBCXXRT) && !defined(__GLIBCXX__)
>  bool uncaught_exception() _NOEXCEPT
>  {
>  #if __APPLE__ || defined(_LIBCPPABI_VERSION)
> @@ -124,7 +124,7 @@
>
>  #endif  // _LIBCPPABI_VERSION
>  #endif //LIBCXXRT
> -#ifndef _LIBCPPABI_VERSION
> +#if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__)
>
>  bad_exception::~bad_exception() _NOEXCEPT
>  {

ping.

- Michael Spencer



More information about the cfe-commits mailing list