Skip to content

Commit

Permalink
[ubsan] Remove UBSAN_CAN_USE_CXXABI (#121082)
Browse files Browse the repository at this point in the history
It's should be enough to provide weak implementation.

Fixes solaris and android linking after #121006.
  • Loading branch information
vitalybuka authored Dec 25, 2024
1 parent d3846ec commit 1de228f
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 18 deletions.
3 changes: 0 additions & 3 deletions compiler-rt/lib/ubsan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,15 @@ include_directories(..)
set(UBSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
append_list_if(MSVC /Zl UBSAN_CFLAGS)
append_rtti_flag(OFF UBSAN_CFLAGS)
append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_CFLAGS)

# Too many existing bugs, needs cleanup.
append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format UBSAN_CFLAGS)

set(UBSAN_STANDALONE_CFLAGS ${SANITIZER_COMMON_CFLAGS})
append_rtti_flag(OFF UBSAN_STANDALONE_CFLAGS)
append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_STANDALONE_CFLAGS)

set(UBSAN_CXXFLAGS ${SANITIZER_COMMON_CFLAGS})
append_rtti_flag(ON UBSAN_CXXFLAGS)
append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_CXXFLAGS)

# Silence warnings in system headers with MSVC.
if(NOT CLANG_CL)
Expand Down
11 changes: 1 addition & 10 deletions compiler-rt/lib/ubsan/ubsan_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,7 @@ static void handleCFIBadIcall(CFICheckFailData *Data, ValueHandle Function,

namespace __ubsan {

#ifdef UBSAN_CAN_USE_CXXABI

#ifdef _WIN32

extern "C" void __ubsan_handle_cfi_bad_type_default(CFICheckFailData *Data,
ValueHandle Vtable,
bool ValidVtable,
Expand All @@ -911,18 +908,12 @@ extern "C" void __ubsan_handle_cfi_bad_type_default(CFICheckFailData *Data,
}

WIN_WEAK_ALIAS(__ubsan_handle_cfi_bad_type, __ubsan_handle_cfi_bad_type_default)
#else
SANITIZER_WEAK_ATTRIBUTE
#endif
void __ubsan_handle_cfi_bad_type(CFICheckFailData *Data, ValueHandle Vtable,
bool ValidVtable, ReportOptions Opts);

#else
SANITIZER_WEAK_ATTRIBUTE
void __ubsan_handle_cfi_bad_type(CFICheckFailData *Data, ValueHandle Vtable,
bool ValidVtable, ReportOptions Opts) {
Die();
}
#endif

} // namespace __ubsan

Expand Down
2 changes: 0 additions & 2 deletions llvm/utils/gn/secondary/compiler-rt/lib/lsan/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
source_set("common_sources") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
defines = [ "UBSAN_CAN_USE_CXXABI" ]
deps = [
"//compiler-rt/lib/interception:sources",
"//compiler-rt/lib/sanitizer_common:sources",
Expand All @@ -18,7 +17,6 @@ source_set("common_sources") {
source_set("sources") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
defines = [ "UBSAN_CAN_USE_CXXABI" ]
deps = [
"//compiler-rt/lib/interception:sources",
"//compiler-rt/lib/sanitizer_common:sources",
Expand Down
3 changes: 0 additions & 3 deletions llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ gen_version_script("version_script") {
source_set("sources") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
defines = [ "UBSAN_CAN_USE_CXXABI" ]
deps = [
"//compiler-rt/lib/interception:sources",
"//compiler-rt/lib/sanitizer_common:sources",
Expand Down Expand Up @@ -65,7 +64,6 @@ source_set("standalone_sources") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs -= [ "//llvm/utils/gn/build:no_rtti" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
defines = [ "UBSAN_CAN_USE_CXXABI" ]
sources = [
"ubsan_diag_standalone.cpp",
"ubsan_init_standalone.cpp",
Expand All @@ -77,7 +75,6 @@ source_set("cxx_sources") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs -= [ "//llvm/utils/gn/build:no_rtti" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
defines = [ "UBSAN_CAN_USE_CXXABI" ]
sources = [
"ubsan_handlers_cxx.cpp",
"ubsan_handlers_cxx.h",
Expand Down

0 comments on commit 1de228f

Please sign in to comment.