llvm.org GIT mirror llvm / d0fed05
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359805 91177308-0d34-0410-b5e6-96231b3b80d8 Petr Hosek 5 months ago
3 changed file(s) with 151 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1212 if (current_os == "linux") {
1313 deps += [
1414 "//compiler-rt",
15 "//libcxxabi",
1516 "//libunwind",
1617 ]
1718 }
0 group("libcxxabi") {
1 deps = [
2 "//libcxxabi/src(//llvm/utils/gn/build/toolchain:stage2_unix)",
3 ]
4 }
0 import("//clang/runtimes.gni")
1
2 declare_args() {
3 # Use exceptions.
4 libcxxabi_enable_exceptions = true
5
6 # Build libc++abi with definitions for operator new/delete.
7 libcxxabi_enable_new_delete_definitions = true
8
9 # Build libcxxabi as a shared library.
10 libcxxabi_enable_shared = true
11
12 # Build libcxxabi as a static library.
13 libcxxabi_enable_static = true
14
15 # Do not export any symbols from the static library.
16 libcxxabi_hermetic_static_library = true
17 }
18
19 cxxabi_headers = [
20 # This comment prevents `gn format` from putting the file on the same line
21 # as `sources +=`, for sync_source_lists_from_cmake.py.
22 "../include/cxxabi.h",
23 ]
24
25 cxxabi_sources = [
26 # C++ABI files
27 "cxa_aux_runtime.cpp",
28 "cxa_default_handlers.cpp",
29 "cxa_demangle.cpp",
30 "cxa_exception_storage.cpp",
31 "cxa_guard.cpp",
32 "cxa_handlers.cpp",
33 "cxa_unexpected.cpp",
34 "cxa_vector.cpp",
35 "cxa_virtual.cpp",
36
37 # C++ STL files
38 "stdlib_exception.cpp",
39 "stdlib_stdexcept.cpp",
40 "stdlib_typeinfo.cpp",
41
42 # Internal files
43 "abort_message.cpp",
44 "fallback_malloc.cpp",
45 "private_typeinfo.cpp",
46 ]
47 if (libcxxabi_enable_new_delete_definitions) {
48 cxxabi_sources += [ "stdlib_new_delete.cpp" ]
49 }
50 if (libcxxabi_enable_exceptions) {
51 cxxabi_sources += [
52 "cxa_exception.cpp",
53 "cxa_personality.cpp",
54 ]
55 } else {
56 cxxabi_sources += [
57 # This comment prevents `gn format` from putting the file on the same line
58 # as `sources +=`, for sync_source_lists_from_cmake.py.
59 "cxa_noexception.cpp",
60 ]
61 }
62 if (target_os == "linux" || target_os == "fuchsia") {
63 cxxabi_sources += [
64 # This comment prevents `gn format` from putting the file on the same line
65 # as `sources +=`, for sync_source_lists_from_cmake.py.
66 "cxa_thread_atexit.cpp"
67 ]
68 }
69
70 config("cxxabi_config") {
71 include_dirs = [
72 "//libcxxabi/include",
73 "//libcxx/include",
74 ]
75 cflags_cc = [ "-nostdinc++" ]
76 defines = [ "_LIBCXXABI_BUILDING_LIBRARY" ]
77 if (target_os == "win") {
78 defines += [ "_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" ]
79 }
80 }
81
82 if (libcxxabi_enable_shared) {
83 shared_library("cxxabi_shared") {
84 output_dir = runtimes_dir
85 output_name = "c++abi"
86 if (target_os == "linux" || target_os == "mac") {
87 cflags = [ "-fPIC" ]
88 ldflags = [ "-nostdlib++" ]
89 libs = [
90 "dl",
91 "pthread",
92 ]
93 }
94 sources = cxxabi_sources
95 public = cxxabi_headers
96 deps = [
97 "//compiler-rt/lib/builtins",
98 "//libunwind/src:unwind_shared",
99 ]
100 configs += [ ":cxxabi_config" ]
101 configs -= [
102 "//llvm/utils/gn/build:no_exceptions",
103 "//llvm/utils/gn/build:no_rtti",
104 ]
105 }
106 }
107
108 if (libcxxabi_enable_static) {
109 static_library("cxxabi_static") {
110 output_dir = runtimes_dir
111 output_name = "c++abi"
112 complete_static_lib = true
113 configs -= [ "//llvm/utils/gn/build:thin_archive" ]
114 sources = cxxabi_sources
115 public = cxxabi_headers
116 if (libcxxabi_hermetic_static_library) {
117 cflags = [ "-fvisibility=hidden" ]
118 cflags_cc = [ "-fvisibility-global-new-delete-hidden" ]
119 defines = [
120 "_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
121 "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
122 ]
123 }
124 deps = [
125 "//compiler-rt/lib/builtins",
126 "//libunwind/src:unwind_static",
127 ]
128 configs += [ ":cxxabi_config" ]
129 configs -= [
130 "//llvm/utils/gn/build:no_exceptions",
131 "//llvm/utils/gn/build:no_rtti",
132 ]
133 }
134 }
135
136 group("src") {
137 deps = []
138 if (libcxxabi_enable_shared) {
139 deps += [ ":cxxabi_shared" ]
140 }
141 if (libcxxabi_enable_static) {
142 deps += [ ":cxxabi_static" ]
143 }
144 }