aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/gn/secondary/libcxxabi/src/BUILD.gn
blob: c82634e2bb06485398cb90b4349d7918830774d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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 = [
  # Make `gn format` not collapse this, 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_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 += [ "cxa_noexception.cpp" ]
}
if (target_os == "linux" || target_os == "fuchsia") {
  cxxabi_sources += [ "cxa_thread_atexit.cpp" ]
}

config("cxxabi_config") {
  include_dirs = [
    "//libcxxabi/include",

    # Some files depend on libc++ internals.
    "//libcxx/src",
  ]
  cflags_cc = [
    "-std=c++20",
    "-nostdinc++",
  ]
  defines = [
    "_LIBCXXABI_BUILDING_LIBRARY",
    "_LIBCPP_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",
      "//libcxx/include",
      "//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" ]
      if (libcxxabi_enable_new_delete_definitions) {
        cflags_cc = [ "-fvisibility-global-new-delete-hidden" ]
      }
      defines = [
        "_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
        "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
      ]
    }
    deps = [
      "//compiler-rt/lib/builtins",
      "//libcxx/include",
      "//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" ]
  }
}