Adding treatment of ARM platforms if a SYCL-compatible compiler is detected#599
Open
christophriesinger wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Updates Embree’s SYCL (DPCPP/Clang -fsycl) CMake configuration to avoid passing x86-only compile flags when building on ARM platforms, mirroring the existing ARM handling in the Clang toolchain CMake.
Changes:
- Add
EMBREE_ARM-gated ISA flag definitions indpcpp.cmake(including a macOS universal-binaryx86_64sub-case). - Adjust default (non-ARM) SSE2 flags in
dpcpp.cmaketo match the pattern used inclang.cmake.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _SET_IF_EMPTY(FLAGS_AVX512 "-march=skx") | ||
| IF (EMBREE_ARM) | ||
| IF ("x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES) | ||
| # set ARM an x86 flags for macOS universal binary build |
Comment on lines
+25
to
+27
| # for `thread` keyword | ||
| _SET_IF_EMPTY(FLAGS_SSE2 "-msse -msse2 -mno-sse4.2") | ||
| _SET_IF_EMPTY(FLAGS_SSE42 "-msse4.2") |
Comment on lines
+99
to
+104
| MACRO(APPLY_MACOS_FLAGS) | ||
| IF (APPLE) | ||
| SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7") # makes sure code runs on older MacOSX versions | ||
| SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") # link against libc++ which supports C++11 features | ||
| ENDIF() | ||
| ENDMACRO() |
Comment on lines
+54
to
+66
| MACRO(CONFIGURE_STACK_PROTECTOR) | ||
| IF (EMBREE_STACK_PROTECTOR) | ||
| IF (WIN32 AND SYCL_ONEAPI_ICX) | ||
| SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS") # protects against return address overrides | ||
| ELSEIF (NOT WIN32) | ||
| SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector") # protects against return address overrides | ||
| ELSEIF (WIN32) | ||
| SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS") # protects against return address overrides | ||
| ENDIF() | ||
| ELSEIF (WIN32) | ||
| SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /GS-") # do not protect against return address overrides | ||
| ENDIF() | ||
| ENDMACRO() |
Comment on lines
+68
to
+78
| MACRO(DISABLE_STACK_PROTECTOR_FOR_FILE file) | ||
| IF (EMBREE_STACK_PROTECTOR) | ||
| IF (SYCL_ONEAPI_ICX AND WIN32) | ||
| SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "/GS-") | ||
| ELSEIF (NOT WIN32) | ||
| SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "-fno-stack-protector") | ||
| ELSEIF (WIN32) | ||
| SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "/GS-") | ||
| ENDIF() | ||
| ENDIF() | ||
| ENDMACRO() |
Comment on lines
+31
to
+41
| IF (NOT APPLE) | ||
| IF (CMAKE_CXX_COMPILER_ID MATCHES "GNU") | ||
| SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") # issues link error for undefined symbols in shared library | ||
| SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack") # we do not need an executable stack | ||
| SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z relro -z now") # re-arranges data sections to increase security | ||
| SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") # we do not need an executable stack | ||
| SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z relro -z now") # re-arranges data sections to increase security | ||
| ENDIF () | ||
| SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") # enables position independent execution for executable | ||
| ENDIF(APPLE) | ||
| ENDIF() | ||
|
|
||
| SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") # enables position independent execution for executable |
| SET(FLAGS_SSE42 "-D__SSE4_2__ -D__SSE4_1__ -msse4.2") | ||
| SET(FLAGS_AVX "-D__AVX__ -D__SSE4_2__ -D__SSE4_1__ -D__BMI__ -D__BMI2__ -D__LZCNT__ -mavx") | ||
| SET(FLAGS_AVX2 "-D__AVX2__ -D__AVX__ -D__SSE4_2__ -D__SSE4_1__ -D__BMI__ -D__BMI2__ -D__LZCNT__ -mf16c -mavx2 -mfma -mlzcnt -mbmi -mbmi2") | ||
| _SET_IF_EMPTY(FLAGS_AVX512 "-march=skx") |
| _SET_IF_EMPTY(FLAGS_SSE42 "-msse4.2") | ||
| _SET_IF_EMPTY(FLAGS_AVX "-mavx") | ||
| _SET_IF_EMPTY(FLAGS_AVX2 "-mf16c -mavx2 -mfma -mlzcnt -mbmi -mbmi2") | ||
| _SET_IF_EMPTY(FLAGS_AVX512 "-march=skx") |
Contributor
|
I might be wrong here, but couldn't we just make a change here: https://github.com/RenderKit/embree/blob/master/CMakeLists.txt#L228, guarded by something like (untested) Which would bypass the entire dpcpp thing? The build instructions from #439 I wrote still work if you just add |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At least since Clang 19, LLVM Clang supports SYCL and thus, the
-fsyclcompiler argument. Hence, if such a LLVM Clang is detected by CMake, common/cmake/dpcpp.cmake gets included. Since LLVM Clang with support for the-fsyclcompiler argument is also available for ARM platforms (e.g. Clang-cl for Windows on ARM) dpcpp.cmake has to make sure no arguments are passed to Clang not supported by ARM (e.g.-msse2).This code changes copies the treatment for ARM platforms from clang.cmake to dpcpp.cmake.