[build] Fix Windows ASAN build to actually use ASAN.
Bug: https://github.com/dart-lang/sdk/issues/62263 Change-Id: I77a44aeff0a0685730ff3e5c897e338ddc5561a7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464781 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
committed by
Commit Queue
parent
cb938a46ae
commit
7bb5e4c192
@@ -525,6 +525,12 @@ foreach(_target_type,
|
||||
]
|
||||
}
|
||||
}
|
||||
if (is_win && is_asan) {
|
||||
if (!defined(data_deps)) {
|
||||
data_deps = []
|
||||
}
|
||||
data_deps += [ "//build/config/compiler:copy_sanitizer_runtime" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -38,6 +38,13 @@ config("default_include_dirs") {
|
||||
]
|
||||
}
|
||||
|
||||
if (is_win && is_asan) {
|
||||
copy("copy_sanitizer_runtime") {
|
||||
sources = [ "//buildtools/win-x64/clang/lib/clang/22/lib/x86_64-pc-windows-msvc/clang_rt.asan_dynamic.dll" ]
|
||||
outputs = [ "$root_out_dir/{{source_file_part}}" ]
|
||||
}
|
||||
}
|
||||
|
||||
# compiler ---------------------------------------------------------------------
|
||||
#
|
||||
# Base compiler configuration.
|
||||
@@ -107,11 +114,38 @@ config("compiler") {
|
||||
ldflags += [ "-Wl,--fix-cortex-a53-843419" ]
|
||||
}
|
||||
|
||||
# Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and
|
||||
# MemorySanitizer
|
||||
if (use_custom_libcxx) {
|
||||
cflags_cc += [ "-nostdinc++" ]
|
||||
include_dirs = [
|
||||
"//buildtools/third_party/libc++/trunk/include",
|
||||
"//buildtools/third_party/libc++abi/trunk/include",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
# Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and
|
||||
# MemorySanitizer
|
||||
if (is_clang || !is_win) {
|
||||
if (is_asan) {
|
||||
cflags += [ "-fsanitize=address" ]
|
||||
ldflags += [ "-fsanitize=address" ]
|
||||
if (is_win) {
|
||||
# Windows directly calls link.exe instead of the compiler driver when
|
||||
# linking. Hence, pass the runtime libraries instead of -fsanitize=address
|
||||
# or -fsanitize=fuzzer.
|
||||
_clang_lib_dir =
|
||||
"//buildtools/win-x64/clang/lib/clang/22/lib/x86_64-pc-windows-msvc"
|
||||
libs = [ "$_clang_lib_dir/clang_rt.asan_dynamic.lib" ]
|
||||
ldflags += [ "-libpath:" + rebase_path("$_clang_lib_dir") ]
|
||||
if (is_shared_library) {
|
||||
ldflags += [ "-wholearchive:clang_rt.asan_dynamic_runtime_thunk.lib" ]
|
||||
libs += [ "$_clang_lib_dir/clang_rt.asan_dynamic_runtime_thunk.lib" ]
|
||||
} else {
|
||||
ldflags += [ "-wholearchive:clang_rt.asan_static_runtime_thunk.lib" ]
|
||||
libs += [ "$_clang_lib_dir/clang_rt.asan_static_runtime_thunk.lib" ]
|
||||
}
|
||||
} else {
|
||||
ldflags += [ "-fsanitize=address" ]
|
||||
}
|
||||
}
|
||||
if (is_hwasan && is_android && current_cpu == "arm64") {
|
||||
cflags += [ "-fsanitize=hwaddress" ]
|
||||
@@ -156,14 +190,6 @@ config("compiler") {
|
||||
"@loader_path/../../../../buildtools/mac-$host_cpu/clang/lib/clang/22/lib/darwin",
|
||||
]
|
||||
}
|
||||
|
||||
if (use_custom_libcxx) {
|
||||
cflags_cc += [ "-nostdinc++" ]
|
||||
include_dirs = [
|
||||
"//buildtools/third_party/libc++/trunk/include",
|
||||
"//buildtools/third_party/libc++abi/trunk/include",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (is_clang && is_debug) {
|
||||
@@ -814,6 +840,12 @@ if (is_win) {
|
||||
# Warning: This changes C/C++ semantics of function pointer comparison.
|
||||
"/OPT:ICF",
|
||||
]
|
||||
if (is_clang) {
|
||||
common_optimize_on_ldflags += [
|
||||
# This interferes with ODR violation checks in ASAN.
|
||||
"/OPT:NOLLDTAILMERGE",
|
||||
]
|
||||
}
|
||||
} else {
|
||||
common_optimize_on_cflags = [
|
||||
# Don't emit the GCC version ident directives, they just end up in the
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ config("dart_precompiler_config") {
|
||||
|
||||
# In our GN build rules we'll always compile AOT compiler & AOT runtime in
|
||||
# the same mode (TSAN or non-TSAN).
|
||||
if (is_asan && !is_win) {
|
||||
if (is_asan) {
|
||||
defines += [ "TARGET_USES_ADDRESS_SANITIZER" ]
|
||||
} else if (is_msan) {
|
||||
defines += [ "TARGET_USES_MEMORY_SANITIZER" ]
|
||||
|
||||
@@ -59,7 +59,7 @@ main(List<String> arguments) {
|
||||
Expect.contains("READ of size 8", result.stderr); //# uint64: ok
|
||||
Expect.contains("READ of size 4", result.stderr); //# float32: ok
|
||||
Expect.contains("READ of size 8", result.stderr); //# float64: ok
|
||||
if (Platform.executable.contains("aotruntime")) {
|
||||
if (Platform.executable.contains("aotruntime") && !Platform.isWindows) {
|
||||
Expect.contains("expectedFunction", result.stderr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ main(List<String> arguments) {
|
||||
Expect.contains("WRITE of size 8", result.stderr); //# uint64: ok
|
||||
Expect.contains("WRITE of size 4", result.stderr); //# float32: ok
|
||||
Expect.contains("WRITE of size 8", result.stderr); //# float64: ok
|
||||
if (Platform.executable.contains("aotruntime")) {
|
||||
if (Platform.executable.contains("aotruntime") && !Platform.isWindows) {
|
||||
Expect.contains("expectedFunction", result.stderr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ main(List<String> arguments) {
|
||||
Expect.contains(", 8)", result.stderr); //# uint64: ok
|
||||
Expect.contains(", 4)", result.stderr); //# float32: ok
|
||||
Expect.contains(", 8)", result.stderr); //# float64: ok
|
||||
if (Platform.executable.contains("aotruntime")) {
|
||||
if (Platform.executable.contains("aotruntime") && !Platform.isWindows) {
|
||||
Expect.contains("expectedFunction", result.stderr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user