Skip to content

Commit 9c57622

Browse files
authored
[UR] Fix cfi initialization (#17472)
There were a number of problems preventing CFI from being enabled, this hopefully fixes them. As part of this, an unused variable compile error in `clang` was fixed.
1 parent 456b9b4 commit 9c57622

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

unified-runtime/cmake/helpers.cmake

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ set(CFI_FLAGS "")
8383
if (CXX_HAS_CFI_SANITIZE)
8484
# cfi-icall requires called functions in shared libraries to also be built with cfi-icall, which we can't
8585
# guarantee. -fsanitize=cfi depends on -flto
86-
set(CFI_FLAGS "-flto -fsanitize=cfi -fno-sanitize=cfi-icall -fsanitize-ignorelist=${PROJECT_SOURCE_DIR}/sanitizer-ignorelist.txt")
86+
set(CFI_FLAGS "-flto;-fsanitize=cfi;-fno-sanitize=cfi-icall;-fsanitize-ignorelist=${PROJECT_SOURCE_DIR}/sanitizer-ignorelist.txt")
8787
endif()
8888

8989
function(add_ur_target_compile_options name)
@@ -103,17 +103,15 @@ function(add_ur_target_compile_options name)
103103
-fstack-protector-strong
104104
-fvisibility=hidden
105105

106+
${CFI_FLAGS}
107+
106108
$<$<BOOL:${CXX_HAS_FCF_PROTECTION_FULL}>:-fcf-protection=full>
107109
$<$<BOOL:${CXX_HAS_FSTACK_CLASH_PROTECTION}>:-fstack-clash-protection>
108110

109111
# Colored output
110112
$<$<CXX_COMPILER_ID:GNU>:-fdiagnostics-color=always>
111113
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-fcolor-diagnostics>
112114
)
113-
# Cmake can't handle mixing strings without quotes as the options above
114-
# are and strings with quotes like ${CFI_FLAGS} is, so this needs a
115-
# separate call.
116-
target_compile_options(${name} PRIVATE ${CFI_FLAGS})
117115
if (UR_DEVELOPER_MODE)
118116
target_compile_options(${name} PRIVATE -Werror -Wextra)
119117
endif()
@@ -154,7 +152,8 @@ function(add_ur_target_link_options name)
154152
if(NOT MSVC)
155153
if (NOT APPLE)
156154
target_link_options(${name} PRIVATE
157-
"LINKER:-z,relro,-z,now,-z,noexecstack ${CFI_FLAGS}"
155+
${CFI_FLAGS}
156+
"LINKER:-z,relro,-z,now,-z,noexecstack"
158157
)
159158
if (UR_DEVELOPER_MODE)
160159
target_link_options(${name} PRIVATE -Werror -Wextra)

unified-runtime/source/loader/layers/sanitizer/msan/msan_shadow.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ struct MsanShadowMemoryGPU : public MsanShadowMemory {
132132
ur_mutex VirtualMemMapsMutex;
133133

134134
uptr LocalShadowOffset = 0;
135-
136-
uptr PrivateShadowOffset = 0;
137135
};
138136

139137
// clang-format off

0 commit comments

Comments
 (0)