- Notifications
You must be signed in to change notification settings - Fork 89
MSVC STL version check #149
Changes from 5 commits
e54751e d744675 2ed1a98 3c161db 52b9b7b 90b39ff 083d030 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -131,14 +131,57 @@ execute_process(COMMAND ${ComputeCpp_INFO_EXECUTABLE} | |
| "--dump-device-compiler-flags" | ||
| OUTPUT_VARIABLE COMPUTECPP_DEVICE_COMPILER_FLAGS | ||
| RESULT_VARIABLE ComputeCpp_INFO_EXECUTABLE_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS "-sycl-target ${COMPUTECPP_BITCODE}") | ||
| # convert to list before appending | ||
| # (VERBATIM arg passing to execute_process will go crazy over mixed string-list syntax) | ||
| string(REPLACE " " ";" COMPUTECPP_DEVICE_COMPILER_FLAGS ${COMPUTECPP_DEVICE_COMPILER_FLAGS}) | ||
| list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS} -sycl-target ${COMPUTECPP_BITCODE}) | ||
DuncanMcBain marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| | ||
| if(NOT ComputeCpp_INFO_EXECUTABLE_RESULT EQUAL "0") | ||
| message(FATAL_ERROR "compute++ flags - Error obtaining compute++ flags!") | ||
| else() | ||
| mark_as_advanced(COMPUTECPP_COMPILER_FLAGS) | ||
| endif() | ||
| | ||
| # Check if the hosted STL of MSVC is compatible with ComputeCpp | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this whole code section is MSVC-specific, I think I'd be happier if it was part of an opt-in module (i.e. its own file). I feel like that would be a better reflection of the separation of concerns here - it could be called MSVCVersionCheck or similar, and that way users targetting '17 know that they have to deal with it (similarly, once the compiler is updated, they can remove it again). Let me know what you think! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm generally okay with all this being moved to a file of its own. I'm not sure how many such changes are needed. There is a brief GCC-related test at the beginning, which for the sake of consistency might also be put to a different file... all in all, factoring out compiler-specific stuff to separate files and keeping All of this might be the topic of another PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'd prefer if we move it into its own file for now, provided it's not too difficult. Let me know if it looks like it will actually be too onerous. You're right about the gcc/clang check. Revisiting it, I'm tempted to remove it, because who uses 4.8? 😝 More seriously, if you use old compilers like that, you will get compile issues. Though maybe we should move it to this new file while we still (ostensibly) support Ubuntu 14.04? Decision time: if you feel like moving it too, please feel free, though I won't mark it as a requirement of this PR by any means. Thanks again! | ||
| if(MSVC) | ||
| set(ComputeCpp_STL_CHECK_SRC __STL_check) | ||
| file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ComputeCpp_STL_CHECK_SRC}.cpp | ||
| "#include <ios>\n" | ||
MathiasMagnus marked this conversation as resolved. Show resolved Hide resolved | ||
| "int main() { return 0; }\n") | ||
| execute_process( | ||
| COMMAND ${ComputeCpp_DEVICE_COMPILER_EXECUTABLE} | ||
| ${COMPUTECPP_DEVICE_COMPILER_FLAGS} | ||
| -isystem ${ComputeCpp_INCLUDE_DIRS} | ||
| -o ${ComputeCpp_STL_CHECK_SRC}.sycl | ||
| -c ${ComputeCpp_STL_CHECK_SRC}.cpp | ||
| WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
| RESULT_VARIABLE ComputeCpp_STL_CHECK_RESULT | ||
| ERROR_QUIET | ||
| OUTPUT_QUIET) | ||
| if(NOT ${ComputeCpp_STL_CHECK_RESULT} EQUAL 0) | ||
| # Try disabling compiler version checks | ||
| execute_process( | ||
| COMMAND ${ComputeCpp_DEVICE_COMPILER_EXECUTABLE} | ||
| ${COMPUTECPP_DEVICE_COMPILER_FLAGS} | ||
| -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH | ||
| -isystem ${ComputeCpp_INCLUDE_DIRS} | ||
| -o ${ComputeCpp_STL_CHECK_SRC}.cpp.sycl | ||
| -c ${ComputeCpp_STL_CHECK_SRC}.cpp | ||
| WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
| RESULT_VARIABLE ComputeCpp_STL_CHECK_RESULT | ||
| ERROR_QUIET | ||
| OUTPUT_QUIET) | ||
| if(NOT ${ComputeCpp_STL_CHECK_RESULT} EQUAL 0) | ||
| message(STATUS "Device compiler cannot consume hosted STL headers. Using any parts of the STL will likely result in device compiler errors.") | ||
| else() | ||
DuncanMcBain marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| message(STATUS "Device compiler does not meet certain STL version requirements. Disabling version checks and hoping for the best.") | ||
| list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH) | ||
| endif() | ||
| endif() | ||
| file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${ComputeCpp_STL_CHECK_SRC}.cpp | ||
| ${CMAKE_CURRENT_BINARY_DIR}/${ComputeCpp_STL_CHECK_SRC}.cpp.sycl) | ||
| endif(MSVC) | ||
| | ||
| find_package_handle_standard_args(ComputeCpp | ||
| REQUIRED_VARS ComputeCpp_ROOT_DIR | ||
| ComputeCpp_DEVICE_COMPILER_EXECUTABLE | ||
| | @@ -375,15 +418,9 @@ function(__build_ir) | |
| # Add both source and the sycl files to the VS solution. | ||
| target_sources(${SDK_BUILD_IR_TARGET} PUBLIC ${SDK_BUILD_IR_SOURCE} ${outputSyclFile}) | ||
| | ||
| # NOTE: The Visual Studio generators parse compile flags differently, | ||
| # hence the different argument syntax | ||
| if(CMAKE_GENERATOR MATCHES "Visual Studio") | ||
| set(forceIncludeFlags "/FI\"${includedFile}\" /TP") | ||
| else() | ||
| set(forceIncludeFlags /FI ${includedFile} /TP) | ||
| endif() | ||
| set(forceIncludeFlags "/FI ${includedFile} /TP") | ||
| else() | ||
| set(forceIncludeFlags "-include ${includedFile} -x c++") | ||
| set(forceIncludeFlags "-include ${includedFile} -x c++") | ||
DuncanMcBain marked this conversation as resolved. Show resolved Hide resolved | ||
| endif() | ||
| | ||
| set_property( | ||
| | ||
Uh oh!
There was an error while loading. Please reload this page.