Skip to content

[UR] Fix typo in cfi flags handling. #17452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions unified-runtime/cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ else()
endif()

set(CFI_FLAGS "")
if (CFI_HAS_CFI_SANITIZE)
if (CXX_HAS_CFI_SANITIZE)
# cfi-icall requires called functions in shared libraries to also be built with cfi-icall, which we can't
# guarantee. -fsanitize=cfi depends on -flto
set(CFI_FLAGS "-flto -fsanitize=cfi -fno-sanitize=cfi-icall -fsanitize-ignorelist=${PROJECT_SOURCE_DIR}/sanitizer-ignorelist.txt")
Expand All @@ -103,14 +103,17 @@ function(add_ur_target_compile_options name)
-fstack-protector-strong
-fvisibility=hidden

${CFI_FLAGS}
$<$<BOOL:${CXX_HAS_FCF_PROTECTION_FULL}>:-fcf-protection=full>
$<$<BOOL:${CXX_HAS_FSTACK_CLASH_PROTECTION}>:-fstack-clash-protection>

# Colored output
$<$<CXX_COMPILER_ID:GNU>:-fdiagnostics-color=always>
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-fcolor-diagnostics>
)
# Cmake can't handle mixing strings without quotes as the options above
# are and strings with quotes like ${CFI_FLAGS} is, so this needs a
# separate call.
target_compile_options(${name} PRIVATE ${CFI_FLAGS})
if (UR_DEVELOPER_MODE)
target_compile_options(${name} PRIVATE -Werror -Wextra)
endif()
Expand Down Expand Up @@ -151,8 +154,7 @@ function(add_ur_target_link_options name)
if(NOT MSVC)
if (NOT APPLE)
target_link_options(${name} PRIVATE
${CFI_FLAGS}
"LINKER:-z,relro,-z,now,-z,noexecstack"
"LINKER:-z,relro,-z,now,-z,noexecstack ${CFI_FLAGS}"
)
if (UR_DEVELOPER_MODE)
target_link_options(${name} PRIVATE -Werror -Wextra)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,6 @@ TEST_P(urEnqueueEventsWaitMultiDeviceMTTest, EnqueueWaitSingleQueueMultiOps) {
}

TEST_P(urEnqueueEventsWaitMultiDeviceMTTest, EnqueueWaitOnAllQueues) {
// Fails when -fsanitize=cfi
#ifdef UR_USE_CFI
if (getParam().value) {
UUR_KNOWN_FAILURE_ON(uur::OpenCL{});
}
#endif

std::vector<uur::raii::Event> eventsRaii(devices.size());
std::vector<ur_event_handle_t> events(devices.size());
auto work = [this, &events, &eventsRaii](size_t i) {
Expand Down
Loading