diff --git a/buildbot/configure.py b/buildbot/configure.py index b2f9a9805976f..d2c130a28fdb0 100644 --- a/buildbot/configure.py +++ b/buildbot/configure.py @@ -246,6 +246,9 @@ def do_configure(args, passthrough_args): "none of them to let download from github.com" ) + if args.use_debug_crt_dll: + cmake_cmd.extend(["-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL"]) + # Add additional CMake options if provided if args.cmake_opt: cmake_cmd += args.cmake_opt @@ -434,6 +437,11 @@ def main(): action="store_true", help="Print the generated CMake flags to a single line on standard output and exit. Suppresses all other output and does not run the cmake command.", ) + parser.add_argument( + "--use-debug-crt-dll", + action="store_true", + help="Link libraries with MSVC debug dll in release mode.", + ) args, passthrough_args = parser.parse_known_intermixed_args() if not args.print_cmake_flags: diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index ae3fa0335ab17..1eb437020d5ea 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -315,13 +315,6 @@ if (WIN32) if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) list(APPEND SYCL_RT_LIBS sycl${SYCL_MAJOR_VERSION}-preview) endif() - # Do we really support non-MSVC ABI on WIN? - if (MSVC) - list(APPEND SYCL_RT_LIBS sycl${SYCL_MAJOR_VERSION}d) - if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) - list(APPEND SYCL_RT_LIBS sycl${SYCL_MAJOR_VERSION}-previewd) - endif() - endif() else() set(SYCL_RT_LIBS sycl) if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) @@ -372,11 +365,7 @@ if(SYCL_ENABLE_XPTI_TRACING AND endif() if (SYCL_ENABLE_XPTI_TRACING) - if (MSVC) - set(XPTIFW_LIBS xpti xptid xptifw xptifwd) - else() - set(XPTIFW_LIBS xpti xptifw) - endif() + set(XPTIFW_LIBS xpti xptifw) endif() # SYCL toolchain builds all components: compiler, libraries, headers, etc. @@ -415,7 +404,7 @@ add_custom_target( sycl-toolchain ALL ) if (WIN32) - add_dependencies(sycl-toolchain ur_win_proxy_loader unified-runtimed-build) + add_dependencies(sycl-toolchain ur_win_proxy_loader) endif() if("cuda" IN_LIST SYCL_ENABLE_BACKENDS) diff --git a/sycl/cmake/modules/AddSYCLUnitTest.cmake b/sycl/cmake/modules/AddSYCLUnitTest.cmake index 9f1fa77774361..04d11f4ea09e2 100644 --- a/sycl/cmake/modules/AddSYCLUnitTest.cmake +++ b/sycl/cmake/modules/AddSYCLUnitTest.cmake @@ -11,22 +11,12 @@ function(add_sycl_unittest_internal test_dirname link_variant is_preview is_no_c # Select which sycl libraries and object to link based # on whether this is a preview build. - if (MSVC AND build_type_lower MATCHES "debug") - if (${is_preview}) - set(sycl_obj_target "sycl-previewd_object") - set(sycl_so_target "sycl-previewd") - else() - set(sycl_obj_target "sycld_object") - set(sycl_so_target "sycld") - endif() + if (${is_preview}) + set(sycl_obj_target "sycl-preview_object") + set(sycl_so_target "sycl-preview") else() - if (${is_preview}) - set(sycl_obj_target "sycl-preview_object") - set(sycl_so_target "sycl-preview") - else() - set(sycl_obj_target "sycl_object") - set(sycl_so_target "sycl") - endif() + set(sycl_obj_target "sycl_object") + set(sycl_so_target "sycl") endif() # This is done to ensure that preview tests are kept in a separate diff --git a/sycl/cmake/modules/BuildUnifiedRuntime.cmake b/sycl/cmake/modules/BuildUnifiedRuntime.cmake index 73e52e59f2be3..280a946cf2e51 100644 --- a/sycl/cmake/modules/BuildUnifiedRuntime.cmake +++ b/sycl/cmake/modules/BuildUnifiedRuntime.cmake @@ -182,113 +182,6 @@ if("offload" IN_LIST SYCL_ENABLE_BACKENDS) add_sycl_ur_adapter(offload) endif() -if(CMAKE_SYSTEM_NAME STREQUAL Windows) - # On Windows, also build/install debug libraries with the d suffix that are - # compiled with /MDd so users can link against these in debug builds. - include(ExternalProject) - set(URD_BINARY_DIR ${CMAKE_BINARY_DIR}/unified-runtimed) - set(URD_INSTALL_DIR ${URD_BINARY_DIR}/install) - - # This creates a subbuild which can be used in dependencies with the - # unified-runtimed target. It invokes the install-unified-runtime-libraries - # target to install the UR runtime libraries. - ExternalProject_Add(unified-runtimed - SOURCE_DIR ${UNIFIED_RUNTIME_SOURCE_DIR} - BINARY_DIR ${URD_BINARY_DIR} - INSTALL_DIR ${URD_INSTALL_DIR} - INSTALL_COMMAND ${CMAKE_COMMAND} - --build --config Debug - --target install-unified-runtime-libraries - CMAKE_CACHE_ARGS - -DCMAKE_BUILD_TYPE:STRING=Debug - -DCMAKE_INSTALL_PREFIX:STRING= - # Enable d suffix on libraries - -DUR_USE_DEBUG_POSTFIX:BOOL=ON - # Don't build unnecessary targets in subbuild. - -DUR_BUILD_EXAMPLES:BOOL=OFF - -DUR_BUILD_TESTS:BOOL=OFF - -DUR_BUILD_TOOLS:BOOL=OFF - # Sanitizer layer is not supported on Windows. - -DUR_ENABLE_SYMBOLIZER:BOOL=OFF - # Inherit settings from parent build. - -DUR_ENABLE_TRACING:BOOL=${UR_ENABLE_TRACING} - -DUR_ENABLE_COMGR:BOOL=${UR_ENABLE_COMGR} - -DUR_BUILD_ADAPTER_L0:BOOL=${UR_BUILD_ADAPTER_L0} - -DUR_BUILD_ADAPTER_L0_V2:BOOL=${UR_BUILD_ADAPTER_L0_V2} - -DUR_BUILD_ADAPTER_OPENCL:BOOL=${UR_BUILD_ADAPTER_OPENCL} - -DUR_BUILD_ADAPTER_CUDA:BOOL=${UR_BUILD_ADAPTER_CUDA} - -DUR_BUILD_ADAPTER_HIP:BOOL=${UR_BUILD_ADAPTER_HIP} - -DUR_BUILD_ADAPTER_NATIVE_CPU:BOOL=${UR_BUILD_ADAPTER_NATIVE_CPU} - -DUMF_BUILD_EXAMPLES:BOOL=${UMF_BUILD_EXAMPLES} - -DUMF_BUILD_SHARED_LIBRARY:BOOL=${UMF_BUILD_SHARED_LIBRARY} - -DUMF_LINK_HWLOC_STATICALLY:BOOL=${UMF_LINK_HWLOC_STATICALLY} - -DUMF_DISABLE_HWLOC:BOOL=${UMF_DISABLE_HWLOC} - # Enable d suffix in UMF - -DUMF_USE_DEBUG_POSTFIX:BOOL=ON - ) - - # Copy the debug UR runtime libraries to /bin & /lib for use in - # the parent build, e.g. integration testing. - set(URD_COPY_FILES) - macro(urd_copy_library_to_build library shared) - if(${shared}) - list(APPEND URD_COPY_FILES - ${LLVM_BINARY_DIR}/bin/${library}.dll - ) - add_custom_command( - OUTPUT - ${LLVM_BINARY_DIR}/bin/${library}.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${URD_INSTALL_DIR}/bin/${library}.dll - ${LLVM_BINARY_DIR}/bin/${library}.dll - ) - endif() - - list(APPEND URD_COPY_FILES - ${LLVM_BINARY_DIR}/lib/${library}.lib - ) - add_custom_command( - OUTPUT - ${LLVM_BINARY_DIR}/lib/${library}.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${URD_INSTALL_DIR}/lib/${library}.lib - ${LLVM_BINARY_DIR}/lib/${library}.lib - ) - endmacro() - - urd_copy_library_to_build(ur_loaderd "NOT;${UR_STATIC_LOADER}") - foreach(adatper ${SYCL_ENABLE_BACKENDS}) - if(adapter MATCHES "level_zero") - set(shared "NOT;${UR_STATIC_ADAPTER_L0}") - else() - set(shared TRUE) - endif() - urd_copy_library_to_build(ur_adapter_${adatper}d "${shared}") - endforeach() - # Also copy umfd.dll/umfd.lib - urd_copy_library_to_build(umfd ${UMF_BUILD_SHARED_LIBRARY}) - - add_custom_target(unified-runtimed-build ALL DEPENDS ${URD_COPY_FILES}) - add_dependencies(unified-runtimed-build unified-runtimed) - - # Add the debug UR runtime libraries to the parent install. - install( - FILES ${URD_INSTALL_DIR}/bin/ur_loaderd.dll - DESTINATION "bin" COMPONENT unified-runtime-loader) - foreach(adapter ${SYCL_ENABLE_BACKENDS}) - install( - FILES ${URD_INSTALL_DIR}/bin/ur_adapter_${adapter}d.dll - DESTINATION "bin" COMPONENT ur_adapter_${adapter}) - add_dependencies(install-sycl-ur-adapter-${adapter} unified-runtimed) - endforeach() - if(UMF_BUILD_SHARED_LIBRARY) - # Also install umfd.dll - install( - FILES ${URD_INSTALL_DIR}/bin/umfd.dll - DESTINATION "bin" COMPONENT unified-memory-framework) - endif() -endif() - if(TARGET umf) install(TARGETS umf LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT unified-memory-framework diff --git a/sycl/cmake/modules/SYCLUtils.cmake b/sycl/cmake/modules/SYCLUtils.cmake index f469b26047605..b5bae23b2e539 100644 --- a/sycl/cmake/modules/SYCLUtils.cmake +++ b/sycl/cmake/modules/SYCLUtils.cmake @@ -4,17 +4,18 @@ include(CheckLinkerFlag) # add_stripped_pdb(TARGET_NAME) # # Will add option for generating stripped PDB file and install the generated -# file as ${ARG_TARGET_NAME}.pdb in bin folder. +# file as ${ARG_TARGET_NAME}{d}.pdb in bin folder. # NOTE: LLD does not currently support /PDBSTRIPPED so the PDB file is optional. macro(add_stripped_pdb ARG_TARGET_NAME) - check_linker_flag(CXX "LINKER:/PDBSTRIPPED:${ARG_TARGET_NAME}.stripped.pdb" + set(PDB_FILENAME "${ARG_TARGET_NAME}$<$:d>") + check_linker_flag(CXX "LINKER:/PDBSTRIPPED:${PDB_FILENAME}.stripped.pdb" LINKER_SUPPORTS_PDBSTRIPPED) if(LINKER_SUPPORTS_PDBSTRIPPED) target_link_options(${ARG_TARGET_NAME} - PRIVATE "LINKER:/PDBSTRIPPED:${ARG_TARGET_NAME}.stripped.pdb") - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET_NAME}.stripped.pdb" + PRIVATE "LINKER:/PDBSTRIPPED:${PDB_FILENAME}.stripped.pdb") + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PDB_FILENAME}.stripped.pdb" DESTINATION ${CMAKE_INSTALL_PREFIX}/bin - RENAME "${ARG_TARGET_NAME}.pdb" + RENAME "${PDB_FILENAME}.pdb" COMPONENT ${ARG_TARGET_NAME} OPTIONAL) endif() diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 4159303f87d19..c75fff52a6554 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -16,10 +16,10 @@ if (SYCL_ENABLE_XPTI_TRACING) include_directories(${LLVM_EXTERNAL_XPTI_SOURCE_DIR}/include) endif() -function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) +function(add_sycl_rt_library LIB_TARGET_NAME LIB_OBJ_NAME LIB_OUTPUT_NAME) # Add an optional argument so we can get the library name to # link with for Windows Debug version - cmake_parse_arguments(ARG "" "XPTI_LIB;IMPLIB_NAME" "COMPILE_OPTIONS;SOURCES" ${ARGN}) + cmake_parse_arguments(ARG "" "XPTI_LIB;IMPLIB_OUTPUT_NAME" "COMPILE_OPTIONS;SOURCES" ${ARGN}) add_library(${LIB_OBJ_NAME} OBJECT ${ARG_SOURCES}) @@ -75,13 +75,13 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) # Common link step setup - add_library(${LIB_NAME} SHARED + add_library(${LIB_TARGET_NAME} SHARED $ ${CMAKE_CURRENT_BINARY_DIR}/version.rc) find_package(Threads REQUIRED) - target_link_libraries(${LIB_NAME} + target_link_libraries(${LIB_TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} @@ -96,22 +96,22 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) if (SYCL_ENABLE_STACK_PRINTING) if(NOT MSVC OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ARG_COMPILE_OPTIONS MATCHES ".*MDd.*") OR (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT ARG_COMPILE_OPTIONS MATCHES ".*MDd.*")) - add_dependencies(${LIB_NAME} LLVMSupport) + add_dependencies(${LIB_TARGET_NAME} LLVMSupport) target_compile_definitions(${LIB_OBJ_NAME} PUBLIC ENABLE_STACK_TRACE) - target_link_libraries(${LIB_NAME} PRIVATE LLVMSupport) + target_link_libraries(${LIB_TARGET_NAME} PRIVATE LLVMSupport) endif() endif() # TODO: Enabled for MSVC if (NOT MSVC AND SYCL_LIB_WITH_DEBUG_SYMBOLS) separate_arguments(CMAKE_CXX_FLAGS_DEBUG_SEPARATED UNIX_COMMAND "${CMAKE_CXX_FLAGS_DEBUG}") - target_compile_options(${LIB_NAME} PRIVATE ${CMAKE_CXX_FLAGS_DEBUG_SEPARATED}) + target_compile_options(${LIB_TARGET_NAME} PRIVATE ${CMAKE_CXX_FLAGS_DEBUG_SEPARATED}) endif() # To facilitate better tracing and profiling except on release builds. check_cxx_compiler_flag("-fno-omit-frame-pointer" CXX_HAS_NO_OMIT_FRAME_POINTER) if (CXX_HAS_NO_OMIT_FRAME_POINTER) - target_compile_options(${LIB_NAME} PUBLIC + target_compile_options(${LIB_TARGET_NAME} PUBLIC $<$:-fno-omit-frame-pointer> ) target_compile_options(${LIB_OBJ_NAME} PUBLIC @@ -123,10 +123,10 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) target_compile_options(${LIB_OBJ_NAME} PUBLIC -fprofile-instr-generate -fcoverage-mapping ) - target_compile_options(${LIB_NAME} PUBLIC + target_compile_options(${LIB_TARGET_NAME} PUBLIC -fprofile-instr-generate -fcoverage-mapping ) - target_link_options(${LIB_NAME} PUBLIC + target_link_options(${LIB_TARGET_NAME} PUBLIC -fprofile-instr-generate -fcoverage-mapping ) endif() @@ -135,16 +135,16 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) sycl-headers ) - set_target_properties(${LIB_NAME} PROPERTIES LINKER_LANGUAGE CXX) + set_target_properties(${LIB_TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX) if (SYCL_ENABLE_XPTI_TRACING) target_compile_definitions(${LIB_OBJ_NAME} PRIVATE XPTI_ENABLE_INSTRUMENTATION XPTI_STATIC_LIBRARY) - target_link_libraries(${LIB_NAME} PRIVATE ${ARG_XPTI_LIB}) + target_link_libraries(${LIB_TARGET_NAME} PRIVATE ${ARG_XPTI_LIB}) endif() if (LLVM_ENABLE_ZSTD) target_compile_definitions(${LIB_OBJ_NAME} PRIVATE SYCL_RT_ZSTD_AVAILABLE) - target_link_libraries(${LIB_NAME} PRIVATE ${zstd_STATIC_LIBRARY}) + target_link_libraries(${LIB_TARGET_NAME} PRIVATE ${zstd_STATIC_LIBRARY}) target_include_directories(${LIB_OBJ_NAME} PRIVATE ${zstd_INCLUDE_DIR}) endif() @@ -153,44 +153,38 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) # ur_win_proxy_loader if (WIN32) include_directories(${LLVM_EXTERNAL_SYCL_SOURCE_DIR}/ur_win_proxy_loader) - if(WIN_DUPE) - target_link_libraries(${LIB_NAME} PUBLIC ur_win_proxy_loaderd) - set(MANIFEST_FILE_NAME "sycld.manifest") - else() - target_link_libraries(${LIB_NAME} PUBLIC ur_win_proxy_loader) - set(MANIFEST_FILE_NAME "sycl.manifest") - endif() + target_link_libraries(${LIB_TARGET_NAME} PUBLIC ur_win_proxy_loader) + set(MANIFEST_FILE_NAME "sycl$<$:d>.manifest") # Embed manifest into the sycl.dll where ur_win_proxy_loader.dll is described as sycl.dll's private dll and will always be loaded from the same directory. # 0x2000: LOAD_LIBRARY_SAFE_CURRENT_DIRS flag. Using this flag means that loading dependency DLLs (of sycl.dll) # from the current directory is only allowed if it is under a directory in the Safe load list. - target_link_options(${LIB_NAME} PRIVATE "LINKER:/DEPENDENTLOADFLAG:0x2000" "LINKER:/MANIFEST:NO" "LINKER:/MANIFEST:EMBED" "LINKER:/MANIFESTINPUT:${CMAKE_CURRENT_SOURCE_DIR}/${MANIFEST_FILE_NAME}") + target_link_options(${LIB_TARGET_NAME} PRIVATE "LINKER:/DEPENDENTLOADFLAG:0x2000" "LINKER:/MANIFEST:NO" "LINKER:/MANIFEST:EMBED" "LINKER:/MANIFESTINPUT:${CMAKE_CURRENT_SOURCE_DIR}/${MANIFEST_FILE_NAME}") endif() if (WIN32) - if (ARG_IMPLIB_NAME) - add_custom_command( - TARGET ${LIB_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${LIB_NAME}.lib ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ARG_IMPLIB_NAME}.lib - COMMENT "Creating version-agnostic copy of the import library.") - install( - FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ARG_IMPLIB_NAME}.lib - DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT sycl) - endif() + add_custom_command( + TARGET ${LIB_TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${LIB_OUTPUT_NAME}.lib + ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ARG_IMPLIB_OUTPUT_NAME}.lib + COMMENT "Creating version-agnostic copy of the import library.") + install( + FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ARG_IMPLIB_OUTPUT_NAME}.lib + DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT sycl) endif() if (MSVC) # Install stripped PDB - add_stripped_pdb(${LIB_NAME}) + add_stripped_pdb(${LIB_TARGET_NAME}) else() if (UNIX AND NOT APPLE) set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/ld-version-script.txt") target_link_libraries( - ${LIB_NAME} PRIVATE "-Wl,--version-script=${linker_script}") - set_target_properties(${LIB_NAME} PROPERTIES LINK_DEPENDS ${linker_script}) + ${LIB_TARGET_NAME} PRIVATE "-Wl,--version-script=${linker_script}") + set_target_properties(${LIB_TARGET_NAME} PROPERTIES LINK_DEPENDS ${linker_script}) endif() if (SYCL_ENABLE_XPTI_TRACING) - target_link_libraries(${LIB_NAME} PRIVATE ${CMAKE_DL_LIBS}) + target_link_libraries(${LIB_TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS}) endif() endif() @@ -198,7 +192,7 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) if(LINKER_SUPPORTS_WL_GC_SECTIONS) # Reduces the size of the resulting library by having the linker perform # garbage collection. - target_link_options(${LIB_NAME} PRIVATE -Wl,--gc-sections) + target_link_options(${LIB_TARGET_NAME} PRIVATE -Wl,--gc-sections) endif() if(SYCL_ENABLE_EXTENSION_JIT) @@ -208,18 +202,18 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) set(SYCL_JIT_INCLUDE_DIRS ${LLVM_EXTERNAL_SYCL_JIT_SOURCE_DIR}/common/include ${LLVM_EXTERNAL_SYCL_JIT_SOURCE_DIR}/jit-compiler/include) - add_dependencies(${LIB_NAME} sycl-jit) + add_dependencies(${LIB_TARGET_NAME} sycl-jit) add_dependencies(${LIB_OBJ_NAME} sycl-jit) target_include_directories(${LIB_OBJ_NAME} PRIVATE ${SYCL_JIT_INCLUDE_DIRS}) set_property(GLOBAL APPEND PROPERTY SYCL_TOOLCHAIN_INSTALL_COMPONENTS sycl-jit) - target_compile_definitions(${LIB_NAME} PRIVATE SYCL_EXT_JIT_ENABLE) + target_compile_definitions(${LIB_TARGET_NAME} PRIVATE SYCL_EXT_JIT_ENABLE) target_compile_definitions(${LIB_OBJ_NAME} PRIVATE SYCL_EXT_JIT_ENABLE) endif(SYCL_ENABLE_EXTENSION_JIT) - add_common_options(${LIB_NAME} ${LIB_OBJ_NAME}) + add_common_options(${LIB_TARGET_NAME} ${LIB_OBJ_NAME}) - set_target_properties(${LIB_NAME} PROPERTIES + set_target_properties(${LIB_TARGET_NAME} PROPERTIES VERSION ${SYCL_VERSION_STRING} SOVERSION ${SYCL_MAJOR_VERSION} # Set the runpath to the lib directory so libsycl can find libur_loader @@ -346,40 +340,6 @@ set(SYCL_NON_PREVIEW_SOURCES "${SYCL_COMMON_SOURCES}" set(SYCL_PREVIEW_SOURCES "${SYCL_COMMON_SOURCES}" ) -if (MSVC) - # MSVC provides two incompatible build variants for its CRT: release and debug - # To avoid potential issues in user code we also need to provide two kinds - # of SYCL Runtime Library for release and debug configurations. - foreach(flag_var - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - string(REGEX REPLACE "/MDd" "" ${flag_var} "${${flag_var}}") - string(REGEX REPLACE "/MTd" "" ${flag_var} "${${flag_var}}") - string(REGEX REPLACE "/MD" "" ${flag_var} "${${flag_var}}") - string(REGEX REPLACE "/MT" "" ${flag_var} "${${flag_var}}") - endforeach() - - set(WIN_DUPE "1") - if (SYCL_ENABLE_XPTI_TRACING) - add_sycl_rt_library(sycl${SYCL_MAJOR_VERSION}d sycld_object XPTI_LIB xptid COMPILE_OPTIONS "/MDd" SOURCES ${SYCL_NON_PREVIEW_SOURCES} IMPLIB_NAME sycld) - if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) - add_sycl_rt_library(sycl${SYCL_MAJOR_VERSION}-previewd sycl-previewd_object XPTI_LIB xptid COMPILE_OPTIONS "/MDd" "/D__INTEL_PREVIEW_BREAKING_CHANGES" SOURCES ${SYCL_PREVIEW_SOURCES} IMPLIB_NAME sycl-previewd) - endif() - else() - add_sycl_rt_library(sycl${SYCL_MAJOR_VERSION}d sycld_object COMPILE_OPTIONS "/MDd" SOURCES ${SYCL_NON_PREVIEW_SOURCES} IMPLIB_NAME sycld) - if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) - add_sycl_rt_library(sycl${SYCL_MAJOR_VERSION}-previewd sycl-previewd_object COMPILE_OPTIONS "/MDd" "/D__INTEL_PREVIEW_BREAKING_CHANGES" SOURCES ${SYCL_PREVIEW_SOURCES} IMPLIB_NAME sycl-previewd) - endif() - endif() - unset(WIN_DUPE) - add_library(sycld ALIAS sycl${SYCL_MAJOR_VERSION}d) - if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) - add_library(sycl-previewd ALIAS sycl${SYCL_MAJOR_VERSION}-previewd) - endif() - - set(SYCL_EXTRA_OPTS "/MD") -endif() - check_cxx_compiler_flag(-fsemantic-interposition HAS_SEMANTIC_INTERPOSITION_FLAG) if (HAS_SEMANTIC_INTERPOSITION_FLAG AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) # See https://github.com/llvm/llvm-project/issues/58295. @@ -387,32 +347,57 @@ if (HAS_SEMANTIC_INTERPOSITION_FLAG AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) endif() if (WIN32) -set(LIB_NAME "sycl${SYCL_MAJOR_VERSION}") + set(LIB_NAME "sycl${SYCL_MAJOR_VERSION}") + set(LIB_OUTPUT_NAME "${LIB_NAME}") + set(LIB_PREVIEW_NAME ${LIB_NAME}-preview) + set(LIB_PREVIEW_OUTPUT_NAME ${LIB_OUTPUT_NAME}-preview) + if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set(LIB_OUTPUT_NAME "${LIB_OUTPUT_NAME}d") + set(LIB_PREVIEW_OUTPUT_NAME ${LIB_PREVIEW_OUTPUT_NAME}d) + endif() else() -set(LIB_NAME "sycl") + set(LIB_NAME "sycl") + set(LIB_OUTPUT_NAME "${LIB_NAME}") + set(LIB_PREVIEW_NAME ${LIB_NAME}-preview) + set(LIB_PREVIEW_OUTPUT_NAME ${LIB_OUTPUT_NAME}-preview) endif() + # Version-agnostic name of the import library, has effect on Windows only. set(IMPLIB_NAME "sycl") +set(IMPLIB_PREVIEW_NAME "${IMPLIB_NAME}-preview") +if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set(IMPLIB_NAME "${IMPLIB_NAME}d") + set(IMPLIB_PREVIEW_NAME "${IMPLIB_PREVIEW_NAME}d") +endif() -if (SYCL_ENABLE_XPTI_TRACING) - add_sycl_rt_library(${LIB_NAME} sycl_object XPTI_LIB xpti COMPILE_OPTIONS ${SYCL_EXTRA_OPTS} SOURCES ${SYCL_NON_PREVIEW_SOURCES} IMPLIB_NAME ${IMPLIB_NAME}) - if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) - add_sycl_rt_library(${LIB_NAME}-preview sycl-preview_object XPTI_LIB xpti COMPILE_OPTIONS ${SYCL_EXTRA_OPTS} "-D__INTEL_PREVIEW_BREAKING_CHANGES" SOURCES ${SYCL_PREVIEW_SOURCES} IMPLIB_NAME ${IMPLIB_NAME}-preview) - endif() -else() - add_sycl_rt_library(${LIB_NAME} sycl_object COMPILE_OPTIONS ${SYCL_EXTRA_OPTS} SOURCES ${SYCL_NON_PREVIEW_SOURCES} IMPLIB_NAME ${IMPLIB_NAME}) - if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) - add_sycl_rt_library(${LIB_NAME}-preview sycl-preview_object COMPILE_OPTIONS ${SYCL_EXTRA_OPTS} "-D__INTEL_PREVIEW_BREAKING_CHANGES" SOURCES ${SYCL_PREVIEW_SOURCES} IMPLIB_NAME ${IMPLIB_NAME}-preview) - endif() +add_sycl_rt_library(${LIB_NAME} sycl_object ${LIB_OUTPUT_NAME} + XPTI_LIB xpti + COMPILE_OPTIONS ${SYCL_EXTRA_OPTS} + SOURCES ${SYCL_NON_PREVIEW_SOURCES} + IMPLIB_OUTPUT_NAME ${IMPLIB_NAME}) +if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) + add_sycl_rt_library(${LIB_PREVIEW_NAME} sycl-preview_object ${LIB_PREVIEW_OUTPUT_NAME} + XPTI_LIB xpti + COMPILE_OPTIONS ${SYCL_EXTRA_OPTS} "-D__INTEL_PREVIEW_BREAKING_CHANGES" + SOURCES ${SYCL_PREVIEW_SOURCES} + IMPLIB_OUTPUT_NAME ${IMPLIB_PREVIEW_NAME}) endif() -if (WIN32) +if (CMAKE_SYSTEM_NAME STREQUAL Windows) add_library(sycl ALIAS ${LIB_NAME}) if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) add_library(sycl-preview ALIAS sycl${SYCL_MAJOR_VERSION}-preview) endif() endif() +if (CMAKE_SYSTEM_NAME STREQUAL Windows AND + (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL)) + set_target_properties(sycl${SYCL_MAJOR_VERSION} PROPERTIES OUTPUT_NAME "sycl${SYCL_MAJOR_VERSION}d") + if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) + set_target_properties(sycl${SYCL_MAJOR_VERSION}-preview PROPERTIES OUTPUT_NAME "sycl${SYCL_MAJOR_VERSION}-previewd") + endif() +endif() + install(TARGETS ${SYCL_RT_LIBS} ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT sycl LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT sycl diff --git a/sycl/test-e2e/Basic/std_array.cpp b/sycl/test-e2e/Basic/std_array.cpp index 12a2fb05160e2..d387910d80a0a 100644 --- a/sycl/test-e2e/Basic/std_array.cpp +++ b/sycl/test-e2e/Basic/std_array.cpp @@ -1,6 +1,6 @@ // Check that std::array is supported on device in debug mode on Windows. -// REQUIRES: windows +// REQUIRES: windows && debug_sycl_library && build-mode && run-mode // RUN: %clangxx --driver-mode=cl -fsycl -o %t.exe %s /Od /MDd /Zi /EHsc // RUN: %{run} %t.exe diff --git a/sycl/test-e2e/README.md b/sycl/test-e2e/README.md index 159dbb8f2d3cc..9601a1e231aca 100644 --- a/sycl/test-e2e/README.md +++ b/sycl/test-e2e/README.md @@ -214,6 +214,9 @@ used. to specify the correct build target type for the available Offload device. Valid values are `target-nvidia` and `target-amd`. +***USE_DEBUG_LIBRARIES*** - enable the use of Windows debug libraries by setting +this to "ON". "OFF" by default. + ## Special test categories There are two special directories for extended testing. See documentation at: diff --git a/sycl/test-e2e/Regression/compile_on_win_with_mdd.cpp b/sycl/test-e2e/Regression/compile_on_win_with_mdd.cpp index 57826c81ece2e..d6506d205fff5 100644 --- a/sycl/test-e2e/Regression/compile_on_win_with_mdd.cpp +++ b/sycl/test-e2e/Regression/compile_on_win_with_mdd.cpp @@ -1,4 +1,4 @@ -// REQUIRES: windows +// REQUIRES: windows && debug_sycl_library && build-mode && run-mode // RUN: %clangxx --driver-mode=cl -fsycl /MDd -c %s -o %t.obj // RUN: %clangxx --driver-mode=cl -fsycl %t.obj -Wno-unused-command-line-argument -o %t.out @@ -9,6 +9,8 @@ // The failure happens if perform separate compile and link, and pass /MDd to // the compile line. In that case, user application will crash during launching // with abort() message. +// Note that building requires the Windows debug library to be present, so it is +// only run in full testing mode. #include diff --git a/sycl/test-e2e/Regression/msvc_crt.cpp b/sycl/test-e2e/Regression/msvc_crt.cpp index 9d59547e50d7b..1d07c9a26730f 100644 --- a/sycl/test-e2e/Regression/msvc_crt.cpp +++ b/sycl/test-e2e/Regression/msvc_crt.cpp @@ -1,7 +1,5 @@ -// RUN: %{build} /MD -o %t1.exe -// RUN: %{run} %t1.exe -// RUN: %{build} /MDd -o %t2.exe -// RUN: %{run} %t2.exe +// RUN: %{build} %if debug_sycl_library %{ /MDd %} %else %{ /MD %} -o %t.exe +// RUN: %{run} %t.exe // REQUIRES: system-windows, cl_options //==-------------- msvc_crt.cpp - SYCL MSVC CRT test -----------------------==// // diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 36e06223bdb7f..fc66ab327b9a3 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -333,6 +333,12 @@ def open_check_file(file_name): if ps.wait() == 0: config.available_features.add("has_ndebug") +# Check if the current build mode is debug. +if config.use_debug_libs: + config.available_features.add("debug_sycl_library") + # Add /MDd to the build command to make it use the debug library. + config.cxx_flags += " /MDd" if cl_options else " -fms-runtime-lib=dll_dbg" + # Check for Level Zero SDK check_l0_file = "l0_include.cpp" with open_check_file(check_l0_file) as fp: @@ -576,7 +582,13 @@ def open_check_file(file_name): ( "%sycl_options", " " - + os.path.normpath(os.path.join(config.sycl_libs_dir + "/../lib/sycl8.lib")) + + os.path.normpath( + os.path.join( + config.sycl_libs_dir + + "/../lib/" + + ("sycl8d.lib" if config.use_debug_libs else "sycl8.lib") + ) + ) + " -Xclang -isystem -Xclang " + config.sycl_include + " -Xclang -isystem -Xclang " @@ -594,7 +606,11 @@ def open_check_file(file_name): config.substitutions.append( ( "%sycl_options", - (" -lsycl8" if platform.system() == "Windows" else " -lsycl") + ( + (" -lsycl8d" if config.use_debug_libs else " -lsycl8") + if platform.system() == "Windows" + else " -lsycl" + ) + " -isystem " + config.sycl_include + " -isystem " @@ -794,9 +810,7 @@ def remove_level_zero_suffix(devices): xptifw_dispatcher = os.path.join(xptifw_lib_dir, "libxptifw.so") elif platform.system() == "Windows": # Use debug version of xptifw library if tests are built with \MDd. - xptifw_dispatcher_name = ( - XPTIFW_DEBUG if "/MDd" in config.cxx_flags else XPTIFW_RELEASE - ) + xptifw_dispatcher_name = XPTIFW_DEBUG if config.use_debug_libs else XPTIFW_RELEASE xptifw_dispatcher = os.path.join( config.dpcpp_root_dir, "bin", xptifw_dispatcher_name + ".dll" ) @@ -808,7 +822,7 @@ def remove_level_zero_suffix(devices): config.substitutions.append(("%xptifw_dispatcher", xptifw_dispatcher)) if cl_options: # Use debug version of xptifw library if tests are built with \MDd. - xptifw_lib_name = XPTIFW_DEBUG if "/MDd" in config.cxx_flags else XPTIFW_RELEASE + xptifw_lib_name = XPTIFW_DEBUG if config.use_debug_libs else XPTIFW_RELEASE xptifw_lib = os.path.normpath( os.path.join(xptifw_lib_dir, xptifw_lib_name + ".lib") ) diff --git a/sycl/test-e2e/lit.site.cfg.py.in b/sycl/test-e2e/lit.site.cfg.py.in index 8d45b7d762baf..065cee5beedbb 100644 --- a/sycl/test-e2e/lit.site.cfg.py.in +++ b/sycl/test-e2e/lit.site.cfg.py.in @@ -59,6 +59,8 @@ config.vulkan_include_dir = "@Vulkan_INCLUDE_DIRS@" config.vulkan_lib = "@Vulkan_LIBRARY@" config.vulkan_found = "@Vulkan_FOUND@" +config.use_debug_libs = ("@USE_DEBUG_LIBRARIES@" == "ON") + config.run_launcher = lit_config.params.get('run_launcher', "@SYCL_E2E_RUN_LAUNCHER@") config.allow_unknown_arch = "@SYCL_E2E_LIT_ALLOW_UNKNOWN_ARCH@" diff --git a/sycl/test/abi/preview_lib_marker.cpp b/sycl/test/abi/preview_lib_marker.cpp index 23ee1e87a8008..21a9e67781314 100644 --- a/sycl/test/abi/preview_lib_marker.cpp +++ b/sycl/test/abi/preview_lib_marker.cpp @@ -1,6 +1,6 @@ // DEFINE: %{checkprefix} = %if windows %{CHECK-NO-PREVIEW-WINDOWS%} %else %{CHECK-NO-PREVIEW-LINUX%} -// RUN: not %clangxx -fsycl %s -o %t 2>&1 | FileCheck --check-prefix=%{checkprefix} %s -// RUN: %clangxx -fsycl -fpreview-breaking-changes %s -o %t +// RUN: not %clangxx %fsycl %s -o %t 2>&1 | FileCheck --check-prefix=%{checkprefix} %s +// RUN: %clangxx %fsycl -fpreview-breaking-changes %s -o %t // REQUIRES: preview-breaking-changes-supported // Checks that the preview-breaking-changes marker is present only when the diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index 8eed8b8dba437..51ca4d6ee13ea 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -3,7 +3,7 @@ # DO NOT EDIT IT MANUALLY. Refer to sycl/doc/developer/ABIPolicyGuide.md for more info. ################################################################################ -# RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir %python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %s %llvm_build_bin_dir/sycl8.dll +# RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir %python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %s %if debug_sycl_library %{ %llvm_build_bin_dir/sycl8d.dll %} %else %{ %llvm_build_bin_dir/sycl8.dll %} # REQUIRES: windows # UNSUPPORTED: libcxx diff --git a/sycl/test/abi/symbol_size_alignment.cpp b/sycl/test/abi/symbol_size_alignment.cpp index 63286da1b9786..ed4c6770f1cbe 100644 --- a/sycl/test/abi/symbol_size_alignment.cpp +++ b/sycl/test/abi/symbol_size_alignment.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %s -D__SYCL_INTERNAL_API -o %t +// RUN: %clangxx %fsycl %s -D__SYCL_INTERNAL_API -o %t // UNSUPPORTED: libcxx // Changing symbol size or alignment is a breaking change. If it happens, refer diff --git a/sycl/test/basic_tests/accessor/accessor_default_ctor.cpp b/sycl/test/basic_tests/accessor/accessor_default_ctor.cpp index a4bc1b90ed6f8..11edc82878bb5 100644 --- a/sycl/test/basic_tests/accessor/accessor_default_ctor.cpp +++ b/sycl/test/basic_tests/accessor/accessor_default_ctor.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-targets=%sycl_triple %s -o %t.out // RUN: %t.out #include diff --git a/sycl/test/basic_tests/accessor/accessor_property_list_rt.cpp b/sycl/test/basic_tests/accessor/accessor_property_list_rt.cpp index 2c28b0bc4a4cf..51d4d11f83985 100644 --- a/sycl/test/basic_tests/accessor/accessor_property_list_rt.cpp +++ b/sycl/test/basic_tests/accessor/accessor_property_list_rt.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-targets=%sycl_triple %s -o %t.out // RUN: %t.out #include diff --git a/sycl/test/basic_tests/accessor/host-acc-assign-op.cpp b/sycl/test/basic_tests/accessor/host-acc-assign-op.cpp index 37ff0aa3da6a0..cf9da44cc1e86 100644 --- a/sycl/test/basic_tests/accessor/host-acc-assign-op.cpp +++ b/sycl/test/basic_tests/accessor/host-acc-assign-op.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-targets=%sycl_triple %s -o %t.out // RUN: %t.out // XFAIL: libcxx diff --git a/sycl/test/basic_tests/accessor/target_device.cpp b/sycl/test/basic_tests/accessor/target_device.cpp index 09b6d0524c38c..69291be8d37d3 100644 --- a/sycl/test/basic_tests/accessor/target_device.cpp +++ b/sycl/test/basic_tests/accessor/target_device.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-targets=%sycl_triple %s -o %t.out // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/basic_tests/builtins/relational_builtins.cpp b/sycl/test/basic_tests/builtins/relational_builtins.cpp index 035a54fda2b46..8da1d8fdb9618 100644 --- a/sycl/test/basic_tests/builtins/relational_builtins.cpp +++ b/sycl/test/basic_tests/builtins/relational_builtins.cpp @@ -1,5 +1,5 @@ -// RUN: %clangxx -fsycl %s -o %t.out -// RUN: %if preview-breaking-changes-supported %{ %clangxx -fsycl -fpreview-breaking-changes %s -o %t.out %} +// RUN: %clangxx %fsycl %s -o %t.out +// RUN: %if preview-breaking-changes-supported %{ %clangxx %fsycl -fpreview-breaking-changes %s -o %t.out %} // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/basic_tests/code_location.cpp b/sycl/test/basic_tests/code_location.cpp index bafea8b4d6a0d..ee1cb4dcb1650 100644 --- a/sycl/test/basic_tests/code_location.cpp +++ b/sycl/test/basic_tests/code_location.cpp @@ -1,6 +1,6 @@ -// RUN: %clangxx -fsycl -DNDEBUG %s -o %t.out +// RUN: %clangxx %fsycl -DNDEBUG %s -o %t.out // RUN: %t.out -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx %fsycl %s -o %t.out // RUN: %t.out #include diff --git a/sycl/test/basic_tests/device-selectors-exception.cpp b/sycl/test/basic_tests/device-selectors-exception.cpp index b978623b1cd45..b665c3f2fb7a6 100644 --- a/sycl/test/basic_tests/device-selectors-exception.cpp +++ b/sycl/test/basic_tests/device-selectors-exception.cpp @@ -1,6 +1,6 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-targets=%sycl_triple %s -o %t.out // RUN: env SYCL_DEVICE_FILTER="" %t.out -// RUN: %if preview-breaking-changes-supported %{ %clangxx -fsycl -fsycl-targets=%sycl_triple -fpreview-breaking-changes %s -o %t.out %} +// RUN: %if preview-breaking-changes-supported %{ %clangxx %fsycl -fsycl-targets=%sycl_triple -fpreview-breaking-changes %s -o %t.out %} // ONEAPI_DEVICE_SELECTOR="*:-1" causes this test to not select any device at // all. // RUN: %if preview-breaking-changes-supported %{ env ONEAPI_DEVICE_SELECTOR="*:-1" %t.out %} diff --git a/sycl/test/basic_tests/device_config_file_aspects.cpp b/sycl/test/basic_tests/device_config_file_aspects.cpp index 90c23d9ef593c..8526a4c014436 100644 --- a/sycl/test/basic_tests/device_config_file_aspects.cpp +++ b/sycl/test/basic_tests/device_config_file_aspects.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %s -o %t.out -I %llvm_main_include_dir +// RUN: %clangxx %fsycl %s -o %t.out -I %llvm_main_include_dir // RUN: %t.out // #include diff --git a/sycl/test/basic_tests/group.cpp b/sycl/test/basic_tests/group.cpp index ff811dfe60b91..d1f25144ce7d9 100644 --- a/sycl/test/basic_tests/group.cpp +++ b/sycl/test/basic_tests/group.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-targets=%sycl_triple %s -o %t.out // RUN: %t.out // XFAIL: libcxx diff --git a/sycl/test/basic_tests/host_image_accessor_read.cpp b/sycl/test/basic_tests/host_image_accessor_read.cpp index c79247c0bcec1..b31886b68f1fc 100644 --- a/sycl/test/basic_tests/host_image_accessor_read.cpp +++ b/sycl/test/basic_tests/host_image_accessor_read.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx %fsycl %s -o %t.out // RUN: %t.out // XFAIL: libcxx diff --git a/sycl/test/basic_tests/id.cpp b/sycl/test/basic_tests/id.cpp index 3c24a22dfea85..c71a3e34d466e 100644 --- a/sycl/test/basic_tests/id.cpp +++ b/sycl/test/basic_tests/id.cpp @@ -1,6 +1,6 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-targets=%sycl_triple %s -o %t.out // RUN: %t.out -// RUN: %clangxx -D__SYCL_DISABLE_ID_TO_INT_CONV__ -fsycl %s -o %t_dis.out +// RUN: %clangxx -D__SYCL_DISABLE_ID_TO_INT_CONV__ %fsycl %s -o %t_dis.out // RUN: %t_dis.out // XFAIL: libcxx diff --git a/sycl/test/basic_tests/item.cpp b/sycl/test/basic_tests/item.cpp index 0fb7f8e31409a..c9ee8d46f25cf 100644 --- a/sycl/test/basic_tests/item.cpp +++ b/sycl/test/basic_tests/item.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-targets=%sycl_triple %s -o %t.out // RUN: %t.out // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/basic_tests/marray/marray.cpp b/sycl/test/basic_tests/marray/marray.cpp index b48fe70f17520..153ada7db2e2e 100644 --- a/sycl/test/basic_tests/marray/marray.cpp +++ b/sycl/test/basic_tests/marray/marray.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx %fsycl %s -o %t.out // RUN: %t.out //==--------------- marray.cpp - SYCL marray test --------------------------==// diff --git a/sycl/test/basic_tests/nd_range.cpp b/sycl/test/basic_tests/nd_range.cpp index 39e1479f31481..a033bdf420396 100644 --- a/sycl/test/basic_tests/nd_range.cpp +++ b/sycl/test/basic_tests/nd_range.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-targets=%sycl_triple %s -o %t.out // RUN: %t.out //==--------------- nd_range.cpp - SYCL nd_range test ----------------------==// // diff --git a/sycl/test/basic_tests/range.cpp b/sycl/test/basic_tests/range.cpp index 49b557b4ea056..625142d7d3efb 100644 --- a/sycl/test/basic_tests/range.cpp +++ b/sycl/test/basic_tests/range.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-targets=%sycl_triple %s -o %t.out // RUN: %t.out // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/basic_tests/sycl_maximum_minimum.cpp b/sycl/test/basic_tests/sycl_maximum_minimum.cpp index dd88701ecce99..0bba28fc8488d 100644 --- a/sycl/test/basic_tests/sycl_maximum_minimum.cpp +++ b/sycl/test/basic_tests/sycl_maximum_minimum.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx %fsycl %s -o %t.out // RUN: %t.out #include diff --git a/sycl/test/basic_tests/temp-assign-guard.cpp b/sycl/test/basic_tests/temp-assign-guard.cpp index 6e1c823d89c4a..35d81cc49f2df 100644 --- a/sycl/test/basic_tests/temp-assign-guard.cpp +++ b/sycl/test/basic_tests/temp-assign-guard.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx %fsycl %s -o %t.out // RUN: %t.out #include diff --git a/sycl/test/basic_tests/vectors/size_one_checks.cpp b/sycl/test/basic_tests/vectors/size_one_checks.cpp index c1dbb7bfa20e0..c856054f6f554 100644 --- a/sycl/test/basic_tests/vectors/size_one_checks.cpp +++ b/sycl/test/basic_tests/vectors/size_one_checks.cpp @@ -1,6 +1,6 @@ -// RUN: %clangxx -fsycl %s -o %t_default.out +// RUN: %clangxx %fsycl %s -o %t_default.out // RUN: %t_default.out -// RUN: %if preview-breaking-changes-supported %{ %clangxx -fsycl -fpreview-breaking-changes %s -o %t_vec.out %} +// RUN: %if preview-breaking-changes-supported %{ %clangxx %fsycl -fpreview-breaking-changes %s -o %t_vec.out %} // RUN: %if preview-breaking-changes-supported %{ %t_vec.out %} #include diff --git a/sycl/test/basic_tests/vectors/swizzle.cpp b/sycl/test/basic_tests/vectors/swizzle.cpp index 4de5fde499c5c..9b897425fefbe 100644 --- a/sycl/test/basic_tests/vectors/swizzle.cpp +++ b/sycl/test/basic_tests/vectors/swizzle.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %s -o %t_default.out +// RUN: %clangxx %fsycl %s -o %t_default.out // RUN: %t_default.out #include diff --git a/sycl/test/basic_tests/vectors/vectors.cpp b/sycl/test/basic_tests/vectors/vectors.cpp index 9ef5dcae5bf63..073b8595a3a39 100644 --- a/sycl/test/basic_tests/vectors/vectors.cpp +++ b/sycl/test/basic_tests/vectors/vectors.cpp @@ -1,6 +1,6 @@ -// RUN: %clangxx -fsycl %s -o %t_default.out +// RUN: %clangxx %fsycl %s -o %t_default.out // RUN: %t_default.out -// RUN: %if preview-breaking-changes-supported %{ %clangxx -fsycl -fpreview-breaking-changes %s -o %t_vec.out %} +// RUN: %if preview-breaking-changes-supported %{ %clangxx %fsycl -fpreview-breaking-changes %s -o %t_vec.out %} // RUN: %if preview-breaking-changes-supported %{ %t_vec.out %} // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/esimd/odr.cpp b/sycl/test/esimd/odr.cpp index 42716c1ec61c0..61cd9c8f376ee 100644 --- a/sycl/test/esimd/odr.cpp +++ b/sycl/test/esimd/odr.cpp @@ -6,9 +6,9 @@ // // CUDA/HIP do not support intrinsics generated by the ESIMD compilation path: // -// RUN: %clangxx -fsycl -fsycl-targets=spir64-unknown-unknown -DSOURCE1 -c %s -o %t1.o -// RUN: %clangxx -fsycl -fsycl-targets=spir64-unknown-unknown -DSOURCE2 -c %s -o %t2.o -// RUN: %clangxx -fsycl -fsycl-targets=spir64-unknown-unknown %t1.o %t2.o -o %t.exe +// RUN: %clangxx %fsycl -fsycl-targets=spir64-unknown-unknown -DSOURCE1 -c %s -o %t1.o +// RUN: %clangxx %fsycl -fsycl-targets=spir64-unknown-unknown -DSOURCE2 -c %s -o %t2.o +// RUN: %clangxx %fsycl -fsycl-targets=spir64-unknown-unknown %t1.o %t2.o -o %t.exe // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/extensions/device_architecture/device_architecture.cpp b/sycl/test/extensions/device_architecture/device_architecture.cpp index c28b4006c89be..b6fff5193ea15 100644 --- a/sycl/test/extensions/device_architecture/device_architecture.cpp +++ b/sycl/test/extensions/device_architecture/device_architecture.cpp @@ -3,7 +3,7 @@ // During binary run there are some errors, this is expected, so there is no run // line yet for this test. -// RUN: %clangxx -fsycl -DSYCL_EXT_ONEAPI_DEVICE_ARCHITECTURE_NEW_DESIGN_IMPL %s -o %t.out +// RUN: %clangxx %fsycl -DSYCL_EXT_ONEAPI_DEVICE_ARCHITECTURE_NEW_DESIGN_IMPL %s -o %t.out // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/extensions/properties/properties_get_property.cpp b/sycl/test/extensions/properties/properties_get_property.cpp index 2827be58a6196..00cf98f9d7c96 100644 --- a/sycl/test/extensions/properties/properties_get_property.cpp +++ b/sycl/test/extensions/properties/properties_get_property.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-targets=%sycl_triple %s -o %t.out // RUN: %t.out #include diff --git a/sycl/test/invoke_simd/return-type-uniform.cpp b/sycl/test/invoke_simd/return-type-uniform.cpp index 6f22c5d6e0818..5f43de48e0613 100644 --- a/sycl/test/invoke_simd/return-type-uniform.cpp +++ b/sycl/test/invoke_simd/return-type-uniform.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fno-sycl-device-code-split-esimd -Xclang -fsycl-allow-func-ptr %s -o /dev/null +// RUN: %clangxx %fsycl -fno-sycl-device-code-split-esimd -Xclang -fsycl-allow-func-ptr %s -o /dev/null // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index 4ebe0b06ff040..e64932ed0b9de 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -69,6 +69,10 @@ if config.sycl_preview_lib_enabled == "ON": config.available_features.add("preview-breaking-changes-supported") +# Check if the current build mode is debug. +if config.use_debug_win_crt: + config.available_features.add("debug_sycl_library") + # Configure LD_LIBRARY_PATH or corresponding os-specific alternatives # Add 'libcxx' feature to filter out all SYCL abi tests when SYCL runtime # is built with llvm libcxx. This feature is added for Linux only since MSVC @@ -137,9 +141,18 @@ sycl_host_only_options += " -isystem %s" % include_dir config.substitutions.append(("%fsycl-host-only", sycl_host_only_options)) -config.substitutions.append( - ("%sycl_lib", " -lsycl8" if platform.system() == "Windows" else "-lsycl") -) +fsycl_opt = "-fsycl" +if platform.system() == "Windows": + config.substitutions.append( + ("%sycl_lib", " -lsycl8d" if config.use_debug_win_crt else " -lsycl8") + ) + if config.use_debug_win_crt: + # If using debug CRT we need to build SYCL programs in debug to link + # with the right library. + fsycl_opt = fsycl_opt + " -Xclang --dependent-lib=msvcrtd" +else: + config.substitutions.append(("%sycl_lib", "-lsycl")) +config.substitutions.append(("%fsycl", fsycl_opt)) llvm_config.add_tool_substitutions(["llvm-spirv"], [config.sycl_tools_dir]) diff --git a/sycl/test/lit.site.cfg.py.in b/sycl/test/lit.site.cfg.py.in index 2d74880f2ff8a..76f15a91eee70 100644 --- a/sycl/test/lit.site.cfg.py.in +++ b/sycl/test/lit.site.cfg.py.in @@ -36,6 +36,8 @@ config.native_cpu = '@SYCL_BUILD_BACKEND_NATIVE_CPU@' config.native_cpu_ock = '@NATIVECPU_USE_OCK@' config.sycl_preview_lib_enabled = '@SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB@' +config.use_debug_win_crt = '@CMAKE_BUILD_TYPE@' == "Debug" or '@CMAKE_MSVC_RUNTIME_LIBRARY@' == 'MultiThreadedDebugDLL' + import lit.llvm lit.llvm.initialize(lit_config, config) diff --git a/sycl/test/matrix/compile-query.cpp b/sycl/test/matrix/compile-query.cpp index 85dfefb6a2916..c4c8a4492ed2e 100644 --- a/sycl/test/matrix/compile-query.cpp +++ b/sycl/test/matrix/compile-query.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -o compile-query %s +// RUN: %clangxx %fsycl -o compile-query %s #include #include diff --git a/sycl/test/matrix/matrix-bfloat16-test-coord-basicB.cpp b/sycl/test/matrix/matrix-bfloat16-test-coord-basicB.cpp index 52c96dcb1cad1..d6327f6b556d8 100644 --- a/sycl/test/matrix/matrix-bfloat16-test-coord-basicB.cpp +++ b/sycl/test/matrix/matrix-bfloat16-test-coord-basicB.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -O2 %s -o %t.out +// RUN: %clangxx %fsycl -O2 %s -o %t.out // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/matrix/matrix-bfloat16-test.cpp b/sycl/test/matrix/matrix-bfloat16-test.cpp index abdf249f71a29..fe383cc4a18ef 100644 --- a/sycl/test/matrix/matrix-bfloat16-test.cpp +++ b/sycl/test/matrix/matrix-bfloat16-test.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -O2 %s -o %t.out +// RUN: %clangxx %fsycl -O2 %s -o %t.out // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/matrix/matrix-elemwise-ops.cpp b/sycl/test/matrix/matrix-elemwise-ops.cpp index 64fec8ba2e048..19a3871ce755d 100644 --- a/sycl/test/matrix/matrix-elemwise-ops.cpp +++ b/sycl/test/matrix/matrix-elemwise-ops.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -O2 %s -o %t.out +// RUN: %clangxx %fsycl -O2 %s -o %t.out // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/matrix/matrix-tf32-test.cpp b/sycl/test/matrix/matrix-tf32-test.cpp index 040d9437401e8..ab54828ab11c3 100644 --- a/sycl/test/matrix/matrix-tf32-test.cpp +++ b/sycl/test/matrix/matrix-tf32-test.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -O2 %s -o %t.out +// RUN: %clangxx %fsycl -O2 %s -o %t.out // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/regression/abs_diff_host.cpp b/sycl/test/regression/abs_diff_host.cpp index 6bbe129ce8349..f2f3f9bb2b27b 100644 --- a/sycl/test/regression/abs_diff_host.cpp +++ b/sycl/test/regression/abs_diff_host.cpp @@ -1,6 +1,6 @@ -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx %fsycl %s -o %t.out // RUN: %t.out -// RUN: %if preview-breaking-changes-supported %{ %clangxx -fsycl -fpreview-breaking-changes %s -o %t2.out %} +// RUN: %if preview-breaking-changes-supported %{ %clangxx %fsycl -fpreview-breaking-changes %s -o %t2.out %} // RUN: %if preview-breaking-changes-supported %{ %t2.out %} // Test checks that sycl::abs_diff correctly handles signed operations that diff --git a/sycl/test/regression/atomic_ref_assignment_ambiguity.cpp b/sycl/test/regression/atomic_ref_assignment_ambiguity.cpp index bfececed25a27..c2d5279f7a00b 100644 --- a/sycl/test/regression/atomic_ref_assignment_ambiguity.cpp +++ b/sycl/test/regression/atomic_ref_assignment_ambiguity.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx %fsycl %s -o %t.out // Tests that the assignment operator on atomic_ref for pointers do not cause // overload resolution ambiguities. diff --git a/sycl/test/regression/bit_cast_win.cpp b/sycl/test/regression/bit_cast_win.cpp index f535634b15522..f2386b0ca61a0 100644 --- a/sycl/test/regression/bit_cast_win.cpp +++ b/sycl/test/regression/bit_cast_win.cpp @@ -1,4 +1,5 @@ -// RUN: %clangxx -fsycl -fsycl-host-compiler=cl -fsycl-host-compiler-options='/std:c++17 /Zc:__cplusplus' %s -o %t.out +// DEFINE: %{md_flag} = %if debug_sycl_library %{/MD%} %else %{/MDd%} +// RUN: %clangxx %fsycl -fsycl-host-compiler=cl -fsycl-host-compiler-options='/std:c++17 /Zc:__cplusplus %{md_flag}' %s -o %t.out // UNSUPPORTED: linux #include "bit_cast.hpp" diff --git a/sycl/test/regression/check_config_processing.cpp b/sycl/test/regression/check_config_processing.cpp index baa1c6e4d9f48..561d2441e31dc 100644 --- a/sycl/test/regression/check_config_processing.cpp +++ b/sycl/test/regression/check_config_processing.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx %fsycl %s -o %t.out // // RUN: env TEST=SET_CORRECT_ENVIRONMENT %t.out > %t.conf // RUN: env TEST=CORRECT_CONFIG_FILE env SYCL_CONFIG_FILE_NAME=%t.conf %t.out diff --git a/sycl/test/regression/fsycl-save-temps.cpp b/sycl/test/regression/fsycl-save-temps.cpp index 4718d0d713e77..f692e22b6534b 100644 --- a/sycl/test/regression/fsycl-save-temps.cpp +++ b/sycl/test/regression/fsycl-save-temps.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// // Verify that a sample compilation succeeds with -save-temps -// RUN: %clangxx -fsycl -save-temps %s -o %t.out +// RUN: %clangxx %fsycl -save-temps %s -o %t.out // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 diff --git a/sycl/test/regression/half_host_subnormal_min.cpp b/sycl/test/regression/half_host_subnormal_min.cpp index f0e0405e879dd..a6e9910e220b9 100644 --- a/sycl/test/regression/half_host_subnormal_min.cpp +++ b/sycl/test/regression/half_host_subnormal_min.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx %fsycl %s -o %t.out // RUN: %t.out // // Checks that sycl::half on host can correctly cast its minimum subnormal value diff --git a/sycl/test/regression/host_half_nextafter.cpp b/sycl/test/regression/host_half_nextafter.cpp index fe9bf949c65e3..58e4a5e10d893 100644 --- a/sycl/test/regression/host_half_nextafter.cpp +++ b/sycl/test/regression/host_half_nextafter.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx %fsycl %s -o %t.out // RUN: %t.out // // Checks that sycl::nextafter with sycl::half on host correctly converts based diff --git a/sycl/test/regression/host_tanpi_double_accuracy.cpp b/sycl/test/regression/host_tanpi_double_accuracy.cpp index d84a391b36e6a..9671b96657a7d 100644 --- a/sycl/test/regression/host_tanpi_double_accuracy.cpp +++ b/sycl/test/regression/host_tanpi_double_accuracy.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx %fsycl %s -o %t.out // RUN: %t.out // // Checks that sycl::tanpi with double has the accuracy required by the diff --git a/sycl/test/regression/memcpy-in-vec-as.cpp b/sycl/test/regression/memcpy-in-vec-as.cpp index 19da300696242..b5f6910606e53 100644 --- a/sycl/test/regression/memcpy-in-vec-as.cpp +++ b/sycl/test/regression/memcpy-in-vec-as.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -D_FORTIFY_SOURCE=2 %s -o %t.out +// RUN: %clangxx %fsycl -D_FORTIFY_SOURCE=2 %s -o %t.out // XFAIL: libcxx // XFAIL-TRACKER: https://github.com/intel/llvm/issues/19616 #include diff --git a/sycl/test/regression/std_array_vec_constructor.cpp b/sycl/test/regression/std_array_vec_constructor.cpp index 9b84e552767f9..5560b566c7edb 100644 --- a/sycl/test/regression/std_array_vec_constructor.cpp +++ b/sycl/test/regression/std_array_vec_constructor.cpp @@ -1,8 +1,8 @@ // Test to isolate sycl::vec bug due to use of std::array in // the constructor. -// REQUIRES: windows +// REQUIRES: windows && debug_sycl_library -// RUN: %clangxx -O0 -fsycl -D_DEBUG -shared %s -nostdlib -Xclang --dependent-lib=msvcrtd -fms-runtime-lib=dll_dbg +// RUN: %clangxx -O0 %fsycl -D_DEBUG -shared %s -nostdlib -Xclang --dependent-lib=msvcrtd -fms-runtime-lib=dll_dbg #include diff --git a/sycl/test/scheduler/GetWaitList.cpp b/sycl/test/scheduler/GetWaitList.cpp index 37727c0790868..f34210c833ba1 100644 --- a/sycl/test/scheduler/GetWaitList.cpp +++ b/sycl/test/scheduler/GetWaitList.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -I %sycl_source_dir %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-targets=%sycl_triple -I %sycl_source_dir %s -o %t.out // RUN: %t.out //==------------------- GetWaitList.cpp ----------------------------==// // diff --git a/sycl/test/win_ucrt/lit.local.cfg b/sycl/test/win_ucrt/lit.local.cfg new file mode 100644 index 0000000000000..38b99a9a37f14 --- /dev/null +++ b/sycl/test/win_ucrt/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = [".py"] diff --git a/sycl/test/win_ucrt/ucrt_check.py b/sycl/test/win_ucrt/ucrt_check.py new file mode 100644 index 0000000000000..2314c0267e5e7 --- /dev/null +++ b/sycl/test/win_ucrt/ucrt_check.py @@ -0,0 +1,58 @@ +# REQUIRES: windows +# RUN: %python %s %llvm_build_bin_dir +# +# Check for Windows URCT dependencies in library files in a specified path. If a +# library uses a the debug URCT it must be postfixed with "d". +# +import argparse +import os +import subprocess +import sys + + +# Some libraries are excluded from the check: +# * OpenCL.dll: The OpenCL ICD loader is ignored as it is generally not part of +# the compiler release packages. +exclude_list = {"OpenCL.dll"} + + +def check_file(filepath): + filename, file_ext = os.path.splitext(entry.name) + + # Only consider .dll or .lib files. + if not (file_ext == ".dll" or file_ext == ".lib"): + return 0 + + has_debug_postfix = filename.endswith("d") + dep_output = subprocess.run( + ["dumpbin", "/dependents", filepath], shell=False, capture_output=True + ) + + if str(dep_output.stdout).find("ucrtbased.dll") != -1: + if not has_debug_postfix: + print("Unexpected use of ucrtbased.dll:", filepath) + return 1 + elif str(dep_output.stdout).find("ucrtbase.dll") != -1: + if has_debug_postfix: + print("Unexpected use of ucrtbase.dll:", filepath) + return 1 + elif str(dep_output.stdout).find("api-ms-win-crt-") != -1: + if has_debug_postfix: + print("Unexpected use of api-ms-win-crt-*.dll: ", filepath) + return 1 + return 0 + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Windows UCRT checker utility.") + parser.add_argument("target_path", type=str) + args = parser.parse_args() + + # Scan the path for library files. + failures = 0 + with os.scandir(args.target_path) as it: + for entry in it: + if entry.is_file(): + failures += check_file(entry.name) + if failures > 0: + exit(failures) diff --git a/sycl/tools/sycl-ls/CMakeLists.txt b/sycl/tools/sycl-ls/CMakeLists.txt index a1cb33c6553b2..8afc547d4a9ce 100644 --- a/sycl/tools/sycl-ls/CMakeLists.txt +++ b/sycl/tools/sycl-ls/CMakeLists.txt @@ -2,12 +2,6 @@ add_executable(sycl-ls sycl-ls.cpp) add_dependencies(sycl-ls sycl) target_include_directories(sycl-ls PRIVATE "${sycl_inc_dir}") -set(sycl_lib sycl) -string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower) -if (WIN32 AND "${build_type_lower}" MATCHES "debug") - set(sycl_lib sycld) -endif() - # Disable aspect::image & deprecation warnings. target_compile_definitions(sycl-ls PRIVATE @@ -18,7 +12,7 @@ target_compile_definitions(sycl-ls target_link_libraries(sycl-ls PRIVATE - ${sycl_lib} + sycl UnifiedRuntime-Headers ) if (WIN32) diff --git a/sycl/ur_win_proxy_loader/CMakeLists.txt b/sycl/ur_win_proxy_loader/CMakeLists.txt index 940fcd28299e7..9f6e51dcb1ed5 100644 --- a/sycl/ur_win_proxy_loader/CMakeLists.txt +++ b/sycl/ur_win_proxy_loader/CMakeLists.txt @@ -12,58 +12,19 @@ set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc "RC_COPYRIGHT=\"Copyright (C) 2023 Intel Corporation\"") configure_file(../../llvm/resources/windows_version_resource.rc ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc @ONLY) add_library(ur_win_proxy_loader SHARED ur_win_proxy_loader.cpp ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc) +if (CMAKE_SYSTEM_NAME STREQUAL Windows AND + (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL)) + set_target_properties(ur_win_proxy_loader PROPERTIES OUTPUT_NAME "ur_win_proxy_loaderd") + target_compile_definitions(ur_win_proxy_loader PRIVATE UR_WIN_PROXY_LOADER_DEBUG_POSTFIX) +endif() add_dependencies(ur_win_proxy_loader UnifiedRuntimeLoader) install(TARGETS ur_win_proxy_loader RUNTIME DESTINATION "bin" COMPONENT ur_win_proxy_loader ) if (MSVC) - # MSVC provides two incompatible build variants for its CRT: release and debug - # To avoid potential issues in user code we also need to provide two kinds - # of SYCL Runtime Library for release and debug configurations. - set(WINUNLOAD_CXX_FLAGS "") - if (CMAKE_BUILD_TYPE MATCHES "Debug") - set(WINUNLOAD_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/MDd" "" WINUNLOAD_CXX_FLAGS "${WINUNLOAD_CXX_FLAGS}") - string(REPLACE "/MTd" "" WINUNLOAD_CXX_FLAGS "${WINUNLOAD_CXX_FLAGS}") - else() - if (CMAKE_BUILD_TYPE MATCHES "Release") - set(WINUNLOAD_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}") - elseif (CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo") - set(WINUNLOAD_CXX_FLAGS "${CMAKE_CXX_FLAGS_MINSIZEREL}") - elseif (CMAKE_BUILD_TYPE MATCHES "MinSizeRel") - set(WINUNLOAD_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") - endif() - string(REPLACE "/MD" "" WINUNLOAD_CXX_FLAGS "${WINUNLOAD_CXX_FLAGS}") - string(REPLACE "/MT" "" WINUNLOAD_CXX_FLAGS "${WINUNLOAD_CXX_FLAGS}") - endif() - - # target_compile_options requires list of options, not a string - string(REPLACE " " ";" WINUNLOAD_CXX_FLAGS "${WINUNLOAD_CXX_FLAGS}") - - set(WINUNLOAD_CXX_FLAGS_RELEASE "${WINUNLOAD_CXX_FLAGS};/MD") - set(WINUNLOAD_CXX_FLAGS_DEBUG "${WINUNLOAD_CXX_FLAGS};/MDd") - - # CMake automatically applies these flags to all targets. To override this - # behavior, options lists are reset. - set(CMAKE_CXX_FLAGS_RELEASE "") - set(CMAKE_CXX_FLAGS_MINSIZEREL "") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "") - set(CMAKE_CXX_FLAGS_DEBUG "") - - # Handle the debug version for the Microsoft compiler as a special case by - # creating a debug version of the static library that uses the flags used by - # the SYCL runtime - add_library(ur_win_proxy_loaderd SHARED ur_win_proxy_loader.cpp ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc) - target_compile_options(ur_win_proxy_loaderd PRIVATE ${WINUNLOAD_CXX_FLAGS_DEBUG}) - target_compile_options(ur_win_proxy_loader PRIVATE ${WINUNLOAD_CXX_FLAGS_RELEASE}) - target_compile_definitions(ur_win_proxy_loaderd PRIVATE UR_WIN_PROXY_LOADER_DEBUG) - target_link_libraries(ur_win_proxy_loaderd PRIVATE shlwapi) target_link_libraries(ur_win_proxy_loader PRIVATE shlwapi) # 0x2000: LOAD_LIBRARY_SAFE_CURRENT_DIRS flag. Using this flag means that loading dependency DLLs # from the current directory is only allowed if it is under a directory in the Safe load list. - target_link_options(ur_win_proxy_loaderd PRIVATE LINKER:/DEPENDENTLOADFLAG:0x2000) target_link_options(ur_win_proxy_loader PRIVATE LINKER:/DEPENDENTLOADFLAG:0x2000) - install(TARGETS ur_win_proxy_loaderd - RUNTIME DESTINATION "bin" COMPONENT ur_win_proxy_loader) endif() diff --git a/unified-runtime/CMakeLists.txt b/unified-runtime/CMakeLists.txt index 9115f52617c4f..0fa71fb21c1fd 100644 --- a/unified-runtime/CMakeLists.txt +++ b/unified-runtime/CMakeLists.txt @@ -67,7 +67,6 @@ set(UR_CONFORMANCE_TARGET_TRIPLES "" CACHE STRING "List of sycl targets to build CTS device binaries for") set(UR_CONFORMANCE_AMD_ARCH "" CACHE STRING "AMD device target ID to build CTS binaries for") set(UR_CONFORMANCE_SELECTOR "" CACHE STRING "If nonempty, the device selector for conformance tests") -option(UR_USE_DEBUG_POSTFIX "Enable debug postfix 'd' for libraries" OFF) set(UR_ADAPTER_LEVEL_ZERO_SOURCE_DIR "" CACHE PATH "Path to external 'level_zero' adapter source dir") set(UR_ADAPTER_OPENCL_SOURCE_DIR "" CACHE PATH @@ -224,11 +223,7 @@ if(UR_ENABLE_TRACING) endif() endif() - if (MSVC) - set(TARGET_XPTI $,xpti,xptid>) - else() - set(TARGET_XPTI xpti) - endif() + set(TARGET_XPTI xpti) endif() if(UR_ENABLE_SANITIZER) diff --git a/unified-runtime/cmake/FetchLevelZero.cmake b/unified-runtime/cmake/FetchLevelZero.cmake index 7997e99c6964f..caf2dff75ca8e 100644 --- a/unified-runtime/cmake/FetchLevelZero.cmake +++ b/unified-runtime/cmake/FetchLevelZero.cmake @@ -57,9 +57,6 @@ if(NOT LEVEL_ZERO_LIB_NAME AND NOT LEVEL_ZERO_LIBRARY) # Prevent L0 loader from exporting extra symbols set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF) - set(CMAKE_MSVC_RUNTIME_LIBRARY_BAK "${CMAKE_MSVC_RUNTIME_LIBRARY}") - # UMF has not yet been able to build as static - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") message(STATUS "Level Zero Adapter: Will fetch Level Zero Loader from ${UR_LEVEL_ZERO_LOADER_REPO}") include(FetchContent) FetchContent_Declare(level-zero-loader @@ -74,7 +71,6 @@ if(NOT LEVEL_ZERO_LIB_NAME AND NOT LEVEL_ZERO_LIBRARY) # Restore original flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BAK}") - set(CMAKE_MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY_BAK}") set(LEVEL_ZERO_LIBRARY ze_loader) set(LEVEL_ZERO_INCLUDE_DIR ${level-zero-loader_SOURCE_DIR}/include CACHE PATH "Path to Level Zero Headers") diff --git a/unified-runtime/cmake/helpers.cmake b/unified-runtime/cmake/helpers.cmake index 12bb758257c14..997325ce97154 100644 --- a/unified-runtime/cmake/helpers.cmake +++ b/unified-runtime/cmake/helpers.cmake @@ -126,9 +126,6 @@ function(add_ur_target_compile_options name) elseif(MSVC) target_compile_options(${name} PRIVATE $<$:/MP> # clang-cl.exe does not support /MP - /MD$<$:d> - - /W3 /GS # Enable: Buffer security check /Gy # Enable: Function-level linking @@ -203,8 +200,9 @@ function(add_ur_library name) $<$,link.exe>:LINKER:/DEPENDENTLOADFLAG:0x2000> ) endif() - if(UR_USE_DEBUG_POSTFIX) - set_target_properties(${name} PROPERTIES DEBUG_POSTFIX d) + if (CMAKE_SYSTEM_NAME STREQUAL Windows AND + (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL)) + set_target_properties(${name} PROPERTIES OUTPUT_NAME "${name}d") endif() if(UR_EXTERNAL_DEPENDENCIES) add_dependencies(${name} ${UR_EXTERNAL_DEPENDENCIES}) diff --git a/unified-runtime/source/adapters/CMakeLists.txt b/unified-runtime/source/adapters/CMakeLists.txt index c5663229f1ce6..2cf732e521ce9 100644 --- a/unified-runtime/source/adapters/CMakeLists.txt +++ b/unified-runtime/source/adapters/CMakeLists.txt @@ -6,7 +6,11 @@ function(add_ur_adapter name) add_ur_library(${name} ${ARGN}) if(MSVC) - set(TARGET_LIBNAME ${name}) + if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set(TARGET_LIBNAME ${name}d) + else() + set(TARGET_LIBNAME ${name}) + endif() string(TOUPPER ${TARGET_LIBNAME} TARGET_LIBNAME) set(ADAPTER_VERSION_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/${name}.def) @@ -34,6 +38,10 @@ function(add_ur_adapter name) "-Wl,--version-script=${ADAPTER_VERSION_SCRIPT}" ) endif() + if (CMAKE_SYSTEM_NAME STREQUAL Windows AND + (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL)) + set_target_properties(${name} PROPERTIES OUTPUT_NAME "${name}d") + endif() add_dependencies(ur_loader ${name}) endfunction() diff --git a/unified-runtime/source/common/CMakeLists.txt b/unified-runtime/source/common/CMakeLists.txt index 9657bfc5f620c..3c05ee66a63f5 100644 --- a/unified-runtime/source/common/CMakeLists.txt +++ b/unified-runtime/source/common/CMakeLists.txt @@ -100,6 +100,12 @@ else() set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "Build UMF examples") set(UMF_BUILD_SHARED_LIBRARY ${UMF_BUILD_SHARED_LIBRARY} CACHE INTERNAL "Build UMF shared library") + if (CMAKE_SYSTEM_NAME STREQUAL Windows) + if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set(UMF_USE_DEBUG_POSTFIX ON) + endif() + endif() + FetchContent_MakeAvailable(unified-memory-framework) FetchContent_GetProperties(unified-memory-framework) endif() @@ -158,3 +164,8 @@ target_link_libraries(ur_umf INTERFACE umf::umf umf::headers ) + +if (CMAKE_SYSTEM_NAME STREQUAL Windows AND + (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL)) + set_target_properties(ur_umf PROPERTIES OUTPUT_NAME "ur_umfd") +endif() diff --git a/unified-runtime/source/loader/CMakeLists.txt b/unified-runtime/source/loader/CMakeLists.txt index a331e10e34a8d..8f6900bcdc50a 100644 --- a/unified-runtime/source/loader/CMakeLists.txt +++ b/unified-runtime/source/loader/CMakeLists.txt @@ -21,12 +21,18 @@ add_ur_library(ur_loader ) install_ur_library(ur_loader) -target_compile_definitions(ur_loader PRIVATE - UR_USE_DEBUG_POSTFIX=$ -) +if (CMAKE_SYSTEM_NAME STREQUAL Windows) + if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + target_compile_definitions(ur_loader PRIVATE UR_USE_DEBUG_POSTFIX=1) + endif() +endif() if (MSVC) - set(TARGET_LIBNAME ur_loader) + if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set(TARGET_LIBNAME ur_loaderd) + else() + set(TARGET_LIBNAME ur_loader) + endif() string(TOUPPER ${TARGET_LIBNAME} TARGET_LIBNAME) set(LOADER_VERSION_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/ur_loader.def) diff --git a/unified-runtime/source/mock/CMakeLists.txt b/unified-runtime/source/mock/CMakeLists.txt index 06a1a1db043a6..450eaccd96f9f 100644 --- a/unified-runtime/source/mock/CMakeLists.txt +++ b/unified-runtime/source/mock/CMakeLists.txt @@ -6,6 +6,12 @@ add_ur_library(ur_mock SHARED "${CMAKE_CURRENT_SOURCE_DIR}/ur_mock_helpers.cpp" ) + +if(CMAKE_SYSTEM_NAME STREQUAL Windows AND + (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL)) + set_target_properties(ur_mock PROPERTIES OUTPUT_NAME "ur_mock_headersd") +endif() + target_include_directories(ur_mock INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}" ) diff --git a/xpti/CMakeLists.txt b/xpti/CMakeLists.txt index 50f84fef817e2..6dcf860901399 100644 --- a/xpti/CMakeLists.txt +++ b/xpti/CMakeLists.txt @@ -22,41 +22,6 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE) endif() -if (MSVC) - # MSVC provides two incompatible build variants for its CRT: release and debug - # To avoid potential issues in user code we also need to provide two kinds - # of SYCL Runtime Library for release and debug configurations. - set(XPTI_CXX_FLAGS "") - if (CMAKE_BUILD_TYPE MATCHES "Debug") - set(XPTI_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/MDd" "" XPTI_CXX_FLAGS "${XPTI_CXX_FLAGS}") - string(REPLACE "/MTd" "" XPTI_CXX_FLAGS "${XPTI_CXX_FLAGS}") - else() - if (CMAKE_BUILD_TYPE MATCHES "Release") - set(XPTI_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}") - elseif (CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo") - set(XPTI_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") - elseif (CMAKE_BUILD_TYPE MATCHES "MinSizeRel") - set(XPTI_CXX_FLAGS "${CMAKE_CXX_FLAGS_MINSIZEREL}") - endif() - string(REPLACE "/MD" "" XPTI_CXX_FLAGS "${XPTI_CXX_FLAGS}") - string(REPLACE "/MT" "" XPTI_CXX_FLAGS "${XPTI_CXX_FLAGS}") - endif() - - # target_compile_options requires list of options, not a string - string(REPLACE " " ";" XPTI_CXX_FLAGS "${XPTI_CXX_FLAGS}") - - set(XPTI_CXX_FLAGS_RELEASE "${XPTI_CXX_FLAGS};/MD") - set(XPTI_CXX_FLAGS_DEBUG "${XPTI_CXX_FLAGS};/MDd") - - # CMake automatically applies these flags to all targets. To override this - # behavior, options lists are reset. - set(CMAKE_CXX_FLAGS_RELEASE "") - set(CMAKE_CXX_FLAGS_MINSIZEREL "") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "") - set(CMAKE_CXX_FLAGS_DEBUG "") -endif() - set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/lib/${CMAKE_BUILD_TYPE}) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) @@ -79,9 +44,6 @@ if (LLVM_BINARY_DIR) COMMENT "Copying XPTI headers ..." ) add_dependencies(xpti xpti-headers) - if (MSVC) - add_dependencies(xptid xpti-headers) - endif() endif() include(GNUInstallDirs) diff --git a/xpti/src/CMakeLists.txt b/xpti/src/CMakeLists.txt index 1d7e371e98a17..d94ddad5f0125 100644 --- a/xpti/src/CMakeLists.txt +++ b/xpti/src/CMakeLists.txt @@ -22,13 +22,3 @@ set(SOURCES ) add_xpti_lib(xpti ${SOURCES}) - -# Handle the debug version for the Microsoft compiler as a special case by -# creating a debug version of the static library that uses the flags used by -# the SYCL runtime -if (MSVC) - add_xpti_lib(xptid STATIC ${SOURCES}) - target_compile_options(xptid PRIVATE ${XPTI_CXX_FLAGS_DEBUG}) - target_compile_options(xpti PRIVATE ${XPTI_CXX_FLAGS_RELEASE}) -endif() - diff --git a/xptifw/CMakeLists.txt b/xptifw/CMakeLists.txt index 00a9c71ba2892..1064bcbc59ab2 100644 --- a/xptifw/CMakeLists.txt +++ b/xptifw/CMakeLists.txt @@ -48,10 +48,6 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) add_subdirectory(src) set(xptifw_lib xptifw) -string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower) -if (WIN32 AND "${build_type_lower}" MATCHES "debug") - set(xptifw_lib xptifwd) -endif() add_custom_target(check-xptifw) diff --git a/xptifw/src/CMakeLists.txt b/xptifw/src/CMakeLists.txt index 1026bc505f4ee..e58638a76f097 100644 --- a/xptifw/src/CMakeLists.txt +++ b/xptifw/src/CMakeLists.txt @@ -52,14 +52,6 @@ function(add_xpti_library LIB_NAME) remove_definitions(-DXPTI_STATIC_LIBRARY) add_library(${LIB_NAME} SHARED ${SOURCES}) - if (${LIB_NAME} MATCHES "xptifwd") - set_property(TARGET ${LIB_NAME} PROPERTY - MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL") - else() - set_property(TARGET ${LIB_NAME} PROPERTY - MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") - endif() - target_compile_definitions(${LIB_NAME} PRIVATE -DXPTI_API_EXPORTS) target_include_directories(${LIB_NAME} PUBLIC $ @@ -78,6 +70,10 @@ function(add_xpti_library LIB_NAME) target_link_libraries(${LIB_NAME} PUBLIC $) endif() + if (SYCL_USE_LIBCXX) + target_link_libraries(${LIB_NAME} PRIVATE "-L${SYCL_LIBCXX_LIBRARY_PATH}" -Wl,-rpath,${SYCL_LIBCXX_LIBRARY_PATH} -nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgcc) + endif() + # Set the location of the library installation include(GNUInstallDirs) install(TARGETS ${LIB_NAME} @@ -87,10 +83,4 @@ function(add_xpti_library LIB_NAME) ) endfunction(add_xpti_library) -# MSVC provides two incompatible build variants for its CRT: release and debug -# To avoid potential issues in user code we also need to provide two kinds -# of XPTIFW for release and debug configurations. add_xpti_library(xptifw) -if (MSVC) - add_xpti_library(xptifwd) -endif()