80
80
endif ()
81
81
82
82
set (CFI_FLAGS "" )
83
- if (CFI_HAS_CFI_SANITIZE )
83
+ if (CXX_HAS_CFI_SANITIZE )
84
84
# cfi-icall requires called functions in shared libraries to also be built with cfi-icall, which we can't
85
85
# guarantee. -fsanitize=cfi depends on -flto
86
86
set (CFI_FLAGS "-flto -fsanitize=cfi -fno-sanitize=cfi-icall -fsanitize-ignorelist=${PROJECT_SOURCE_DIR} /sanitizer-ignorelist.txt" )
@@ -103,14 +103,17 @@ function(add_ur_target_compile_options name)
103
103
-fstack-protector-strong
104
104
-fvisibility=hidden
105
105
106
- ${CFI_FLAGS}
107
106
$< $< BOOL:${CXX_HAS_FCF_PROTECTION_FULL} > :-fcf-protection=full>
108
107
$< $< BOOL:${CXX_HAS_FSTACK_CLASH_PROTECTION} > :-fstack-clash-protection>
109
108
110
109
# Colored output
111
110
$< $< CXX_COMPILER_ID:GNU> :-fdiagnostics-color=always>
112
111
$< $< CXX_COMPILER_ID:Clang,AppleClang> :-fcolor-diagnostics>
113
112
)
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} )
114
117
if (UR_DEVELOPER_MODE )
115
118
target_compile_options (${name} PRIVATE -Werror -Wextra )
116
119
endif ()
@@ -151,8 +154,7 @@ function(add_ur_target_link_options name)
151
154
if (NOT MSVC )
152
155
if (NOT APPLE )
153
156
target_link_options (${name} PRIVATE
154
- ${CFI_FLAGS}
155
- "LINKER:-z,relro,-z,now,-z,noexecstack"
157
+ "LINKER:-z,relro,-z,now,-z,noexecstack ${CFI_FLAGS} "
156
158
)
157
159
if (UR_DEVELOPER_MODE )
158
160
target_link_options (${name} PRIVATE -Werror -Wextra )
0 commit comments