1import("//clang/runtimes.gni") 2 3declare_args() { 4 # Use exceptions. 5 libcxxabi_enable_exceptions = true 6 7 # Build libc++abi with definitions for operator new/delete. 8 libcxxabi_enable_new_delete_definitions = true 9 10 # Build libcxxabi as a shared library. 11 libcxxabi_enable_shared = true 12 13 # Build libcxxabi as a static library. 14 libcxxabi_enable_static = true 15 16 # Do not export any symbols from the static library. 17 libcxxabi_hermetic_static_library = true 18} 19 20cxxabi_headers = [ 21 # Make `gn format` not collapse this, for sync_source_lists_from_cmake.py. 22 "../include/cxxabi.h", 23] 24 25cxxabi_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_vector.cpp", 34 "cxa_virtual.cpp", 35 36 # C++ STL files 37 "stdlib_exception.cpp", 38 "stdlib_stdexcept.cpp", 39 "stdlib_typeinfo.cpp", 40 41 # Internal files 42 "abort_message.cpp", 43 "fallback_malloc.cpp", 44 "private_typeinfo.cpp", 45] 46if (libcxxabi_enable_new_delete_definitions) { 47 cxxabi_sources += [ "stdlib_new_delete.cpp" ] 48} 49if (libcxxabi_enable_exceptions) { 50 cxxabi_sources += [ 51 "cxa_exception.cpp", 52 "cxa_personality.cpp", 53 ] 54} else { 55 cxxabi_sources += [ "cxa_noexception.cpp" ] 56} 57if (target_os == "linux" || target_os == "fuchsia") { 58 cxxabi_sources += [ "cxa_thread_atexit.cpp" ] 59} 60 61config("cxxabi_config") { 62 include_dirs = [ 63 "//libcxxabi/include", 64 65 # Some files depend on libc++ internals. 66 "//libcxx/src", 67 ] 68 cflags_cc = [ 69 "-std=c++23", 70 "-nostdinc++", 71 ] 72 defines = [ 73 "_LIBCXXABI_BUILDING_LIBRARY", 74 "_LIBCPP_BUILDING_LIBRARY", 75 ] 76 if (target_os == "win") { 77 defines += [ "_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" ] 78 } 79} 80 81if (libcxxabi_enable_shared) { 82 shared_library("cxxabi_shared") { 83 output_dir = runtimes_dir 84 output_name = "c++abi" 85 if (target_os == "linux" || target_os == "mac") { 86 cflags = [ "-fPIC" ] 87 ldflags = [ "-nostdlib++" ] 88 libs = [ 89 "dl", 90 "pthread", 91 ] 92 } 93 sources = cxxabi_sources 94 public = cxxabi_headers 95 deps = [ 96 "//compiler-rt/lib/builtins", 97 "//libcxx/include", 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 108if (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 if (libcxxabi_enable_new_delete_definitions) { 119 cflags_cc = [ "-fvisibility-global-new-delete=force-hidden" ] 120 } 121 defines = [ 122 "_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS", 123 "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS", 124 ] 125 } 126 deps = [ 127 "//compiler-rt/lib/builtins", 128 "//libcxx/include", 129 "//libunwind/src:unwind_static", 130 ] 131 configs += [ ":cxxabi_config" ] 132 configs -= [ 133 "//llvm/utils/gn/build:no_exceptions", 134 "//llvm/utils/gn/build:no_rtti", 135 ] 136 } 137} 138 139group("src") { 140 deps = [] 141 if (libcxxabi_enable_shared) { 142 deps += [ ":cxxabi_shared" ] 143 } 144 if (libcxxabi_enable_static) { 145 deps += [ ":cxxabi_static" ] 146 } 147} 148