0

Reenable the libc++ nondebug assertion handler on Windows

The clang roll https://crrev.com/c/3889980 includes the lld patch
https://reviews.llvm.org/D133165. With this patch, lld now supports weak
symbols in LLVM bitcode input files when outputting COFF files. This
allows us to use the nondebug assertion handler when building Windows
with ThinLTO enabled.

Cq-Include-Trybots: chromium/try:dawn-win10-x86-deps-rel
Cq-Include-Trybots: chromium/try:win7-rel
Cq-Include-Trybots: chromium/try:win-official,win32-official
Cq-Include-Trybots: chromium/try:win-swangle-try-x86
Cq-Include-Trybots: chrome/try:win-chrome,win64-chrome
Cq-Include-Trybots: chrome/try:win32-pgo,win64-pgo
Bug: 1335422
Change-Id: I139f62c83acec3778628884d135f572e4c4f5ef4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3894313
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Alan Zhao <ayzhao@google.com>
Reviewed-by: Hans Wennborg <hans@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1047103}
This commit is contained in:
Alan Zhao
2022-09-14 21:09:33 +00:00
committed by Chromium LUCI CQ
parent 7806bb4f76
commit 218f8ad243
4 changed files with 9 additions and 14 deletions

@ -1550,9 +1550,7 @@ mixed_component("base") {
# Windows cannot use the nodebug assertion handler because it doesn't support
# weak symbols, which are required to override the default libc++
# implementation.
# TODO(crbug.com/1335422): Make the non-debug assertion handler work on
# Windows.
if (use_custom_libcxx && !is_debug && !is_win) {
if (use_custom_libcxx && !is_debug) {
public_deps += [ ":nodebug_assertion" ]
}
@ -2703,7 +2701,7 @@ static_library("base_static") {
}
}
if (use_custom_libcxx && !is_debug && !is_win) {
if (use_custom_libcxx && !is_debug) {
# nodebug_assertion.cc has to be in its own source_set instead of being
# included as a source in //base as otherwise its symbols won't be linked in
# if they end up in an archive.

@ -34,10 +34,7 @@ using ::testing::Not;
// presence or absence of the above string.
TEST(LibcppHardeningTest, Assertions) {
std::vector<int> vec = {0, 1, 2};
// Windows uses the default handler even for non-debug builds as it lacks
// support for weak symbols, which are required to override the default
// assertion handler.
#if defined NDEBUG && !BUILDFLAG(IS_WIN)
#ifdef NDEBUG
// We have to explicitly check for the GTEST_HAS_DEATH_TEST macro instead of
// using EXPECT_DEATH_IF_SUPPORTED(...) for the following reasons:
//
@ -54,10 +51,10 @@ TEST(LibcppHardeningTest, Assertions) {
EXPECT_DEATH(vec[3], Not(ContainsRegex(".*assertion.*failed:")));
#else
GTEST_UNSUPPORTED_DEATH_TEST(vec[3], "", );
#endif // GTEST_HAS_DEATH_TEST
#endif // GTEST_HAS_DEATH_TEST && !GTEST_OS_LINUX_ANDROID
#else
EXPECT_DEATH_IF_SUPPORTED(vec[3], ".*assertion.*failed:");
#endif // defined NDEBUG && !BUILDFLAG(IS_WIN)
#endif // ifdef NDEBUG
}
} // namespace

@ -3,7 +3,6 @@
// found in the LICENSE file.
#include <__config>
#include <__verbose_abort>
#include "base/base_export.h"
#include "base/immediate_crash.h"

@ -209,8 +209,9 @@ target(_libcxx_target_type, "libc++") {
if (!export_libcxxabi_from_executables) {
deps = [ "//buildtools/third_party/libc++abi" ]
}
if (!is_debug) {
defines += [ "_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1" ]
}
}
if (!is_debug) {
defines += [ "_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1" ]
}
}