forked from OSchip/llvm-project
[gn] Support for building libcxxabi
This change introduces support for building libcxxabi. The library build should be complete, but not all CMake options have been replicated in GN. We also don't support tests yet. We only support two stage build at the moment. Differential Revision: https://reviews.llvm.org/D60372 llvm-svn: 359805
This commit is contained in:
parent
f0652f03b6
commit
4fe63c70c7
|
@ -451,9 +451,7 @@ set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
|
|||
|
||||
include_directories(include)
|
||||
if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM)
|
||||
find_path(
|
||||
LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL
|
||||
libunwind.h
|
||||
find_path(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL libunwind.h
|
||||
PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES}
|
||||
${LIBCXXABI_LIBUNWIND_PATH}/include
|
||||
${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES}
|
||||
|
|
|
@ -25,17 +25,23 @@ if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
|
|||
endif()
|
||||
|
||||
if (LIBCXXABI_ENABLE_EXCEPTIONS)
|
||||
list(APPEND LIBCXXABI_SOURCES cxa_exception.cpp)
|
||||
list(APPEND LIBCXXABI_SOURCES cxa_personality.cpp)
|
||||
list(APPEND LIBCXXABI_SOURCES
|
||||
cxa_exception.cpp
|
||||
cxa_personality.cpp
|
||||
)
|
||||
else()
|
||||
list(APPEND LIBCXXABI_SOURCES cxa_noexception.cpp)
|
||||
list(APPEND LIBCXXABI_SOURCES
|
||||
cxa_noexception.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (LIBCXXABI_ENABLE_THREADS AND (UNIX OR FUCHSIA) AND NOT (APPLE OR CYGWIN))
|
||||
list(APPEND LIBCXXABI_SOURCES cxa_thread_atexit.cpp)
|
||||
endif()
|
||||
|
||||
set(LIBCXXABI_HEADERS ../include/cxxabi.h)
|
||||
set(LIBCXXABI_HEADERS
|
||||
../include/cxxabi.h
|
||||
)
|
||||
|
||||
# Add all the headers to the project for IDEs.
|
||||
if (MSVC_IDE OR XCODE)
|
||||
|
|
|
@ -13,6 +13,7 @@ group("default") {
|
|||
if (current_os == "linux") {
|
||||
deps += [
|
||||
"//compiler-rt",
|
||||
"//libcxxabi",
|
||||
"//libunwind",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
group("libcxxabi") {
|
||||
deps = [
|
||||
"//libcxxabi/src(//llvm/utils/gn/build/toolchain:stage2_unix)",
|
||||
]
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
import("//clang/runtimes.gni")
|
||||
|
||||
declare_args() {
|
||||
# Use exceptions.
|
||||
libcxxabi_enable_exceptions = true
|
||||
|
||||
# Build libc++abi with definitions for operator new/delete.
|
||||
libcxxabi_enable_new_delete_definitions = true
|
||||
|
||||
# Build libcxxabi as a shared library.
|
||||
libcxxabi_enable_shared = true
|
||||
|
||||
# Build libcxxabi as a static library.
|
||||
libcxxabi_enable_static = true
|
||||
|
||||
# Do not export any symbols from the static library.
|
||||
libcxxabi_hermetic_static_library = true
|
||||
}
|
||||
|
||||
cxxabi_headers = [
|
||||
# This comment prevents `gn format` from putting the file on the same line
|
||||
# as `sources +=`, for sync_source_lists_from_cmake.py.
|
||||
"../include/cxxabi.h",
|
||||
]
|
||||
|
||||
cxxabi_sources = [
|
||||
# C++ABI files
|
||||
"cxa_aux_runtime.cpp",
|
||||
"cxa_default_handlers.cpp",
|
||||
"cxa_demangle.cpp",
|
||||
"cxa_exception_storage.cpp",
|
||||
"cxa_guard.cpp",
|
||||
"cxa_handlers.cpp",
|
||||
"cxa_unexpected.cpp",
|
||||
"cxa_vector.cpp",
|
||||
"cxa_virtual.cpp",
|
||||
|
||||
# C++ STL files
|
||||
"stdlib_exception.cpp",
|
||||
"stdlib_stdexcept.cpp",
|
||||
"stdlib_typeinfo.cpp",
|
||||
|
||||
# Internal files
|
||||
"abort_message.cpp",
|
||||
"fallback_malloc.cpp",
|
||||
"private_typeinfo.cpp",
|
||||
]
|
||||
if (libcxxabi_enable_new_delete_definitions) {
|
||||
cxxabi_sources += [ "stdlib_new_delete.cpp" ]
|
||||
}
|
||||
if (libcxxabi_enable_exceptions) {
|
||||
cxxabi_sources += [
|
||||
"cxa_exception.cpp",
|
||||
"cxa_personality.cpp",
|
||||
]
|
||||
} else {
|
||||
cxxabi_sources += [
|
||||
# This comment prevents `gn format` from putting the file on the same line
|
||||
# as `sources +=`, for sync_source_lists_from_cmake.py.
|
||||
"cxa_noexception.cpp",
|
||||
]
|
||||
}
|
||||
if (target_os == "linux" || target_os == "fuchsia") {
|
||||
cxxabi_sources += [
|
||||
# This comment prevents `gn format` from putting the file on the same line
|
||||
# as `sources +=`, for sync_source_lists_from_cmake.py.
|
||||
"cxa_thread_atexit.cpp"
|
||||
]
|
||||
}
|
||||
|
||||
config("cxxabi_config") {
|
||||
include_dirs = [
|
||||
"//libcxxabi/include",
|
||||
"//libcxx/include",
|
||||
]
|
||||
cflags_cc = [ "-nostdinc++" ]
|
||||
defines = [ "_LIBCXXABI_BUILDING_LIBRARY" ]
|
||||
if (target_os == "win") {
|
||||
defines += [ "_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (libcxxabi_enable_shared) {
|
||||
shared_library("cxxabi_shared") {
|
||||
output_dir = runtimes_dir
|
||||
output_name = "c++abi"
|
||||
if (target_os == "linux" || target_os == "mac") {
|
||||
cflags = [ "-fPIC" ]
|
||||
ldflags = [ "-nostdlib++" ]
|
||||
libs = [
|
||||
"dl",
|
||||
"pthread",
|
||||
]
|
||||
}
|
||||
sources = cxxabi_sources
|
||||
public = cxxabi_headers
|
||||
deps = [
|
||||
"//compiler-rt/lib/builtins",
|
||||
"//libunwind/src:unwind_shared",
|
||||
]
|
||||
configs += [ ":cxxabi_config" ]
|
||||
configs -= [
|
||||
"//llvm/utils/gn/build:no_exceptions",
|
||||
"//llvm/utils/gn/build:no_rtti",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (libcxxabi_enable_static) {
|
||||
static_library("cxxabi_static") {
|
||||
output_dir = runtimes_dir
|
||||
output_name = "c++abi"
|
||||
complete_static_lib = true
|
||||
configs -= [ "//llvm/utils/gn/build:thin_archive" ]
|
||||
sources = cxxabi_sources
|
||||
public = cxxabi_headers
|
||||
if (libcxxabi_hermetic_static_library) {
|
||||
cflags = [ "-fvisibility=hidden" ]
|
||||
cflags_cc = [ "-fvisibility-global-new-delete-hidden" ]
|
||||
defines = [
|
||||
"_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
|
||||
"_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
|
||||
]
|
||||
}
|
||||
deps = [
|
||||
"//compiler-rt/lib/builtins",
|
||||
"//libunwind/src:unwind_static",
|
||||
]
|
||||
configs += [ ":cxxabi_config" ]
|
||||
configs -= [
|
||||
"//llvm/utils/gn/build:no_exceptions",
|
||||
"//llvm/utils/gn/build:no_rtti",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
group("src") {
|
||||
deps = []
|
||||
if (libcxxabi_enable_shared) {
|
||||
deps += [ ":cxxabi_shared" ]
|
||||
}
|
||||
if (libcxxabi_enable_static) {
|
||||
deps += [ ":cxxabi_static" ]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue