Skip to content

Commit 6d17254

Browse files
committed
[gn build] Add ubsan libraries
clang -fsanitize=undefined works with this. Reviewed By: thakis Differential Revision: https://reviews.llvm.org/D131916
1 parent e792a35 commit 6d17254

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ group("lib") {
77
deps += [ "//compiler-rt/lib/msan" ]
88
}
99
if (current_os == "linux" || current_os == "android") {
10-
deps += [ "//compiler-rt/lib/ubsan_minimal" ]
10+
deps += [
11+
"//compiler-rt/lib/ubsan",
12+
"//compiler-rt/lib/ubsan_minimal",
13+
]
1114
}
1215
if (current_os != "win" && current_os != "baremetal") {
1316
deps += [ "//compiler-rt/lib/asan" ]

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

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
import("//compiler-rt/target.gni")
2+
3+
group("ubsan") {
4+
deps = [
5+
":ubsan_standalone",
6+
":ubsan_standalone_cxx",
7+
]
8+
}
9+
110
source_set("sources") {
211
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
312
configs += [ "//llvm/utils/gn/build:crt_code" ]
@@ -46,7 +55,6 @@ source_set("dynamic_runtime_thunk") {
4655
sources = [ "ubsan_win_dynamic_runtime_thunk.cpp" ]
4756
}
4857

49-
# Unreferenced; at the moment exists to make sync_source_lists_from_cmake happy.
5058
source_set("standalone_sources") {
5159
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
5260
configs -= [ "//llvm/utils/gn/build:no_rtti" ]
@@ -57,6 +65,11 @@ source_set("standalone_sources") {
5765
"ubsan_init_standalone.cpp",
5866
"ubsan_signals_standalone.cpp",
5967
]
68+
deps = [
69+
":sources",
70+
"//compiler-rt/lib/interception:sources",
71+
"//compiler-rt/lib/sanitizer_common:sources",
72+
]
6073
}
6174

6275
source_set("cxx_sources") {
@@ -72,3 +85,31 @@ source_set("cxx_sources") {
7285
"ubsan_type_hash_win.cpp",
7386
]
7487
}
88+
89+
static_library("ubsan_standalone") {
90+
output_dir = crt_current_out_dir
91+
output_name = "clang_rt.ubsan_standalone$crt_current_target_suffix"
92+
complete_static_lib = true
93+
configs -= [
94+
"//llvm/utils/gn/build:llvm_code",
95+
"//llvm/utils/gn/build:thin_archive",
96+
]
97+
deps = [
98+
":sources",
99+
":standalone_sources",
100+
]
101+
configs += [ "//llvm/utils/gn/build:crt_code" ]
102+
sources = [ "ubsan_init_standalone_preinit.cpp" ]
103+
}
104+
105+
static_library("ubsan_standalone_cxx") {
106+
output_dir = crt_current_out_dir
107+
output_name = "clang_rt.ubsan_standalone_cxx$crt_current_target_suffix"
108+
complete_static_lib = true
109+
configs -= [
110+
"//llvm/utils/gn/build:llvm_code",
111+
"//llvm/utils/gn/build:thin_archive",
112+
]
113+
deps = [ ":cxx_sources" ]
114+
configs += [ "//llvm/utils/gn/build:crt_code" ]
115+
}

0 commit comments

Comments
 (0)