Debian Codegraph @

llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn

raw
1 import("//compiler-rt/gen_version_script.gni")
2 import("//compiler-rt/target.gni")
3
4 group("ubsan") {
5 deps = [
6 ":ubsan_shared",
7 ":ubsan_static",
8 ]
9 if (current_os != "mac") {
10 deps += [ ":ubsan_static_cxx" ]
11 }
12 }
13
14 gen_version_script("version_script") {
15 extra = "ubsan.syms.extra"
16 output = "$target_gen_dir/ubsan.vers"
17 libs = [
18 ":ubsan_static",
19 ":ubsan_static_cxx",
20 ]
21 lib_names = [
22 "ubsan_standalone",
23 "ubsan_standalone_cxx",
24 ]
25 }
26
27 source_set("sources") {
28 configs -= [ "//llvm/utils/gn/build:llvm_code" ]
29 configs += [ "//llvm/utils/gn/build:crt_code" ]
30 defines = [ "UBSAN_CAN_USE_CXXABI" ]
31 deps = [
32 "//compiler-rt/lib/interception:sources",
33 "//compiler-rt/lib/sanitizer_common:sources",
34 ]
35 sources = [
36 "ubsan_diag.cpp",
37 "ubsan_diag.h",
38 "ubsan_flags.cpp",
39 "ubsan_flags.h",
40 "ubsan_handlers.cpp",
41 "ubsan_handlers.h",
42 "ubsan_init.cpp",
43 "ubsan_init.h",
44 "ubsan_monitor.cpp",
45 "ubsan_monitor.h",
46 "ubsan_platform.h",
47 "ubsan_signals_standalone.h",
48 "ubsan_type_hash.h",
49 "ubsan_value.cpp",
50 "ubsan_value.h",
51 ]
52 }
53
54 source_set("weak_interception") {
55 configs -= [ "//llvm/utils/gn/build:llvm_code" ]
56 configs += [ "//llvm/utils/gn/build:crt_code" ]
57 sources = [ "ubsan_win_weak_interception.cpp" ]
58 defines = [ "SANITIZER_DYNAMIC" ]
59 }
60
61 source_set("dll_thunk") {
62 configs -= [ "//llvm/utils/gn/build:llvm_code" ]
63 configs += [ "//llvm/utils/gn/build:crt_code" ]
64 sources = [ "ubsan_win_dll_thunk.cpp" ]
65 defines = [ "SANITIZER_DLL_THUNK" ]
66 }
67
68 source_set("dynamic_runtime_thunk") {
69 configs -= [ "//llvm/utils/gn/build:llvm_code" ]
70 configs += [ "//llvm/utils/gn/build:crt_code" ]
71 defines = [ "SANITIZER_DYNAMIC_RUNTIME_THUNK" ]
72 sources = [ "ubsan_win_dynamic_runtime_thunk.cpp" ]
73 }
74
75 source_set("standalone_sources") {
76 configs -= [ "//llvm/utils/gn/build:llvm_code" ]
77 configs -= [ "//llvm/utils/gn/build:no_rtti" ]
78 configs += [ "//llvm/utils/gn/build:crt_code" ]
79 defines = [ "UBSAN_CAN_USE_CXXABI" ]
80 sources = [
81 "ubsan_diag_standalone.cpp",
82 "ubsan_init_standalone.cpp",
83 "ubsan_signals_standalone.cpp",
84 ]
85 }
86
87 source_set("cxx_sources") {
88 configs -= [ "//llvm/utils/gn/build:llvm_code" ]
89 configs -= [ "//llvm/utils/gn/build:no_rtti" ]
90 configs += [ "//llvm/utils/gn/build:crt_code" ]
91 defines = [ "UBSAN_CAN_USE_CXXABI" ]
92 sources = [
93 "ubsan_handlers_cxx.cpp",
94 "ubsan_handlers_cxx.h",
95 "ubsan_type_hash.cpp",
96 "ubsan_type_hash_itanium.cpp",
97 "ubsan_type_hash_win.cpp",
98 ]
99 }
100
101 static_library("ubsan_static") {
102 output_dir = crt_current_out_dir
103 if (current_os == "mac") {
104 output_name = "clang_rt.ubsan_osx"
105 } else {
106 output_name = "clang_rt.ubsan_standalone$crt_current_target_suffix"
107 }
108 complete_static_lib = true
109 configs -= [
110 "//llvm/utils/gn/build:llvm_code",
111 "//llvm/utils/gn/build:no_rtti",
112 "//llvm/utils/gn/build:thin_archive",
113 ]
114 configs += [ "//llvm/utils/gn/build:crt_code" ]
115 sources = [ "ubsan_init_standalone_preinit.cpp" ]
116 deps = [
117 ":sources",
118 ":standalone_sources",
119 ]
120 if (current_os == "mac") {
121 deps += [ ":cxx_sources" ]
122 }
123 }
124
125 if (current_os != "mac") {
126 static_library("ubsan_static_cxx") {
127 output_dir = crt_current_out_dir
128 output_name = "clang_rt.ubsan_standalone_cxx$crt_current_target_suffix"
129 complete_static_lib = true
130 configs -= [
131 "//llvm/utils/gn/build:llvm_code",
132 "//llvm/utils/gn/build:thin_archive",
133 ]
134 configs += [ "//llvm/utils/gn/build:crt_code" ]
135 deps = [ ":cxx_sources" ]
136 }
137 }
138
139 shared_library("ubsan_shared") {
140 output_dir = crt_current_out_dir
141 if (current_os == "mac") {
142 output_name = "clang_rt.ubsan_osx_dynamic"
143 } else {
144 output_name = "clang_rt.ubsan_standalone$crt_current_target_suffix"
145 }
146 configs -= [ "//llvm/utils/gn/build:llvm_code" ]
147 configs += [ "//llvm/utils/gn/build:crt_code" ]
148 if (current_os == "mac") {
149 ldflags = [
150 "-lc++",
151 "-lc++abi",
152
153 # ubsan
154 "-Wl,-U,___ubsan_default_options",
155
156 # sanitizer_common
157 "-Wl,-U,___sanitizer_free_hook",
158 "-Wl,-U,___sanitizer_malloc_hook",
159 "-Wl,-U,___sanitizer_report_error_summary",
160 "-Wl,-U,___sanitizer_sandbox_on_notify",
161 "-Wl,-U,___sanitizer_symbolize_code",
162 "-Wl,-U,___sanitizer_symbolize_data",
163 "-Wl,-U,___sanitizer_symbolize_frame",
164 "-Wl,-U,___sanitizer_symbolize_demangle",
165 "-Wl,-U,___sanitizer_symbolize_flush",
166 "-Wl,-U,___sanitizer_symbolize_set_demangle",
167 "-Wl,-U,___sanitizer_symbolize_set_inline_frames",
168
169 # FIXME: better
170 "-Wl,-install_name,@rpath/libclang_rt.ubsan_osx_dynamic.dylib",
171 ]
172 # FIXME: -Wl,-rpath
173 # FIXME: codesign (??)
174 }
175 deps = [
176 ":cxx_sources",
177 ":sources",
178 ":standalone_sources",
179 ":version_script",
180 ]
181 if (current_os != "mac" && current_os != "win") {
182 inputs = [ "$target_gen_dir/ubsan.vers" ]
183 ldflags =
184 [ "-Wl,--version-script," + rebase_path(inputs[0], root_build_dir) ]
185 }
186 }