Skip to content

Commit bea2f25

Browse files
authored
[gn build] Port win asan runtime rules (#108293)
Windows doesn't have a static runtime after #107899.
1 parent 6eb3519 commit bea2f25

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

llvm/utils/gn/build/toolchain/target_flags.gni

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ if (current_os == "android") {
5454
target_flags += [ "--target=$llvm_current_triple" ]
5555
}
5656

57-
if (current_cpu == "x86") {
57+
if (current_cpu == "x86" && current_os != "win") {
5858
target_flags += [ "-m32" ]
5959
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ group("lib") {
1010
if (current_os == "linux" || current_os == "android") {
1111
deps += [ "//compiler-rt/lib/ubsan_minimal" ]
1212
}
13-
if (current_os != "win" && current_os != "baremetal") {
13+
if (current_os != "baremetal") {
1414
deps += [
1515
"//compiler-rt/lib/asan",
16-
"//compiler-rt/lib/ubsan",
16+
"//compiler-rt/lib/profile",
1717
]
18+
}
19+
if (current_os != "win" && current_os != "baremetal") {
20+
deps += [ "//compiler-rt/lib/ubsan" ]
1821
if (current_cpu == "x64" || current_cpu == "arm64") {
1922
deps += [ "//compiler-rt/lib/tsan/rtl" ]
2023
}
2124
}
22-
if (current_os != "baremetal") {
23-
deps += [ "//compiler-rt/lib/profile" ]
24-
}
2525
}

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ if (current_toolchain == host_toolchain) {
6060
"asan_thread.h",
6161
"asan_win.cpp",
6262
]
63-
if (target_os != "mac" && target_os != "win") {
63+
if (current_os != "mac" && current_os != "win") {
6464
asan_sources += [ "asan_interceptors_vfork.S" ]
6565
}
6666
config("asan_config") {
6767
cflags = []
68-
if (target_os != "win") {
68+
if (current_os != "win") {
6969
cflags += [ "-ftls-model=initial-exec" ]
7070
} else {
7171
ldflags = [ "/OPT:NOICF" ]
@@ -76,11 +76,11 @@ if (current_toolchain == host_toolchain) {
7676
# FIXME: add_sanitizer_rt_version_list (cf hwasan)
7777
# FIXME: need libclang_rt.asan*.a.syms?
7878

79-
if (target_os == "android") {
79+
if (current_os == "android") {
8080
ldflags = [ "-Wl,-z,global" ]
8181
}
8282

83-
if (target_os == "mac") {
83+
if (current_os == "mac") {
8484
# The -U flags below correspond to the add_weak_symbols() calls in CMake.
8585
ldflags = [
8686
"-lc++",
@@ -145,7 +145,7 @@ if (current_toolchain == host_toolchain) {
145145
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
146146
configs += [ "//llvm/utils/gn/build:crt_code" ]
147147
sources = [ "asan_rtl_static.cpp" ]
148-
if (target_os != "mac" && target_os != "win") {
148+
if (current_os != "mac" && current_os != "win") {
149149
sources += [ "asan_rtl_x86_64.S" ]
150150
}
151151
}
@@ -183,7 +183,7 @@ if (current_toolchain == host_toolchain) {
183183
}
184184
}
185185

186-
if (current_os != "mac") {
186+
if (current_os != "mac" && current_os != "win") {
187187
static_library("asan_static_library") {
188188
output_dir = crt_current_out_dir
189189
output_name = "clang_rt.asan$crt_current_target_suffix"
@@ -232,7 +232,8 @@ if (current_toolchain == host_toolchain) {
232232
if (current_os == "win") {
233233
static_library("asan_static_runtime_thunk") {
234234
output_dir = crt_current_out_dir
235-
output_name = "clang_rt.asan_static_runtime_thunk$crt_current_target_suffix"
235+
output_name =
236+
"clang_rt.asan_static_runtime_thunk$crt_current_target_suffix"
236237
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
237238
configs += [ "//llvm/utils/gn/build:crt_code" ]
238239
complete_static_lib = true
@@ -277,11 +278,11 @@ if (current_toolchain == host_toolchain) {
277278
deps = [ ":asan_shared_library" ]
278279
if (current_os == "win") {
279280
deps += [
280-
":asan_static_runtime_thunk",
281281
":asan_dynamic_runtime_thunk",
282+
":asan_static_runtime_thunk",
282283
]
283284
}
284-
if (current_os != "mac") {
285+
if (current_os != "mac" && current_os != "win") {
285286
deps += [
286287
":asan_cxx",
287288
":asan_preinit",

0 commit comments

Comments
 (0)