Commit 67ff2aad authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

win: Don't build 64->32bit cross BHO dll in asan builds.

We only ship 64-bit asan runtimes on Windows, so we shouldn't try to
build 32-bit binaries in 64-bit asan builds.

Also improve an existing assert so that it catches problems like this
at `gn gen` time in the future, by using current_cpu instead of
target_cpu.

Bug: 1065287
Change-Id: I511e50b9578650f85c0beb236ee1de9af6166fb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2125029
Commit-Queue: Nico Weber <thakis@chromium.org>
Commit-Queue: Nicolas Ouellet-Payeur <nicolaso@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarNicolas Ouellet-Payeur <nicolaso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754160}
parent 3d0c248b
......@@ -53,7 +53,7 @@ group("deps") {
}
}
assert(!(is_win && is_asan && target_cpu == "x86"),
assert(!(is_win && is_asan && current_cpu == "x86"),
"ASan is only supported in 64-bit builds on Windows.")
if ((is_mac || is_win || (is_ios && !use_xcode_clang)) && is_asan) {
......@@ -61,7 +61,7 @@ if ((is_mac || is_win || (is_ios && !use_xcode_clang)) && is_asan) {
_clang_rt_dso_path = "darwin/libclang_rt.asan_osx_dynamic.dylib"
} else if (is_ios) {
_clang_rt_dso_path = "darwin/libclang_rt.asan_iossim_dynamic.dylib"
} else if (is_win && target_cpu == "x64") {
} else if (is_win && current_cpu == "x64") {
_clang_rt_dso_path = "windows/clang_rt.asan_dynamic-x86_64.dll"
}
......@@ -222,14 +222,14 @@ config("default_sanitizer_ldflags") {
# In the static-library build, ASan libraries are different for
# executables and dlls, see link_executable and link_shared_library below.
# This here handles only the component build.
if (target_cpu == "x64") {
if (current_cpu == "x64") {
# Windows 64-bit.
libs = [
"clang_rt.asan_dynamic-x86_64.lib",
"clang_rt.asan_dynamic_runtime_thunk-x86_64.lib",
]
} else {
assert(target_cpu == "x86", "WinASan unsupported architecture")
assert(current_cpu == "x86", "WinASan unsupported architecture")
libs = [
"clang_rt.asan_dynamic-i386.lib",
"clang_rt.asan_dynamic_runtime_thunk-i386.lib",
......@@ -237,7 +237,7 @@ config("default_sanitizer_ldflags") {
}
}
if (use_libfuzzer) {
assert(target_cpu == "x64", "LibFuzzer unsupported architecture")
assert(current_cpu == "x64", "LibFuzzer unsupported architecture")
assert(!is_component_build,
"LibFuzzer only supports non-component builds on Windows")
......@@ -308,10 +308,10 @@ config("asan_flags") {
config("link_executable") {
if (is_asan && is_win && !is_component_build) {
if (target_cpu == "x64") {
if (current_cpu == "x64") {
ldflags = [ "-wholearchive:clang_rt.asan-x86_64.lib" ]
} else {
assert(target_cpu == "x86", "WinASan unsupported architecture")
assert(current_cpu == "x86", "WinASan unsupported architecture")
ldflags = [ "-wholearchive:clang_rt.asan-i386.lib" ]
}
}
......@@ -319,10 +319,10 @@ config("link_executable") {
config("link_shared_library") {
if (is_asan && is_win && !is_component_build) {
if (target_cpu == "x64") {
if (current_cpu == "x64") {
libs = [ "clang_rt.asan_dll_thunk-x86_64.lib" ]
} else {
assert(target_cpu == "x86", "WinASan unsupported architecture")
assert(current_cpu == "x86", "WinASan unsupported architecture")
libs = [ "clang_rt.asan_dll_thunk-i386.lib" ]
}
}
......
......@@ -86,50 +86,49 @@ test("browser_switcher_bho_unittests") {
]
}
if (is_clang) {
browser_switcher_x64_toolchain = "//build/toolchain/win:win_clang_x64"
browser_switcher_x86_toolchain = "//build/toolchain/win:win_clang_x86"
} else {
browser_switcher_x64_toolchain = "//build/toolchain/win:x64"
browser_switcher_x86_toolchain = "//build/toolchain/win:x86"
}
assert(is_clang)
browser_switcher_x64_label =
":browser_switcher_bho($browser_switcher_x64_toolchain)"
browser_switcher_x86_label =
":browser_switcher_bho($browser_switcher_x86_toolchain)"
copy("copy_browser_switcher_binaries") {
# Make sure we have both bitnesses in the root out directory.
if (target_cpu == "x86") {
cross_build_label = browser_switcher_x64_label
cross_build_dll = "browser_switcher_bho_64.dll"
} else if (target_cpu == "x64") {
cross_build_label = browser_switcher_x86_label
cross_build_dll = "browser_switcher_bho.dll"
}
cross_build_out_dir = get_label_info(cross_build_label, "root_out_dir")
sources = [ "$cross_build_out_dir/$cross_build_dll" ]
if (symbol_level > 0) {
sources += [ "$cross_build_out_dir/$cross_build_dll.pdb" ]
":browser_switcher_bho(//build/toolchain/win:win_clang_x64)"
if (!is_asan) {
browser_switcher_x86_label =
":browser_switcher_bho(//build/toolchain/win:win_clang_x86)"
copy("copy_browser_switcher_binaries") {
# Make sure we have both bitnesses in the root out directory.
if (target_cpu == "x86") {
cross_build_label = browser_switcher_x64_label
cross_build_dll = "browser_switcher_bho_64.dll"
} else if (target_cpu == "x64") {
cross_build_label = browser_switcher_x86_label
cross_build_dll = "browser_switcher_bho.dll"
}
cross_build_out_dir = get_label_info(cross_build_label, "root_out_dir")
sources = [ "$cross_build_out_dir/$cross_build_dll" ]
if (symbol_level > 0) {
sources += [ "$cross_build_out_dir/$cross_build_dll.pdb" ]
}
outputs = [ "$root_out_dir/{{source_file_part}}" ]
deps = [
browser_switcher_x64_label,
browser_switcher_x86_label,
]
}
outputs = [ "$root_out_dir/{{source_file_part}}" ]
deps = [
browser_switcher_x64_label,
browser_switcher_x86_label,
]
}
group("browser_switcher_dlls") {
# Build a DLL for each bitness, and put them in the root out dir.
deps = [
":copy_browser_switcher_binaries",
browser_switcher_x64_label,
browser_switcher_x86_label,
]
# Asan builds only support 64-bit builds, so don't do this there.
deps = [ browser_switcher_x64_label ]
if (!is_asan) {
deps += [
":copy_browser_switcher_binaries",
browser_switcher_x86_label,
]
}
}
midl("ie_bho_idl") {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment