Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7bb5e4c

Browse files
rmacnak-googleCommit Queue
authored and
Commit Queue
committed
[build] Fix Windows ASAN build to actually use ASAN.
Bug:#62263Change-Id: I77a44aeff0a0685730ff3e5c897e338ddc5561a7Reviewed-on:https://dart-review.googlesource.com/c/sdk/+/464781Commit-Queue: Ryan Macnak <rmacnak@google.com>Reviewed-by: Alexander Aprelev <aam@google.com>
1 parentcb938a4 commit7bb5e4c

File tree

6 files changed

+53
-15
lines changed

6 files changed

+53
-15
lines changed

‎build/config/BUILDCONFIG.gn‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,12 @@ foreach(_target_type,
525525
]
526526
}
527527
}
528+
if (is_win&&is_asan) {
529+
if (!defined(data_deps)) {
530+
data_deps= []
531+
}
532+
data_deps+= ["//build/config/compiler:copy_sanitizer_runtime" ]
533+
}
528534
}
529535
}
530536
}else {

‎build/config/compiler/BUILD.gn‎

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ config("default_include_dirs") {
3838
]
3939
}
4040

41+
if (is_win&&is_asan) {
42+
copy("copy_sanitizer_runtime") {
43+
sources= ["//buildtools/win-x64/clang/lib/clang/22/lib/x86_64-pc-windows-msvc/clang_rt.asan_dynamic.dll" ]
44+
outputs= ["$root_out_dir/{{source_file_part}}" ]
45+
}
46+
}
47+
4148
# compiler ---------------------------------------------------------------------
4249
#
4350
# Base compiler configuration.
@@ -107,11 +114,38 @@ config("compiler") {
107114
ldflags+= ["-Wl,--fix-cortex-a53-843419" ]
108115
}
109116

110-
# Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and
111-
# MemorySanitizer
117+
if (use_custom_libcxx) {
118+
cflags_cc+= ["-nostdinc++" ]
119+
include_dirs= [
120+
"//buildtools/third_party/libc++/trunk/include",
121+
"//buildtools/third_party/libc++abi/trunk/include",
122+
]
123+
}
124+
}
125+
126+
# Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and
127+
# MemorySanitizer
128+
if (is_clang||!is_win) {
112129
if (is_asan) {
113130
cflags+= ["-fsanitize=address" ]
114-
ldflags+= ["-fsanitize=address" ]
131+
if (is_win) {
132+
# Windows directly calls link.exe instead of the compiler driver when
133+
# linking. Hence, pass the runtime libraries instead of -fsanitize=address
134+
# or -fsanitize=fuzzer.
135+
_clang_lib_dir=
136+
"//buildtools/win-x64/clang/lib/clang/22/lib/x86_64-pc-windows-msvc"
137+
libs= ["$_clang_lib_dir/clang_rt.asan_dynamic.lib" ]
138+
ldflags+= ["-libpath:"+rebase_path("$_clang_lib_dir") ]
139+
if (is_shared_library) {
140+
ldflags+= ["-wholearchive:clang_rt.asan_dynamic_runtime_thunk.lib" ]
141+
libs+= ["$_clang_lib_dir/clang_rt.asan_dynamic_runtime_thunk.lib" ]
142+
}else {
143+
ldflags+= ["-wholearchive:clang_rt.asan_static_runtime_thunk.lib" ]
144+
libs+= ["$_clang_lib_dir/clang_rt.asan_static_runtime_thunk.lib" ]
145+
}
146+
}else {
147+
ldflags+= ["-fsanitize=address" ]
148+
}
115149
}
116150
if (is_hwasan&&is_android&&current_cpu=="arm64") {
117151
cflags+= ["-fsanitize=hwaddress" ]
@@ -156,14 +190,6 @@ config("compiler") {
156190
"@loader_path/../../../../buildtools/mac-$host_cpu/clang/lib/clang/22/lib/darwin",
157191
]
158192
}
159-
160-
if (use_custom_libcxx) {
161-
cflags_cc+= ["-nostdinc++" ]
162-
include_dirs= [
163-
"//buildtools/third_party/libc++/trunk/include",
164-
"//buildtools/third_party/libc++abi/trunk/include",
165-
]
166-
}
167193
}
168194

169195
if (is_clang&&is_debug) {
@@ -814,6 +840,12 @@ if (is_win) {
814840
# Warning: This changes C/C++ semantics of function pointer comparison.
815841
"/OPT:ICF",
816842
]
843+
if (is_clang) {
844+
common_optimize_on_ldflags+= [
845+
# This interferes with ODR violation checks in ASAN.
846+
"/OPT:NOLLDTAILMERGE",
847+
]
848+
}
817849
}else {
818850
common_optimize_on_cflags= [
819851
# Don't emit the GCC version ident directives, they just end up in the

‎runtime/BUILD.gn‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ config("dart_precompiler_config") {
112112

113113
# In our GN build rules we'll always compile AOT compiler & AOT runtime in
114114
# the same mode (TSAN or non-TSAN).
115-
if (is_asan&&!is_win) {
115+
if (is_asan) {
116116
defines+= ["TARGET_USES_ADDRESS_SANITIZER" ]
117117
}elseif (is_msan) {
118118
defines+= ["TARGET_USES_MEMORY_SANITIZER" ]

‎runtime/tests/vm/dart/asan/read_test.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ main(List<String> arguments) {
5959
Expect.contains("READ of size 8", result.stderr);//# uint64: ok
6060
Expect.contains("READ of size 4", result.stderr);//# float32: ok
6161
Expect.contains("READ of size 8", result.stderr);//# float64: ok
62-
if (Platform.executable.contains("aotruntime")) {
62+
if (Platform.executable.contains("aotruntime")&&!Platform.isWindows) {
6363
Expect.contains("expectedFunction", result.stderr);
6464
}
6565
}

‎runtime/tests/vm/dart/asan/write_test.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ main(List<String> arguments) {
5959
Expect.contains("WRITE of size 8", result.stderr);//# uint64: ok
6060
Expect.contains("WRITE of size 4", result.stderr);//# float32: ok
6161
Expect.contains("WRITE of size 8", result.stderr);//# float64: ok
62-
if (Platform.executable.contains("aotruntime")) {
62+
if (Platform.executable.contains("aotruntime")&&!Platform.isWindows) {
6363
Expect.contains("expectedFunction", result.stderr);
6464
}
6565
}

‎runtime/tests/vm/dart/msan/read_test.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ main(List<String> arguments) {
5959
Expect.contains(", 8)", result.stderr);//# uint64: ok
6060
Expect.contains(", 4)", result.stderr);//# float32: ok
6161
Expect.contains(", 8)", result.stderr);//# float64: ok
62-
if (Platform.executable.contains("aotruntime")) {
62+
if (Platform.executable.contains("aotruntime")&&!Platform.isWindows) {
6363
Expect.contains("expectedFunction", result.stderr);
6464
}
6565
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp