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 deps = [
31 "//compiler-rt/lib/interception:sources",
32 "//compiler-rt/lib/sanitizer_common:sources",
33 ]
34 sources = [
35 "ubsan_diag.cpp",
36 "ubsan_diag.h",
37 "ubsan_flags.cpp",
38 "ubsan_flags.h",
39 "ubsan_handlers.cpp",
40 "ubsan_handlers.h",
41 "ubsan_init.cpp",
42 "ubsan_init.h",
43 "ubsan_monitor.cpp",
44 "ubsan_monitor.h",
45 "ubsan_platform.h",
46 "ubsan_signals_standalone.h",
47 "ubsan_type_hash.h",
48 "ubsan_value.cpp",
49 "ubsan_value.h",
50 ]
51 }
52
53 source_set("runtime_thunk") {
54 configs -= [ "//llvm/utils/gn/build:llvm_code" ]
55 configs += [ "//llvm/utils/gn/build:crt_code" ]
56 sources = [ "ubsan_win_runtime_thunk.cpp" ]
57 defines = [
58 "SANITIZER_DYNAMIC_RUNTIME_THUNK",
59 "SANITIZER_STATIC_RUNTIME_THUNK",
60 ]
61 }
62
63 source_set("standalone_sources") {
64 configs -= [ "//llvm/utils/gn/build:llvm_code" ]
65 configs -= [ "//llvm/utils/gn/build:no_rtti" ]
66 configs += [ "//llvm/utils/gn/build:crt_code" ]
67 sources = [
68 "ubsan_diag_standalone.cpp",
69 "ubsan_init_standalone.cpp",
70 "ubsan_signals_standalone.cpp",
71 ]
72 }
73
74 source_set("cxx_sources") {
75 configs -= [ "//llvm/utils/gn/build:llvm_code" ]
76 configs -= [ "//llvm/utils/gn/build:no_rtti" ]
77 configs += [ "//llvm/utils/gn/build:crt_code" ]
78 sources = [
79 "ubsan_handlers_cxx.cpp",
80 "ubsan_handlers_cxx.h",
81 "ubsan_type_hash.cpp",
82 "ubsan_type_hash_itanium.cpp",
83 "ubsan_type_hash_win.cpp",
84 ]
85 }
86
87 static_library("ubsan_static") {
88 output_dir = crt_current_out_dir
89 if (current_os == "mac") {
90 output_name = "clang_rt.ubsan_osx"
91 } else {
92 output_name = "clang_rt.ubsan_standalone$crt_current_target_suffix"
93 }
94 complete_static_lib = true
95 configs -= [
96 "//llvm/utils/gn/build:llvm_code",
97 "//llvm/utils/gn/build:no_rtti",
98 "//llvm/utils/gn/build:thin_archive",
99 ]
100 configs += [ "//llvm/utils/gn/build:crt_code" ]
101 sources = [ "ubsan_init_standalone_preinit.cpp" ]
102 deps = [
103 ":sources",
104 ":standalone_sources",
105 ]
106 if (current_os == "mac") {
107 deps += [ ":cxx_sources" ]
108 }
109 }
110
111 if (current_os != "mac") {
112 static_library("ubsan_static_cxx") {
113 output_dir = crt_current_out_dir
114 output_name = "clang_rt.ubsan_standalone_cxx$crt_current_target_suffix"
115 complete_static_lib = true
116 configs -= [
117 "//llvm/utils/gn/build:llvm_code",
118 "//llvm/utils/gn/build:thin_archive",
119 ]
120 configs += [ "//llvm/utils/gn/build:crt_code" ]
121 deps = [ ":cxx_sources" ]
122 }
123 }
124
125 shared_library("ubsan_shared") {
126 output_dir = crt_current_out_dir
127 if (current_os == "mac") {
128 output_name = "clang_rt.ubsan_osx_dynamic"
129 } else {
130 output_name = "clang_rt.ubsan_standalone$crt_current_target_suffix"
131 }
132 configs -= [ "//llvm/utils/gn/build:llvm_code" ]
133 configs += [ "//llvm/utils/gn/build:crt_code" ]
134 if (current_os == "mac") {
135 ldflags = [
136 "-lc++",
137 "-lc++abi",
138
139 # ubsan
140 "-Wl,-U,___ubsan_default_options",
141
142 # sanitizer_common
143 "-Wl,-U,___sanitizer_free_hook",
144 "-Wl,-U,___sanitizer_malloc_hook",
145 "-Wl,-U,___sanitizer_report_error_summary",
146 "-Wl,-U,___sanitizer_sandbox_on_notify",
147 "-Wl,-U,___sanitizer_symbolize_code",
148 "-Wl,-U,___sanitizer_symbolize_data",
149 "-Wl,-U,___sanitizer_symbolize_frame",
150 "-Wl,-U,___sanitizer_symbolize_demangle",
151 "-Wl,-U,___sanitizer_symbolize_flush",
152 "-Wl,-U,___sanitizer_symbolize_set_demangle",
153 "-Wl,-U,___sanitizer_symbolize_set_inline_frames",
154
155 # FIXME: better
156 "-Wl,-install_name,@rpath/libclang_rt.ubsan_osx_dynamic.dylib",
157 ]
158 # FIXME: -Wl,-rpath
159 # FIXME: codesign (??)
160 }
161 deps = [
162 ":cxx_sources",
163 ":sources",
164 ":standalone_sources",
165 ":version_script",
166 ]
167 if (current_os != "mac" && current_os != "win") {
168 inputs = [ "$target_gen_dir/ubsan.vers" ]
169 ldflags =
170 [ "-Wl,--version-script," + rebase_path(inputs[0], root_build_dir) ]
171 }
172 }