File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ IF (WIN32)
1717 ELSE ()
1818 SET (COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS-" ) # do not protect against return address overrides
1919 ENDIF ()
20+
21+ # Stack protector override for specific files
2022 MACRO (DISABLE_STACK_PROTECTOR_FOR_FILE file )
2123 IF (EMBREE_STACK_PROTECTOR)
2224 SET_SOURCE_FILES_PROPERTIES (${file} PROPERTIES COMPILE_FLAGS "/GS-" )
Original file line number Diff line number Diff line change @@ -50,30 +50,16 @@ MACRO(APPLY_COMMON_COMPILER_FLAGS)
5050 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS } -D_FORTIFY_SOURCE=2" ) # perform extra security checks for some standard library calls
5151ENDMACRO ()
5252
53- # Stack protector configuration
53+ # Stack protector configuration (Unix-only)
5454MACRO (CONFIGURE_STACK_PROTECTOR )
55- IF (EMBREE_STACK_PROTECTOR)
56- IF (WIN32 AND SYCL_ONEAPI_ICX)
57- SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS } /GS" ) # protects against return address overrides
58- ELSEIF (NOT WIN32 )
59- SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS } -fstack-protector" ) # protects against return address overrides
60- ELSEIF (WIN32 )
61- SET (COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS" ) # protects against return address overrides
62- ENDIF ()
63- ELSEIF (WIN32 )
64- SET (COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS-" ) # do not protect against return address overrides
55+ IF (EMBREE_STACK_PROTECTOR AND NOT WIN32 )
56+ SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS } -fstack-protector" ) # protects against return address overrides
6557 ENDIF ()
6658ENDMACRO ()
6759
6860MACRO (DISABLE_STACK_PROTECTOR_FOR_FILE file )
69- IF (EMBREE_STACK_PROTECTOR)
70- IF (SYCL_ONEAPI_ICX AND WIN32 )
71- SET_SOURCE_FILES_PROPERTIES (${file} PROPERTIES COMPILE_FLAGS "/GS-" )
72- ELSEIF (NOT WIN32 )
73- SET_SOURCE_FILES_PROPERTIES (${file} PROPERTIES COMPILE_FLAGS "-fno-stack-protector" )
74- ELSEIF (WIN32 )
75- SET_SOURCE_FILES_PROPERTIES (${file} PROPERTIES COMPILE_FLAGS "/GS-" )
76- ENDIF ()
61+ IF (EMBREE_STACK_PROTECTOR AND NOT WIN32 )
62+ SET_SOURCE_FILES_PROPERTIES (${file} PROPERTIES COMPILE_FLAGS "-fno-stack-protector" )
7763 ENDIF ()
7864ENDMACRO ()
7965
Original file line number Diff line number Diff line change @@ -179,7 +179,17 @@ IF(SYCL_ONEAPI_ICX)
179179 ENDIF ()
180180ENDIF ()
181181
182- CONFIGURE_STACK_PROTECTOR ()
182+ # Stack protector configuration (Windows ICX-specific handling)
183+ IF (WIN32 AND SYCL_ONEAPI_ICX)
184+ IF (EMBREE_STACK_PROTECTOR)
185+ SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS } /GS" ) # protects against return address overrides
186+ ELSE ()
187+ SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS } /GS-" ) # do not protect against return address overrides
188+ ENDIF ()
189+ ELSE ()
190+ # Use shared stack protector macro for Unix and other platforms
191+ CONFIGURE_STACK_PROTECTOR ()
192+ ENDIF ()
183193
184194IF (SYCL_ONEAPI_ICX AND WIN32 )
185195 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS } /fp:precise" ) # makes dpcpp compiler compatible with clang++
You can’t perform that action at this time.
0 commit comments