[llvm] [gn build] Port win asan runtime rules (PR #108293)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 11 14:09:20 PDT 2024
https://github.com/aeubanks created https://github.com/llvm/llvm-project/pull/108293
Windows doesn't have a static runtime after #107899.
>From 52faafe5716c3a8b972ba8a5bd0c35ecea90206c Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Wed, 11 Sep 2024 21:07:05 +0000
Subject: [PATCH] [gn build] Port win asan runtime rules
Windows doesn't have a static runtime after #107899.
---
.../utils/gn/build/toolchain/target_flags.gni | 2 +-
.../gn/secondary/compiler-rt/lib/BUILD.gn | 10 +++++-----
.../secondary/compiler-rt/lib/asan/BUILD.gn | 19 ++++++++++---------
3 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/llvm/utils/gn/build/toolchain/target_flags.gni b/llvm/utils/gn/build/toolchain/target_flags.gni
index af8adcd2738668..cbfa22966b48f4 100644
--- a/llvm/utils/gn/build/toolchain/target_flags.gni
+++ b/llvm/utils/gn/build/toolchain/target_flags.gni
@@ -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" ]
}
diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
index d8c75a01c6945e..02c20483b7a8bd 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
@@ -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" ]
- }
}
diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/asan/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/asan/BUILD.gn
index cf308753f0c825..42467c21aa24c7 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/asan/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/asan/BUILD.gn
@@ -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" ]
@@ -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++",
@@ -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" ]
}
}
@@ -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"
@@ -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
@@ -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",
More information about the llvm-commits
mailing list