Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gn build] Port win asan runtime rules #108293

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/utils/gn/build/toolchain/target_flags.gni
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ if (current_os == "android") {
target_flags += [ "--target=$llvm_current_triple" ]
}

if (current_cpu == "x86") {
if (current_cpu == "x86" && current_os != "win") {
target_flags += [ "-m32" ]
}
10 changes: 5 additions & 5 deletions llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ group("lib") {
if (current_os == "linux" || current_os == "android") {
deps += [ "//compiler-rt/lib/ubsan_minimal" ]
}
if (current_os != "win" && current_os != "baremetal") {
if (current_os != "baremetal") {
deps += [
"//compiler-rt/lib/asan",
"//compiler-rt/lib/ubsan",
"//compiler-rt/lib/profile",
]
}
if (current_os != "win" && current_os != "baremetal") {
deps += [ "//compiler-rt/lib/ubsan" ]
if (current_cpu == "x64" || current_cpu == "arm64") {
deps += [ "//compiler-rt/lib/tsan/rtl" ]
}
}
if (current_os != "baremetal") {
deps += [ "//compiler-rt/lib/profile" ]
}
}
19 changes: 10 additions & 9 deletions llvm/utils/gn/secondary/compiler-rt/lib/asan/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ if (current_toolchain == host_toolchain) {
"asan_thread.h",
"asan_win.cpp",
]
if (target_os != "mac" && target_os != "win") {
if (current_os != "mac" && current_os != "win") {
asan_sources += [ "asan_interceptors_vfork.S" ]
}
config("asan_config") {
cflags = []
if (target_os != "win") {
if (current_os != "win") {
cflags += [ "-ftls-model=initial-exec" ]
} else {
ldflags = [ "/OPT:NOICF" ]
Expand All @@ -76,11 +76,11 @@ if (current_toolchain == host_toolchain) {
# FIXME: add_sanitizer_rt_version_list (cf hwasan)
# FIXME: need libclang_rt.asan*.a.syms?

if (target_os == "android") {
if (current_os == "android") {
ldflags = [ "-Wl,-z,global" ]
}

if (target_os == "mac") {
if (current_os == "mac") {
# The -U flags below correspond to the add_weak_symbols() calls in CMake.
ldflags = [
"-lc++",
Expand Down Expand Up @@ -145,7 +145,7 @@ if (current_toolchain == host_toolchain) {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
sources = [ "asan_rtl_static.cpp" ]
if (target_os != "mac" && target_os != "win") {
if (current_os != "mac" && current_os != "win") {
sources += [ "asan_rtl_x86_64.S" ]
}
}
Expand Down Expand Up @@ -183,7 +183,7 @@ if (current_toolchain == host_toolchain) {
}
}

if (current_os != "mac") {
if (current_os != "mac" && current_os != "win") {
static_library("asan_static_library") {
output_dir = crt_current_out_dir
output_name = "clang_rt.asan$crt_current_target_suffix"
Expand Down Expand Up @@ -232,7 +232,8 @@ if (current_toolchain == host_toolchain) {
if (current_os == "win") {
static_library("asan_static_runtime_thunk") {
output_dir = crt_current_out_dir
output_name = "clang_rt.asan_static_runtime_thunk$crt_current_target_suffix"
output_name =
"clang_rt.asan_static_runtime_thunk$crt_current_target_suffix"
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
complete_static_lib = true
Expand Down Expand Up @@ -277,11 +278,11 @@ if (current_toolchain == host_toolchain) {
deps = [ ":asan_shared_library" ]
if (current_os == "win") {
deps += [
":asan_static_runtime_thunk",
":asan_dynamic_runtime_thunk",
":asan_static_runtime_thunk",
]
}
if (current_os != "mac") {
if (current_os != "mac" && current_os != "win") {
deps += [
":asan_cxx",
":asan_preinit",
Expand Down
Loading