Skip to content

Commit 008c998

Browse files
committed
Add sanitizer ignorelist for cfi
It seems that, at least if LLVM is to be beleived, this failure is due to something in libc++. This change adds an ignorelist that ignores said function.
1 parent 7a4902d commit 008c998

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

cmake/helpers.cmake

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ else()
7979
set(CXX_HAS_CFI_SANITIZE OFF)
8080
endif()
8181

82+
set(CFI_FLAGS "")
83+
if (CFI_HAS_CFI_SANITIZE)
84+
# cfi-icall requires called functions in shared libraries to also be built with cfi-icall, which we can't
85+
# guarantee. -fsanitize=cfi depends on -flto
86+
set(CFI_FLAGS "-flto -fsanitize=cfi -fno-sanitize=cfi-icall -fsanitize-ignorelist=${CMAKE_SOURCE_DIR}/sanitizer-ignorelist.txt")
87+
endif()
88+
8289
function(add_ur_target_compile_options name)
8390
if(NOT MSVC)
8491
target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2)
@@ -95,9 +102,8 @@ function(add_ur_target_compile_options name)
95102
-fPIC
96103
-fstack-protector-strong
97104
-fvisibility=hidden
98-
# cfi-icall requires called functions in shared libraries to also be built with cfi-icall, which we can't
99-
# guarantee. -fsanitize=cfi depends on -flto
100-
$<$<BOOL:${CXX_HAS_CFI_SANITIZE}>:-flto -fsanitize=cfi -fno-sanitize=cfi-icall>
105+
106+
${CFI_FLAGS}
101107
$<$<BOOL:${CXX_HAS_FCF_PROTECTION_FULL}>:-fcf-protection=full>
102108
$<$<BOOL:${CXX_HAS_FSTACK_CLASH_PROTECTION}>:-fstack-clash-protection>
103109

@@ -135,7 +141,7 @@ function(add_ur_target_link_options name)
135141
if(NOT MSVC)
136142
if (NOT APPLE)
137143
target_link_options(${name} PRIVATE
138-
$<$<BOOL:${CXX_HAS_CFI_SANITIZE}>:-flto -fsanitize=cfi -fno-sanitize=cfi-icall>
144+
${CFI_FLAGS}
139145
"LINKER:-z,relro,-z,now,-z,noexecstack"
140146
)
141147
if (UR_DEVELOPER_MODE)

sanitizer-ignorelist.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[cfi-unrelated-cast]
2+
# std::_Sp_counted_ptr_inplace::_Sp_counted_ptr_inplace() (libstdc++).
3+
# This ctor is used by std::make_shared and needs to cast to uninitialized T*
4+
# in order to call std::allocator_traits<T>::construct.
5+
# See: https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/cfi/cfi_ignorelist.txt
6+
fun:_ZNSt23_Sp_counted_ptr_inplace*

test/conformance/exp_command_buffer/exp_command_buffer_adapter_cuda.match

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/conformance/exp_command_buffer/exp_command_buffer_adapter_hip.match

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)