File: BUILD.gn

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (185 lines) | stat: -rw-r--r-- 4,970 bytes parent folder | download | duplicates (4)
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import("//compiler-rt/gen_version_script.gni")
import("//compiler-rt/target.gni")

group("ubsan") {
  deps = [
    ":ubsan_shared",
    ":ubsan_static",
  ]
  if (current_os != "mac") {
    deps += [ ":ubsan_static_cxx" ]
  }
}

gen_version_script("version_script") {
  extra = "ubsan.syms.extra"
  output = "$target_gen_dir/ubsan.vers"
  libs = [
    ":ubsan_static",
    ":ubsan_static_cxx",
  ]
  lib_names = [
    "ubsan_standalone",
    "ubsan_standalone_cxx",
  ]
}

source_set("sources") {
  configs -= [ "//llvm/utils/gn/build:llvm_code" ]
  configs += [ "//llvm/utils/gn/build:crt_code" ]
  defines = [ "UBSAN_CAN_USE_CXXABI" ]
  deps = [
    "//compiler-rt/lib/interception:sources",
    "//compiler-rt/lib/sanitizer_common:sources",
  ]
  sources = [
    "ubsan_diag.cpp",
    "ubsan_diag.h",
    "ubsan_flags.cpp",
    "ubsan_flags.h",
    "ubsan_handlers.cpp",
    "ubsan_handlers.h",
    "ubsan_init.cpp",
    "ubsan_init.h",
    "ubsan_monitor.cpp",
    "ubsan_monitor.h",
    "ubsan_platform.h",
    "ubsan_signals_standalone.h",
    "ubsan_type_hash.h",
    "ubsan_value.cpp",
    "ubsan_value.h",
  ]
}

source_set("weak_interception") {
  configs -= [ "//llvm/utils/gn/build:llvm_code" ]
  configs += [ "//llvm/utils/gn/build:crt_code" ]
  sources = [ "ubsan_win_weak_interception.cpp" ]
  defines = [ "SANITIZER_DYNAMIC" ]
}

source_set("dll_thunk") {
  configs -= [ "//llvm/utils/gn/build:llvm_code" ]
  configs += [ "//llvm/utils/gn/build:crt_code" ]
  sources = [ "ubsan_win_dll_thunk.cpp" ]
  defines = [ "SANITIZER_DLL_THUNK" ]
}

source_set("dynamic_runtime_thunk") {
  configs -= [ "//llvm/utils/gn/build:llvm_code" ]
  configs += [ "//llvm/utils/gn/build:crt_code" ]
  defines = [ "SANITIZER_DYNAMIC_RUNTIME_THUNK" ]
  sources = [ "ubsan_win_dynamic_runtime_thunk.cpp" ]
}

source_set("standalone_sources") {
  configs -= [ "//llvm/utils/gn/build:llvm_code" ]
  configs -= [ "//llvm/utils/gn/build:no_rtti" ]
  configs += [ "//llvm/utils/gn/build:crt_code" ]
  defines = [ "UBSAN_CAN_USE_CXXABI" ]
  sources = [
    "ubsan_diag_standalone.cpp",
    "ubsan_init_standalone.cpp",
    "ubsan_signals_standalone.cpp",
  ]
}

source_set("cxx_sources") {
  configs -= [ "//llvm/utils/gn/build:llvm_code" ]
  configs -= [ "//llvm/utils/gn/build:no_rtti" ]
  configs += [ "//llvm/utils/gn/build:crt_code" ]
  defines = [ "UBSAN_CAN_USE_CXXABI" ]
  sources = [
    "ubsan_handlers_cxx.cpp",
    "ubsan_handlers_cxx.h",
    "ubsan_type_hash.cpp",
    "ubsan_type_hash_itanium.cpp",
    "ubsan_type_hash_win.cpp",
  ]
}

static_library("ubsan_static") {
  output_dir = crt_current_out_dir
  if (current_os == "mac") {
    output_name = "clang_rt.ubsan_osx"
  } else {
    output_name = "clang_rt.ubsan_standalone$crt_current_target_suffix"
  }
  complete_static_lib = true
  configs -= [
    "//llvm/utils/gn/build:llvm_code",
    "//llvm/utils/gn/build:no_rtti",
    "//llvm/utils/gn/build:thin_archive",
  ]
  configs += [ "//llvm/utils/gn/build:crt_code" ]
  sources = [ "ubsan_init_standalone_preinit.cpp" ]
  deps = [
    ":sources",
    ":standalone_sources",
  ]
  if (current_os == "mac") {
    deps += [ ":cxx_sources" ]
  }
}

if (current_os != "mac") {
  static_library("ubsan_static_cxx") {
    output_dir = crt_current_out_dir
    output_name = "clang_rt.ubsan_standalone_cxx$crt_current_target_suffix"
    complete_static_lib = true
    configs -= [
      "//llvm/utils/gn/build:llvm_code",
      "//llvm/utils/gn/build:thin_archive",
    ]
    configs += [ "//llvm/utils/gn/build:crt_code" ]
    deps = [ ":cxx_sources" ]
  }
}

shared_library("ubsan_shared") {
  output_dir = crt_current_out_dir
  if (current_os == "mac") {
    output_name = "clang_rt.ubsan_osx_dynamic"
  } else {
    output_name = "clang_rt.ubsan_standalone$crt_current_target_suffix"
  }
  configs -= [ "//llvm/utils/gn/build:llvm_code" ]
  configs += [ "//llvm/utils/gn/build:crt_code" ]
  if (current_os == "mac") {
    ldflags = [
      "-lc++",
      "-lc++abi",

      # ubsan
      "-Wl,-U,___ubsan_default_options",

      # sanitizer_common
      "-Wl,-U,___sanitizer_free_hook",
      "-Wl,-U,___sanitizer_malloc_hook",
      "-Wl,-U,___sanitizer_report_error_summary",
      "-Wl,-U,___sanitizer_sandbox_on_notify",
      "-Wl,-U,___sanitizer_symbolize_code",
      "-Wl,-U,___sanitizer_symbolize_data",
      "-Wl,-U,___sanitizer_symbolize_demangle",
      "-Wl,-U,___sanitizer_symbolize_flush",
      "-Wl,-U,___sanitizer_symbolize_set_demangle",
      "-Wl,-U,___sanitizer_symbolize_set_inline_frames",

      # FIXME: better
      "-Wl,-install_name,@rpath/libclang_rt.ubsan_osx_dynamic.dylib",
    ]
    # FIXME: -Wl,-rpath
    # FIXME: codesign (??)
  }
  deps = [
    ":cxx_sources",
    ":sources",
    ":standalone_sources",
    ":version_script",
  ]
  if (current_os != "mac" && current_os != "win") {
    inputs = [ "$target_gen_dir/ubsan.vers" ]
    ldflags =
        [ "-Wl,--version-script," + rebase_path(inputs[0], root_build_dir) ]
  }
}