From ece7f9753333a989cb54cbbd6bdea4ea74ff2857 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 10 Apr 2025 06:20:21 -0700 Subject: [PATCH 01/35] [SYCL] Stop building Windows debug variants in release mode Signed-off-by: Larsen, Steffen --- clang/lib/Driver/ToolChains/MSVC.cpp | 5 +- sycl/CMakeLists.txt | 13 +--- sycl/cmake/modules/AddSYCLUnitTest.cmake | 9 +-- sycl/cmake/modules/SYCLUtils.cmake | 11 ++-- sycl/source/CMakeLists.txt | 66 +++++-------------- .../Regression/compile_on_win_with_mdd.cpp | 2 +- sycl/test-e2e/Regression/msvc_crt.cpp | 6 +- sycl/test-e2e/lit.cfg.py | 6 ++ sycl/test-e2e/lit.site.cfg.py.in | 2 + sycl/test/abi/sycl_symbols_windows.dump | 2 +- sycl/test/lit.cfg.py | 16 ++++- sycl/test/lit.site.cfg.py.in | 2 + sycl/tools/sycl-ls/CMakeLists.txt | 8 +-- sycl/ur_win_proxy_loader/CMakeLists.txt | 43 ------------ unified-runtime/CMakeLists.txt | 6 +- xpti/CMakeLists.txt | 38 ----------- xpti/src/CMakeLists.txt | 10 --- xptifw/CMakeLists.txt | 4 -- xptifw/src/CMakeLists.txt | 9 +-- 19 files changed, 59 insertions(+), 199 deletions(-) diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index 8b295e9188867..07f1a99907e65 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -150,9 +150,10 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA, // equivalent. Do not add the -defaultlib as it conflicts. if (!isDependentLibAdded(Args, "msvcrtd")) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) - CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION "-preview.lib"); + CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION + "d-preview.lib"); else - CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION ".lib"); + CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION "d.lib"); } CmdArgs.push_back("-defaultlib:sycl-devicelib-host.lib"); } diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 78949054ef14c..1dc37d6a97a73 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -293,13 +293,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) @@ -363,11 +356,7 @@ if (NOT WIN32) 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. diff --git a/sycl/cmake/modules/AddSYCLUnitTest.cmake b/sycl/cmake/modules/AddSYCLUnitTest.cmake index 677c7358da0f6..001a84aa77853 100644 --- a/sycl/cmake/modules/AddSYCLUnitTest.cmake +++ b/sycl/cmake/modules/AddSYCLUnitTest.cmake @@ -10,13 +10,8 @@ macro(add_sycl_unittest test_dirname link_variant) get_target_property(SYCL_BINARY_DIR sycl-toolchain BINARY_DIR) string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower) - if (MSVC AND build_type_lower MATCHES "debug") - set(sycl_obj_target "sycld_object") - set(sycl_so_target "sycld") - else() - set(sycl_obj_target "sycl_object") - set(sycl_so_target "sycl") - endif() + set(sycl_obj_target "sycl_object") + set(sycl_so_target "sycl") if ("${link_variant}" MATCHES "SHARED") set(SYCL_LINK_LIBS ${sycl_so_target}) 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 2570921a2d565..8813a6482137b 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -146,13 +146,8 @@ 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_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. @@ -164,10 +159,11 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_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 + ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${LIB_NAME}$<$:d>.lib + ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ARG_IMPLIB_NAME}$<$:d>.lib COMMENT "Creating version-agnostic copy of the import library.") install( - FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ARG_IMPLIB_NAME}.lib + FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ARG_IMPLIB_NAME}$<$:d>.lib DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT sycl) endif() endif() @@ -220,6 +216,12 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) file(REMOVE ${VERSION_FILE}) endif() endif() + + # Ensure that we use the dynamic CRT on Windows, i.e. /MD or /MDd. + set_target_properties(${LIB_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") + set_target_properties(${LIB_OBJ_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") endfunction(add_sycl_rt_library) set(SYCL_COMMON_SOURCES @@ -322,37 +324,8 @@ 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") + # Append d to the debug libraries on Windows. + set(CMAKE_DEBUG_POSTFIX d) endif() check_cxx_compiler_flag(-fsemantic-interposition HAS_SEMANTIC_INTERPOSITION_FLAG) @@ -369,16 +342,9 @@ endif() # Version-agnostic name of the import library, has effect on Windows only. set(IMPLIB_NAME "sycl") -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 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() if (WIN32) 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..823b4dc179cfd 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 // 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 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 222ae37208b59..e06dff9c42411 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -298,6 +298,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.build_mode == "Debug": + 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: diff --git a/sycl/test-e2e/lit.site.cfg.py.in b/sycl/test-e2e/lit.site.cfg.py.in index e2d6bfc282896..90389048c6099 100644 --- a/sycl/test-e2e/lit.site.cfg.py.in +++ b/sycl/test-e2e/lit.site.cfg.py.in @@ -48,6 +48,8 @@ config.vulkan_include_dir = "@Vulkan_INCLUDE_DIRS@" config.vulkan_lib = "@Vulkan_LIBRARY@" config.vulkan_found = "@Vulkan_FOUND@" +config.build_mode = "@CMAKE_BUILD_TYPE@" + 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/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index 8cfa503ed210c..0e0ad915aa1f3 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/sycl8.dll %} %else %{ %llvm_build_bin_dir/sycl8d.dll %} # REQUIRES: windows # UNSUPPORTED: libcxx diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index 089395d5c1400..c6589ec8dddba 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.build_mode == "Debug": + 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 @@ -132,9 +136,12 @@ 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") -) +if platform.system() == "Windows": + config.substitutions.append( + ("%sycl_lib", " -lsycl8d" if config.build_mode == "Debug" else " -lsycl8") + ) +else: + config.substitutions.append(("%sycl_lib", "-lsycl")) llvm_config.add_tool_substitutions(["llvm-spirv"], [config.sycl_tools_dir]) @@ -178,6 +185,9 @@ "--offload-arch=gfx906", ] +if platform.system() == "Windows" and config.build_mode == "Debug": + additional_flags += ["-fms-runtime-lib=dll_dbg"] + config.sycl_headers_filter = lit_config.params.get("SYCL_HEADERS_FILTER", None) if config.sycl_headers_filter is not None: lit_config.note( diff --git a/sycl/test/lit.site.cfg.py.in b/sycl/test/lit.site.cfg.py.in index cc9043f71bf3e..3da06e7ed9134 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.build_mode = "@CMAKE_BUILD_TYPE@" + import lit.llvm lit.llvm.initialize(lit_config, config) diff --git a/sycl/tools/sycl-ls/CMakeLists.txt b/sycl/tools/sycl-ls/CMakeLists.txt index b90bd972d3672..de6520a6d1075 100644 --- a/sycl/tools/sycl-ls/CMakeLists.txt +++ b/sycl/tools/sycl-ls/CMakeLists.txt @@ -2,18 +2,12 @@ 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 warning. target_compile_definitions(sycl-ls PRIVATE SYCL_DISABLE_IMAGE_ASPECT_WARNING) target_link_libraries(sycl-ls PRIVATE - ${sycl_lib} + sycl OpenCL-Headers UnifiedRuntime-Headers ) diff --git a/sycl/ur_win_proxy_loader/CMakeLists.txt b/sycl/ur_win_proxy_loader/CMakeLists.txt index 955cd022183ec..2ef13f329746d 100644 --- a/sycl/ur_win_proxy_loader/CMakeLists.txt +++ b/sycl/ur_win_proxy_loader/CMakeLists.txt @@ -18,51 +18,8 @@ install(TARGETS 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_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 9691012efc6f8..afbdc851a7c37 100644 --- a/unified-runtime/CMakeLists.txt +++ b/unified-runtime/CMakeLists.txt @@ -201,11 +201,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/xpti/CMakeLists.txt b/xpti/CMakeLists.txt index 6433e39c94c70..53ae5d38668cb 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_MINSIZEREL}") - elseif (CMAKE_BUILD_TYPE MATCHES "MinSizeRel") - set(XPTI_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") - 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() - if (SYCL_USE_LIBCXX) if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) @@ -91,9 +56,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 99c7e84c43a56..35763a566f459 100644 --- a/xptifw/CMakeLists.txt +++ b/xptifw/CMakeLists.txt @@ -61,10 +61,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 1337f37879174..846fc228c450d 100644 --- a/xptifw/src/CMakeLists.txt +++ b/xptifw/src/CMakeLists.txt @@ -31,13 +31,8 @@ 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() + set_target_properties(${LIB_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") target_compile_definitions(${LIB_NAME} PRIVATE -DXPTI_API_EXPORTS) target_include_directories(${LIB_NAME} PUBLIC From e43a28ca2102799521b06ed415fb47ee3bfd9d4d Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 24 Apr 2025 03:44:36 -0700 Subject: [PATCH 02/35] Add ucrt checks Signed-off-by: Larsen, Steffen --- opencl/CMakeLists.txt | 4 ++ sycl/source/CMakeLists.txt | 12 +++--- sycl/test/abi/sycl_symbols_windows.dump | 2 +- sycl/test/lit.cfg.py | 10 ++--- sycl/test/win_ucrt/lit.local.cfg | 1 + sycl/test/win_ucrt/urct_check.py | 41 +++++++++++++++++++ sycl/ur_win_proxy_loader/CMakeLists.txt | 7 +++- unified-runtime/cmake/helpers.cmake | 7 ++-- .../source/adapters/CMakeLists.txt | 11 +++-- unified-runtime/source/common/CMakeLists.txt | 4 +- unified-runtime/source/loader/CMakeLists.txt | 18 ++++---- unified-runtime/source/mock/CMakeLists.txt | 4 ++ xptifw/src/CMakeLists.txt | 2 +- 13 files changed, 93 insertions(+), 30 deletions(-) create mode 100644 sycl/test/win_ucrt/lit.local.cfg create mode 100644 sycl/test/win_ucrt/urct_check.py diff --git a/opencl/CMakeLists.txt b/opencl/CMakeLists.txt index 808fc98c6bcc2..d11f2c7a246a0 100644 --- a/opencl/CMakeLists.txt +++ b/opencl/CMakeLists.txt @@ -78,4 +78,8 @@ endif() FetchContent_MakeAvailable(ocl-icd) add_library(OpenCL-ICD ALIAS OpenCL) +if (CMAKE_SYSTEM_NAME STREQUAL Windows) + set_target_properties(OpenCL PROPERTIES DEBUG_POSTFIX d) +endif() + add_subdirectory(opencl-aot) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 8813a6482137b..9d7ff8ef05169 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -323,11 +323,6 @@ set(SYCL_NON_PREVIEW_SOURCES "${SYCL_COMMON_SOURCES}" set(SYCL_PREVIEW_SOURCES "${SYCL_COMMON_SOURCES}" ) -if (MSVC) - # Append d to the debug libraries on Windows. - set(CMAKE_DEBUG_POSTFIX d) -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. @@ -354,6 +349,13 @@ if (WIN32) endif() endif() +if (WIN32) + set_target_properties(${LIB_NAME} PROPERTIES DEBUG_POSTFIX d) + if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB AND (CMAKE_BUILD_TYPE STREQUAL Debug)) + set_target_properties(sycl${SYCL_MAJOR_VERSION}-preview PROPERTIES OUTPUT_NAME sycl${SYCL_MAJOR_VERSION}d-preview) + 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/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index bf18dd573c483..c41a31cb873fa 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 %if debug_sycl_library %{ %llvm_build_bin_dir/sycl8.dll %} %else %{ %llvm_build_bin_dir/sycl8d.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/lit.cfg.py b/sycl/test/lit.cfg.py index ec438952f4329..a0312091426d5 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -185,9 +185,6 @@ "--offload-arch=gfx906", ] -if platform.system() == "Windows" and config.build_mode == "Debug": - additional_flags += ["-fms-runtime-lib=dll_dbg"] - config.sycl_headers_filter = lit_config.params.get("SYCL_HEADERS_FILTER", None) if config.sycl_headers_filter is not None: lit_config.note( @@ -203,10 +200,13 @@ if not dump_only_tests: llvm_config.use_clang(additional_flags=additional_flags) -# Set timeout for test = 10 mins +# Set timeout for test = 10 mins (Release) or 20 mins (Debug) try: import psutil - lit_config.maxIndividualTestTime = 600 + if config.build_mode != "Debug": + lit_config.maxIndividualTestTime = 600 + else: + lit_config.maxIndividualTestTime = 1200 except ImportError: pass 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/urct_check.py b/sycl/test/win_ucrt/urct_check.py new file mode 100644 index 0000000000000..f3022543006c9 --- /dev/null +++ b/sycl/test/win_ucrt/urct_check.py @@ -0,0 +1,41 @@ +# 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 either "d" or +# "d-preview". +# +import argparse +import os +import subprocess +import sys + +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 + + has_debug_postfix = filename.endswith("d") or filename.endswith("d-preview") + dep_output = subprocess.run(["dumpbin", "/dependents", filepath], shell=False, capture_output=True) + + if str(dep_output.stdout).find("ucrtbased.dll"): + if not has_debug_postfix: + print("Unexpected use of ucrtbased.dll:", filepath) + sys.exit(1) + elif str(dep_output.stdout).find("ucrtbase.dll"): + if has_debug_postfix: + print("Unexpected use of ucrtbase.dll:", filepath) + sys.exit(1) + +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. + with os.scandir(args.target_path) as it: + for entry in it: + if entry.is_file(): + check_file(entry.name) diff --git a/sycl/ur_win_proxy_loader/CMakeLists.txt b/sycl/ur_win_proxy_loader/CMakeLists.txt index 804d60d7f1267..27537602e46aa 100644 --- a/sycl/ur_win_proxy_loader/CMakeLists.txt +++ b/sycl/ur_win_proxy_loader/CMakeLists.txt @@ -12,8 +12,11 @@ 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 (MSVC) - set_target_properties(ur_win_proxy_loader PROPERTIES DEBUG_POSTFIX d) +if (WIN32) + set_target_properties(ur_win_proxy_loader PROPERTIES DEBUG_POSTFIX d) + if(CMAKE_BUILD_TYPE STREQUAL Debug) + target_compile_definitions(ur_win_proxy_loader PRIVATE UR_WIN_PROXY_LOADER_DEBUG_POSTFIX) + endif() endif() add_dependencies(ur_win_proxy_loader UnifiedRuntimeLoader) install(TARGETS ur_win_proxy_loader diff --git a/unified-runtime/cmake/helpers.cmake b/unified-runtime/cmake/helpers.cmake index 3a451748ccd6a..12558240f4bdb 100644 --- a/unified-runtime/cmake/helpers.cmake +++ b/unified-runtime/cmake/helpers.cmake @@ -138,9 +138,6 @@ function(add_ur_target_compile_options name) WIN32_LEAN_AND_MEAN NOMINMAX # Cajole Windows.h to define fewer symbols _CRT_SECURE_NO_WARNINGS # Slience warnings about getenv ) - if(UR_USE_DEBUG_POSTFIX) - target_compile_definitions(${name} PRIVATE UR_USE_DEBUG_POSTFIX=1) - endif() if(UR_DEVELOPER_MODE) target_compile_options(${name} PRIVATE @@ -200,7 +197,9 @@ function(add_ur_library name) $<$,link.exe>:LINKER:/DEPENDENTLOADFLAG:0x2000> ) endif() - set_target_properties(${name} PROPERTIES DEBUG_POSTFIX d) + if(WIN32) + set_target_properties(${name} PROPERTIES DEBUG_POSTFIX d) + endif() if(UR_EXTERNAL_DEPENDENCIES) add_dependencies(${name} ${UR_EXTERNAL_DEPENDENCIES}) endif() diff --git a/unified-runtime/source/adapters/CMakeLists.txt b/unified-runtime/source/adapters/CMakeLists.txt index 3c581b7d3ba21..3270c74f7707c 100644 --- a/unified-runtime/source/adapters/CMakeLists.txt +++ b/unified-runtime/source/adapters/CMakeLists.txt @@ -6,11 +6,13 @@ function(add_ur_adapter name) add_ur_library(${name} ${ARGN}) if(MSVC) - set(TARGET_LIBNAME ${name}) + if(CMAKE_BUILD_TYPE STREQUAL Debug) + set(TARGET_LIBNAME ${name}d) + else() + set(TARGET_LIBNAME ${name}) + endif() string(TOUPPER ${TARGET_LIBNAME} TARGET_LIBNAME) - set_target_properties(${name} PROPERTIES DEBUG_POSTFIX d) - set(ADAPTER_VERSION_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/${name}.def) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../adapter.def.in ${ADAPTER_VERSION_SCRIPT} @ONLY) @@ -28,6 +30,9 @@ function(add_ur_adapter name) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../adapter.map.in ${ADAPTER_VERSION_SCRIPT} @ONLY) target_link_options(${name} PRIVATE "-Wl,--version-script=${ADAPTER_VERSION_SCRIPT}") endif() + if(WIN32) + set_target_properties(${name} PROPERTIES DEBUG_POSTFIX 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 214f5c3c5b397..bbbcb55259894 100644 --- a/unified-runtime/source/common/CMakeLists.txt +++ b/unified-runtime/source/common/CMakeLists.txt @@ -73,7 +73,7 @@ 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 (MSVC) + if (WIN32) if(CMAKE_BUILD_TYPE STREQUAL Debug) set(UMF_USE_DEBUG_POSTFIX ON) endif() @@ -134,6 +134,6 @@ target_link_libraries(ur_umf INTERFACE umf::headers ) -if (MSVC) +if (WIN32) set_target_properties(ur_umf PROPERTIES DEBUG_POSTFIX d) endif() diff --git a/unified-runtime/source/loader/CMakeLists.txt b/unified-runtime/source/loader/CMakeLists.txt index 3293876add5e6..848ad18e2dc10 100644 --- a/unified-runtime/source/loader/CMakeLists.txt +++ b/unified-runtime/source/loader/CMakeLists.txt @@ -14,12 +14,6 @@ if(UR_STATIC_LOADER) set(LOADER_LIB_TYPE STATIC) endif() -if (MSVC) - if(CMAKE_BUILD_TYPE STREQUAL Debug) - set(UR_USE_DEBUG_POSTFIX ON) - endif() -endif() - add_ur_library(ur_loader ${LOADER_LIB_TYPE} "" @@ -27,8 +21,18 @@ add_ur_library(ur_loader ) install_ur_library(ur_loader) +if (WIN32) + if(CMAKE_BUILD_TYPE STREQUAL Debug) + 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) + 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 f3933fbef1453..6133e824678f3 100644 --- a/unified-runtime/source/mock/CMakeLists.txt +++ b/unified-runtime/source/mock/CMakeLists.txt @@ -6,6 +6,10 @@ add_library (ur_mock_headers SHARED "${CMAKE_CURRENT_SOURCE_DIR}/ur_mock_helpers.cpp") +if(WIN32) + set_target_properties(ur_mock_headers PROPERTIES DEBUG_POSTFIX d) +endif() + target_include_directories(ur_mock_headers INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}" ) diff --git a/xptifw/src/CMakeLists.txt b/xptifw/src/CMakeLists.txt index a41c13503553d..affb28f161aea 100644 --- a/xptifw/src/CMakeLists.txt +++ b/xptifw/src/CMakeLists.txt @@ -55,7 +55,7 @@ function(add_xpti_library LIB_NAME) 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() - if (MSVC) + if (WIN32) set_target_properties(${LIB_NAME} PROPERTIES DEBUG_POSTFIX d) endif() From 93ec50c7fcd172fd257d62ba261c264141d1fe53 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 25 Apr 2025 09:04:43 -0700 Subject: [PATCH 03/35] Fix formatting Signed-off-by: Larsen, Steffen --- sycl/test-e2e/lit.cfg.py | 2 +- sycl/test/win_ucrt/urct_check.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index e97e3f4081a38..72b74a6abe144 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -304,7 +304,7 @@ def open_check_file(file_name): if config.build_mode == "Debug": 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") + config.cxx_flags += " /MDd" if cl_options else " -fms-runtime-lib=dll_dbg" # Check for Level Zero SDK check_l0_file = "l0_include.cpp" diff --git a/sycl/test/win_ucrt/urct_check.py b/sycl/test/win_ucrt/urct_check.py index f3022543006c9..718f9232926eb 100644 --- a/sycl/test/win_ucrt/urct_check.py +++ b/sycl/test/win_ucrt/urct_check.py @@ -10,15 +10,18 @@ import subprocess import sys + 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 has_debug_postfix = filename.endswith("d") or filename.endswith("d-preview") - dep_output = subprocess.run(["dumpbin", "/dependents", filepath], shell=False, capture_output=True) + dep_output = subprocess.run( + ["dumpbin", "/dependents", filepath], shell=False, capture_output=True + ) if str(dep_output.stdout).find("ucrtbased.dll"): if not has_debug_postfix: @@ -29,7 +32,7 @@ def check_file(filepath): print("Unexpected use of ucrtbase.dll:", filepath) sys.exit(1) -if __name__=="__main__": +if __name__ == "__main__": parser = argparse.ArgumentParser(description="Windows UCRT checker utility.") parser.add_argument("target_path", type=str) args = parser.parse_args() From 89652eff1e4e48017265df20a7ca86f0f34c2cec Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Sun, 27 Apr 2025 21:56:32 -0700 Subject: [PATCH 04/35] Fix formatting Signed-off-by: Larsen, Steffen --- sycl/test/win_ucrt/urct_check.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sycl/test/win_ucrt/urct_check.py b/sycl/test/win_ucrt/urct_check.py index 718f9232926eb..5c27fd429f995 100644 --- a/sycl/test/win_ucrt/urct_check.py +++ b/sycl/test/win_ucrt/urct_check.py @@ -22,7 +22,7 @@ def check_file(filepath): dep_output = subprocess.run( ["dumpbin", "/dependents", filepath], shell=False, capture_output=True ) - + if str(dep_output.stdout).find("ucrtbased.dll"): if not has_debug_postfix: print("Unexpected use of ucrtbased.dll:", filepath) @@ -32,6 +32,7 @@ def check_file(filepath): print("Unexpected use of ucrtbase.dll:", filepath) sys.exit(1) + if __name__ == "__main__": parser = argparse.ArgumentParser(description="Windows UCRT checker utility.") parser.add_argument("target_path", type=str) From 78c2798f57d093c6ae81c187da943a50091c4bb8 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 28 Apr 2025 00:27:07 -0700 Subject: [PATCH 05/35] Fix windows sycl lib install target Signed-off-by: Larsen, Steffen --- clang/lib/Driver/ToolChains/Clang.cpp | 4 +- clang/test/Driver/sycl-offload-old-model.c | 2 +- clang/test/Driver/sycl-offload.c | 2 +- sycl/source/CMakeLists.txt | 90 ++++++++++++---------- 4 files changed, 55 insertions(+), 43 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index bbd9f9d925597..e8f5a973e3fd6 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5413,7 +5413,7 @@ static void ProcessVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args, if (RTOptionID == options::OPT__SLASH_MDd) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION - "-previewd"); + "d-preview"); else CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION "d"); } else { @@ -7033,7 +7033,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (isDependentLibAdded(Args, "msvcrtd")) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION - "-previewd"); + "d-preview"); else CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION "d"); } diff --git a/clang/test/Driver/sycl-offload-old-model.c b/clang/test/Driver/sycl-offload-old-model.c index 832a0ada50884..9126c2e554ab5 100644 --- a/clang/test/Driver/sycl-offload-old-model.c +++ b/clang/test/Driver/sycl-offload-old-model.c @@ -858,6 +858,6 @@ /// Check for linked sycl lib when using -fpreview-breaking-changes with -fsycl // RUN: %clang -### -fsycl --no-offload-new-driver -fpreview-breaking-changes -target x86_64-unknown-windows-msvc -Xclang --dependent-lib=msvcrtd %s 2>&1 | FileCheck -check-prefix FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK %s // RUN: %clang_cl -### -fsycl --no-offload-new-driver -fpreview-breaking-changes /MDd %s 2>&1 | FileCheck -check-prefix FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK %s -// FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK: --dependent-lib=sycl{{[0-9]*}}-previewd +// FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK: --dependent-lib=sycl{{[0-9]*}}-preview // FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK-NOT: -defaultlib:sycl{{[0-9]*}}.lib // FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK-NOT: -defaultlib:sycl{{[0-9]*}}-preview.lib diff --git a/clang/test/Driver/sycl-offload.c b/clang/test/Driver/sycl-offload.c index 56d44faa1efa3..c19089342622d 100644 --- a/clang/test/Driver/sycl-offload.c +++ b/clang/test/Driver/sycl-offload.c @@ -560,7 +560,7 @@ /// Check for linked sycl lib when using -fpreview-breaking-changes with -fsycl // RUN: %clang -### -fsycl --offload-new-driver -fpreview-breaking-changes -target x86_64-unknown-windows-msvc -Xclang --dependent-lib=msvcrtd %s 2>&1 | FileCheck -check-prefix FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK %s // RUN: %clang_cl -### -fsycl --offload-new-driver -fpreview-breaking-changes /MDd %s 2>&1 | FileCheck -check-prefix FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK %s -// FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK: --dependent-lib=sycl{{[0-9]*}}-previewd +// FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK: --dependent-lib=sycl{{[0-9]*}}-preview // FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK-NOT: -defaultlib:sycl{{[0-9]*}}.lib // FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK-NOT: -defaultlib:sycl{{[0-9]*}}-preview.lib diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 9d7ff8ef05169..831700259107a 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -15,10 +15,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}) @@ -69,13 +69,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} @@ -90,22 +90,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 @@ -117,10 +117,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() @@ -129,57 +129,55 @@ 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 (NOT LLVM_ENABLE_ZSTD) target_compile_definitions(${LIB_OBJ_NAME} PRIVATE SYCL_RT_ZSTD_NOT_AVAIABLE) else() - 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() # ur_win_proxy_loader if (WIN32) include_directories(${LLVM_EXTERNAL_SYCL_SOURCE_DIR}/ur_win_proxy_loader) - target_link_libraries(${LIB_NAME} PUBLIC ur_win_proxy_loader) + 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}$<$:d>.lib - ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ARG_IMPLIB_NAME}$<$:d>.lib - COMMENT "Creating version-agnostic copy of the import library.") - install( - FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ARG_IMPLIB_NAME}$<$:d>.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() @@ -190,18 +188,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}) @@ -218,7 +216,7 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) endif() # Ensure that we use the dynamic CRT on Windows, i.e. /MD or /MDd. - set_target_properties(${LIB_NAME} PROPERTIES + set_target_properties(${LIB_TARGET_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") set_target_properties(${LIB_OBJ_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") @@ -331,15 +329,29 @@ endif() if (WIN32) set(LIB_NAME "sycl${SYCL_MAJOR_VERSION}") +set(LIB_OUTPUT_NAME "${LIB_NAME}$<$:d>") else() set(LIB_NAME "sycl") +set(LIB_OUTPUT_NAME "${LIB_NAME}") endif() -# Version-agnostic name of the import library, has effect on Windows only. -set(IMPLIB_NAME "sycl") +set(LIB_PREVIEW_NAME ${LIB_NAME}-preview) +set(LIB_PREVIEW_OUTPUT_NAME ${LIB_OUTPUT_NAME}-preview) -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}) +# Version-agnostic name of the import library, has effect on Windows only. +set(IMPLIB_NAME "sycl$<$:d>") +set(IMPLIB_PREVIEW_NAME "${IMPLIB_NAME}-preview") + +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_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) + 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) From 2c9712cf1bee759555e23901c3673f7c7feae490 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 28 Apr 2025 00:53:11 -0700 Subject: [PATCH 06/35] Revert clang toolchain changes Signed-off-by: Larsen, Steffen --- clang/lib/Driver/ToolChains/Clang.cpp | 4 ++-- clang/test/Driver/sycl-offload-old-model.c | 2 +- clang/test/Driver/sycl-offload.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index e8f5a973e3fd6..bbd9f9d925597 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5413,7 +5413,7 @@ static void ProcessVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args, if (RTOptionID == options::OPT__SLASH_MDd) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION - "d-preview"); + "-previewd"); else CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION "d"); } else { @@ -7033,7 +7033,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (isDependentLibAdded(Args, "msvcrtd")) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION - "d-preview"); + "-previewd"); else CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION "d"); } diff --git a/clang/test/Driver/sycl-offload-old-model.c b/clang/test/Driver/sycl-offload-old-model.c index 9126c2e554ab5..832a0ada50884 100644 --- a/clang/test/Driver/sycl-offload-old-model.c +++ b/clang/test/Driver/sycl-offload-old-model.c @@ -858,6 +858,6 @@ /// Check for linked sycl lib when using -fpreview-breaking-changes with -fsycl // RUN: %clang -### -fsycl --no-offload-new-driver -fpreview-breaking-changes -target x86_64-unknown-windows-msvc -Xclang --dependent-lib=msvcrtd %s 2>&1 | FileCheck -check-prefix FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK %s // RUN: %clang_cl -### -fsycl --no-offload-new-driver -fpreview-breaking-changes /MDd %s 2>&1 | FileCheck -check-prefix FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK %s -// FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK: --dependent-lib=sycl{{[0-9]*}}-preview +// FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK: --dependent-lib=sycl{{[0-9]*}}-previewd // FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK-NOT: -defaultlib:sycl{{[0-9]*}}.lib // FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK-NOT: -defaultlib:sycl{{[0-9]*}}-preview.lib diff --git a/clang/test/Driver/sycl-offload.c b/clang/test/Driver/sycl-offload.c index c19089342622d..56d44faa1efa3 100644 --- a/clang/test/Driver/sycl-offload.c +++ b/clang/test/Driver/sycl-offload.c @@ -560,7 +560,7 @@ /// Check for linked sycl lib when using -fpreview-breaking-changes with -fsycl // RUN: %clang -### -fsycl --offload-new-driver -fpreview-breaking-changes -target x86_64-unknown-windows-msvc -Xclang --dependent-lib=msvcrtd %s 2>&1 | FileCheck -check-prefix FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK %s // RUN: %clang_cl -### -fsycl --offload-new-driver -fpreview-breaking-changes /MDd %s 2>&1 | FileCheck -check-prefix FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK %s -// FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK: --dependent-lib=sycl{{[0-9]*}}-preview +// FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK: --dependent-lib=sycl{{[0-9]*}}-previewd // FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK-NOT: -defaultlib:sycl{{[0-9]*}}.lib // FSYCL-PREVIEW-BREAKING-CHANGES-DEBUG-CHECK-NOT: -defaultlib:sycl{{[0-9]*}}-preview.lib From 598d724a2c270486d9a2bf3260b876bdc4ee737a Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 28 Apr 2025 01:37:10 -0700 Subject: [PATCH 07/35] Remove xptifwd target Signed-off-by: Larsen, Steffen --- sycl/test-e2e/lit.cfg.py | 4 ++-- xptifw/src/CMakeLists.txt | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 72b74a6abe144..70198d9f983cf 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -747,7 +747,7 @@ def remove_level_zero_suffix(devices): 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_DEBUG if config.build_mode == "Debug" in config.cxx_flags else XPTIFW_RELEASE ) xptifw_dispatcher = os.path.join( config.dpcpp_root_dir, "bin", xptifw_dispatcher_name + ".dll" @@ -760,7 +760,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.build_mode == "Debug" in config.cxx_flags else XPTIFW_RELEASE xptifw_lib = os.path.normpath( os.path.join(xptifw_lib_dir, xptifw_lib_name + ".lib") ) diff --git a/xptifw/src/CMakeLists.txt b/xptifw/src/CMakeLists.txt index affb28f161aea..96adcb7ab4ce3 100644 --- a/xptifw/src/CMakeLists.txt +++ b/xptifw/src/CMakeLists.txt @@ -68,10 +68,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() From 29ab725dcd507e7b089aad1f948b153dd9f68556 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 28 Apr 2025 02:24:57 -0700 Subject: [PATCH 08/35] Revert MSVC toolchain changes Signed-off-by: Larsen, Steffen --- clang/lib/Driver/ToolChains/MSVC.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index 0b471d461fc52..98f63a1c0f4bd 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -109,9 +109,9 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA, if (!isDependentLibAdded(Args, "msvcrtd")) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION - "d-preview.lib"); + "-preview.lib"); else - CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION "d.lib"); + CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION ".lib"); } CmdArgs.push_back("-defaultlib:sycl-devicelib-host.lib"); } From f2c032d0446036be4dad25c12db71eef4a3a4c23 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 28 Apr 2025 02:40:14 -0700 Subject: [PATCH 09/35] Fix formatting Signed-off-by: Larsen, Steffen --- clang/lib/Driver/ToolChains/MSVC.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index 98f63a1c0f4bd..1ef469bd6bcb7 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -108,8 +108,7 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA, // equivalent. Do not add the -defaultlib as it conflicts. if (!isDependentLibAdded(Args, "msvcrtd")) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) - CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION - "-preview.lib"); + CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION "-preview.lib"); else CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION ".lib"); } From 68889c0de8df9ab8e753945f1ef5078f4ea8219c Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 28 Apr 2025 02:54:55 -0700 Subject: [PATCH 10/35] Fix more formatting Signed-off-by: Larsen, Steffen --- sycl/test-e2e/lit.cfg.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 70198d9f983cf..672063a5f04a3 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -747,8 +747,10 @@ def remove_level_zero_suffix(devices): elif platform.system() == "Windows": # Use debug version of xptifw library if tests are built with \MDd. xptifw_dispatcher_name = ( - XPTIFW_DEBUG if config.build_mode == "Debug" in config.cxx_flags else XPTIFW_RELEASE - ) + XPTIFW_DEBUG + if config.build_mode == "Debug" in config.cxx_flags + else XPTIFW_RELEASE + ) xptifw_dispatcher = os.path.join( config.dpcpp_root_dir, "bin", xptifw_dispatcher_name + ".dll" ) @@ -760,7 +762,11 @@ 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 config.build_mode == "Debug" in config.cxx_flags else XPTIFW_RELEASE + xptifw_lib_name = ( + XPTIFW_DEBUG + if config.build_mode == "Debug" in config.cxx_flags + else XPTIFW_RELEASE + ) xptifw_lib = os.path.normpath( os.path.join(xptifw_lib_dir, xptifw_lib_name + ".lib") ) From 3f6639da07f134b360f2231f278f7eda5873868b Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 28 Apr 2025 03:11:33 -0700 Subject: [PATCH 11/35] One more formatting patch Signed-off-by: Larsen, Steffen --- sycl/test-e2e/lit.cfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 672063a5f04a3..65c186df9854f 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -750,7 +750,7 @@ def remove_level_zero_suffix(devices): XPTIFW_DEBUG if config.build_mode == "Debug" in config.cxx_flags else XPTIFW_RELEASE - ) + ) xptifw_dispatcher = os.path.join( config.dpcpp_root_dir, "bin", xptifw_dispatcher_name + ".dll" ) From 8e6a9d760c67dde32cafaa4604ed1eb08a0c507a Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 28 Apr 2025 04:41:34 -0700 Subject: [PATCH 12/35] Change OpenCL Windows check Signed-off-by: Larsen, Steffen --- opencl/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opencl/CMakeLists.txt b/opencl/CMakeLists.txt index d11f2c7a246a0..d608aaa64419f 100644 --- a/opencl/CMakeLists.txt +++ b/opencl/CMakeLists.txt @@ -78,7 +78,7 @@ endif() FetchContent_MakeAvailable(ocl-icd) add_library(OpenCL-ICD ALIAS OpenCL) -if (CMAKE_SYSTEM_NAME STREQUAL Windows) +if (WIN32) set_target_properties(OpenCL PROPERTIES DEBUG_POSTFIX d) endif() From 344c638446c25dbdbfafd84f01e3efef3fe68771 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Tue, 29 Apr 2025 03:52:14 -0700 Subject: [PATCH 13/35] Fix ucrt check and ignore OpenCL.dll Signed-off-by: Larsen, Steffen --- opencl/CMakeLists.txt | 4 --- .../win_ucrt/{urct_check.py => ucrt_check.py} | 25 ++++++++++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) rename sycl/test/win_ucrt/{urct_check.py => ucrt_check.py} (63%) diff --git a/opencl/CMakeLists.txt b/opencl/CMakeLists.txt index d608aaa64419f..808fc98c6bcc2 100644 --- a/opencl/CMakeLists.txt +++ b/opencl/CMakeLists.txt @@ -78,8 +78,4 @@ endif() FetchContent_MakeAvailable(ocl-icd) add_library(OpenCL-ICD ALIAS OpenCL) -if (WIN32) - set_target_properties(OpenCL PROPERTIES DEBUG_POSTFIX d) -endif() - add_subdirectory(opencl-aot) diff --git a/sycl/test/win_ucrt/urct_check.py b/sycl/test/win_ucrt/ucrt_check.py similarity index 63% rename from sycl/test/win_ucrt/urct_check.py rename to sycl/test/win_ucrt/ucrt_check.py index 5c27fd429f995..f08d957d97e1a 100644 --- a/sycl/test/win_ucrt/urct_check.py +++ b/sycl/test/win_ucrt/ucrt_check.py @@ -11,26 +11,36 @@ 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 + return 0 has_debug_postfix = filename.endswith("d") or filename.endswith("d-preview") dep_output = subprocess.run( ["dumpbin", "/dependents", filepath], shell=False, capture_output=True ) - if str(dep_output.stdout).find("ucrtbased.dll"): + if str(dep_output.stdout).find("ucrtbased.dll") != -1: if not has_debug_postfix: print("Unexpected use of ucrtbased.dll:", filepath) - sys.exit(1) - elif str(dep_output.stdout).find("ucrtbase.dll"): + return 1 + elif str(dep_output.stdout).find("ucrtbase.dll") != -1: if has_debug_postfix: print("Unexpected use of ucrtbase.dll:", filepath) - sys.exit(1) + 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__": @@ -39,7 +49,10 @@ def check_file(filepath): 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(): - check_file(entry.name) + failures += check_file(entry.name) + if failures > 0: + exit(failures) From 015b566a38326be6101c57495fb826ee2ea8ec59 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Tue, 29 Apr 2025 04:27:48 -0700 Subject: [PATCH 14/35] Add E2E debug library option Signed-off-by: Larsen, Steffen --- sycl/test-e2e/README.md | 3 +++ sycl/test-e2e/lit.cfg.py | 14 +++++--------- sycl/test-e2e/lit.site.cfg.py.in | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/sycl/test-e2e/README.md b/sycl/test-e2e/README.md index bcca7dfdf38de..a4e52759c17f9 100644 --- a/sycl/test-e2e/README.md +++ b/sycl/test-e2e/README.md @@ -203,6 +203,9 @@ or via the ***LIT_OPTS*** environment variable. compilation command line for GPU device. If not specified "-device *" value is used. +***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/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 65c186df9854f..a6425a8790616 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -301,7 +301,7 @@ def open_check_file(file_name): config.available_features.add("has_ndebug") # Check if the current build mode is debug. -if config.build_mode == "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" @@ -542,7 +542,7 @@ 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"))) + " /I" + config.sycl_include + " /I" @@ -560,7 +560,7 @@ 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") + " -I" + config.sycl_include + " -I" @@ -747,9 +747,7 @@ def remove_level_zero_suffix(devices): elif platform.system() == "Windows": # Use debug version of xptifw library if tests are built with \MDd. xptifw_dispatcher_name = ( - XPTIFW_DEBUG - if config.build_mode == "Debug" in config.cxx_flags - else XPTIFW_RELEASE + XPTIFW_DEBUG if config.use_debug_libs else XPTIFW_RELEASE ) xptifw_dispatcher = os.path.join( config.dpcpp_root_dir, "bin", xptifw_dispatcher_name + ".dll" @@ -763,9 +761,7 @@ def remove_level_zero_suffix(devices): if cl_options: # Use debug version of xptifw library if tests are built with \MDd. xptifw_lib_name = ( - XPTIFW_DEBUG - if config.build_mode == "Debug" in config.cxx_flags - else XPTIFW_RELEASE + 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 90389048c6099..22c0233e48479 100644 --- a/sycl/test-e2e/lit.site.cfg.py.in +++ b/sycl/test-e2e/lit.site.cfg.py.in @@ -48,7 +48,7 @@ config.vulkan_include_dir = "@Vulkan_INCLUDE_DIRS@" config.vulkan_lib = "@Vulkan_LIBRARY@" config.vulkan_found = "@Vulkan_FOUND@" -config.build_mode = "@CMAKE_BUILD_TYPE@" +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@" From 651a60d56f20eb6e18ca7aedb4b1197cd9191f72 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Tue, 29 Apr 2025 04:46:53 -0700 Subject: [PATCH 15/35] Fix formatting Signed-off-by: Larsen, Steffen --- sycl/test-e2e/lit.cfg.py | 22 ++++++++++++++-------- sycl/test/win_ucrt/ucrt_check.py | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index a6425a8790616..fce1e77857a50 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -542,7 +542,13 @@ def open_check_file(file_name): ( "%sycl_options", " " - + os.path.normpath(os.path.join(config.sycl_libs_dir + "/../lib/" + ("sycl8d.lib" if config.use_debug_libs else "sycl8.lib"))) + + os.path.normpath( + os.path.join( + config.sycl_libs_dir + + "/../lib/" + + ("sycl8d.lib" if config.use_debug_libs else "sycl8.lib") + ) + ) + " /I" + config.sycl_include + " /I" @@ -560,7 +566,11 @@ def open_check_file(file_name): config.substitutions.append( ( "%sycl_options", - ((" -lsycl8d" if config.use_debug_libs else " -lsycl8") if platform.system() == "Windows" else " -lsycl") + ( + (" -lsycl8d" if config.use_debug_libs else " -lsycl8") + if platform.system() == "Windows" + else " -lsycl" + ) + " -I" + config.sycl_include + " -I" @@ -746,9 +756,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 config.use_debug_libs 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" ) @@ -760,9 +768,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 config.use_debug_libs 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/win_ucrt/ucrt_check.py b/sycl/test/win_ucrt/ucrt_check.py index f08d957d97e1a..4e51c2702737a 100644 --- a/sycl/test/win_ucrt/ucrt_check.py +++ b/sycl/test/win_ucrt/ucrt_check.py @@ -16,6 +16,7 @@ # the compiler release packages. exclude_list = {"OpenCL.dll"} + def check_file(filepath): filename, file_ext = os.path.splitext(entry.name) From 04f3a658dd0ac3c6d6ea06617ab7a9f0a443f7f5 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Tue, 29 Apr 2025 08:11:57 -0700 Subject: [PATCH 16/35] Try fix tests Signed-off-by: Larsen, Steffen --- sycl/test-e2e/Regression/compile_on_win_with_mdd.cpp | 2 +- sycl/test/regression/std_array_vec_constructor.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 823b4dc179cfd..41431d3a45f2c 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, debug_sycl_library +// REQUIRES: windows && debug_sycl_library // 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 diff --git a/sycl/test/regression/std_array_vec_constructor.cpp b/sycl/test/regression/std_array_vec_constructor.cpp index eefd1658e43d4..6c2fc1eac1b97 100644 --- a/sycl/test/regression/std_array_vec_constructor.cpp +++ b/sycl/test/regression/std_array_vec_constructor.cpp @@ -1,6 +1,6 @@ // Test to isolate sycl::vec bug due to use of std::array in // the constructor. -// REQUIRES: windows +// REQUIRES: windows && debug_sycl_library // RUN: not %clangxx -O0 -fsycl -D_DEBUG -shared %s &> %t.compile.log // RUN: FileCheck %s -input-file=%t.compile.log From 5b4a74ce7258119abbcea6bb34ef7a73ad1114bb Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Wed, 30 Apr 2025 22:58:40 -0700 Subject: [PATCH 17/35] Only build and run /MDd test in full mode Signed-off-by: Larsen, Steffen --- sycl/test-e2e/Regression/compile_on_win_with_mdd.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 41431d3a45f2c..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 && debug_sycl_library +// 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 From 7a2a9e4f62ec36adab890e98a9ee306a019be957 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Tue, 6 May 2025 22:33:56 -0700 Subject: [PATCH 18/35] Change WIN32 to checking system name Signed-off-by: Larsen, Steffen --- sycl/source/CMakeLists.txt | 4 ++-- sycl/ur_win_proxy_loader/CMakeLists.txt | 2 +- unified-runtime/cmake/helpers.cmake | 2 +- unified-runtime/source/common/CMakeLists.txt | 4 ++-- unified-runtime/source/loader/CMakeLists.txt | 2 +- unified-runtime/source/mock/CMakeLists.txt | 2 +- xptifw/src/CMakeLists.txt | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 831700259107a..1e0b9bb8f5590 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -354,14 +354,14 @@ if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) 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 (WIN32) +if (CMAKE_SYSTEM_NAME STREQUAL Windows) set_target_properties(${LIB_NAME} PROPERTIES DEBUG_POSTFIX d) if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB AND (CMAKE_BUILD_TYPE STREQUAL Debug)) set_target_properties(sycl${SYCL_MAJOR_VERSION}-preview PROPERTIES OUTPUT_NAME sycl${SYCL_MAJOR_VERSION}d-preview) diff --git a/sycl/ur_win_proxy_loader/CMakeLists.txt b/sycl/ur_win_proxy_loader/CMakeLists.txt index 27537602e46aa..65421deffc4d4 100644 --- a/sycl/ur_win_proxy_loader/CMakeLists.txt +++ b/sycl/ur_win_proxy_loader/CMakeLists.txt @@ -12,7 +12,7 @@ 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 (WIN32) +if (CMAKE_SYSTEM_NAME STREQUAL Windows) set_target_properties(ur_win_proxy_loader PROPERTIES DEBUG_POSTFIX d) if(CMAKE_BUILD_TYPE STREQUAL Debug) target_compile_definitions(ur_win_proxy_loader PRIVATE UR_WIN_PROXY_LOADER_DEBUG_POSTFIX) diff --git a/unified-runtime/cmake/helpers.cmake b/unified-runtime/cmake/helpers.cmake index 12558240f4bdb..1af00c658e9e0 100644 --- a/unified-runtime/cmake/helpers.cmake +++ b/unified-runtime/cmake/helpers.cmake @@ -197,7 +197,7 @@ function(add_ur_library name) $<$,link.exe>:LINKER:/DEPENDENTLOADFLAG:0x2000> ) endif() - if(WIN32) + if(CMAKE_SYSTEM_NAME STREQUAL Windows) set_target_properties(${name} PROPERTIES DEBUG_POSTFIX d) endif() if(UR_EXTERNAL_DEPENDENCIES) diff --git a/unified-runtime/source/common/CMakeLists.txt b/unified-runtime/source/common/CMakeLists.txt index bbbcb55259894..f8c809e33c13b 100644 --- a/unified-runtime/source/common/CMakeLists.txt +++ b/unified-runtime/source/common/CMakeLists.txt @@ -73,7 +73,7 @@ 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 (WIN32) + if (CMAKE_SYSTEM_NAME STREQUAL Windows) if(CMAKE_BUILD_TYPE STREQUAL Debug) set(UMF_USE_DEBUG_POSTFIX ON) endif() @@ -134,6 +134,6 @@ target_link_libraries(ur_umf INTERFACE umf::headers ) -if (WIN32) +if (CMAKE_SYSTEM_NAME STREQUAL Windows) set_target_properties(ur_umf PROPERTIES DEBUG_POSTFIX d) endif() diff --git a/unified-runtime/source/loader/CMakeLists.txt b/unified-runtime/source/loader/CMakeLists.txt index 848ad18e2dc10..4be0519433f4b 100644 --- a/unified-runtime/source/loader/CMakeLists.txt +++ b/unified-runtime/source/loader/CMakeLists.txt @@ -21,7 +21,7 @@ add_ur_library(ur_loader ) install_ur_library(ur_loader) -if (WIN32) +if (CMAKE_SYSTEM_NAME STREQUAL Windows) if(CMAKE_BUILD_TYPE STREQUAL Debug) target_compile_definitions(ur_loader PRIVATE UR_USE_DEBUG_POSTFIX=1) endif() diff --git a/unified-runtime/source/mock/CMakeLists.txt b/unified-runtime/source/mock/CMakeLists.txt index 6133e824678f3..affb350dadbdb 100644 --- a/unified-runtime/source/mock/CMakeLists.txt +++ b/unified-runtime/source/mock/CMakeLists.txt @@ -6,7 +6,7 @@ add_library (ur_mock_headers SHARED "${CMAKE_CURRENT_SOURCE_DIR}/ur_mock_helpers.cpp") -if(WIN32) +if(CMAKE_SYSTEM_NAME STREQUAL Windows) set_target_properties(ur_mock_headers PROPERTIES DEBUG_POSTFIX d) endif() diff --git a/xptifw/src/CMakeLists.txt b/xptifw/src/CMakeLists.txt index 96adcb7ab4ce3..2d7e67ab2ef01 100644 --- a/xptifw/src/CMakeLists.txt +++ b/xptifw/src/CMakeLists.txt @@ -55,7 +55,7 @@ function(add_xpti_library LIB_NAME) 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() - if (WIN32) + if (CMAKE_SYSTEM_NAME STREQUAL Windows) set_target_properties(${LIB_NAME} PROPERTIES DEBUG_POSTFIX d) endif() From b1a29bc63e511bb8cb32cad3a370a50beadbe3b5 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Tue, 20 May 2025 21:47:27 -0700 Subject: [PATCH 19/35] Add option for debug CRT in release Signed-off-by: Larsen, Steffen --- buildbot/configure.py | 6 ++++ opencl/CMakeLists.txt | 6 ++++ sycl/source/CMakeLists.txt | 28 +++++++++++-------- sycl/test/abi/preview_lib_marker.cpp | 4 +-- sycl/test/abi/symbol_size_alignment.cpp | 2 +- .../accessor/accessor_default_ctor.cpp | 2 +- .../accessor/accessor_property_list_rt.cpp | 2 +- .../accessor/host-acc-assign-op.cpp | 2 +- .../basic_tests/accessor/target_device.cpp | 2 +- .../builtins/relational_builtins.cpp | 2 +- sycl/test/basic_tests/code_location.cpp | 4 +-- .../device-selectors-exception.cpp | 4 +-- .../device_config_file_aspects.cpp | 2 +- sycl/test/basic_tests/group.cpp | 2 +- .../basic_tests/host_image_accessor_read.cpp | 2 +- sycl/test/basic_tests/id.cpp | 4 +-- sycl/test/basic_tests/item.cpp | 2 +- sycl/test/basic_tests/marray/marray.cpp | 2 +- sycl/test/basic_tests/nd_range.cpp | 2 +- sycl/test/basic_tests/range.cpp | 2 +- .../test/basic_tests/sycl_maximum_minimum.cpp | 2 +- sycl/test/basic_tests/temp-assign-guard.cpp | 2 +- .../basic_tests/vectors/size_one_checks.cpp | 4 +-- sycl/test/basic_tests/vectors/swizzle.cpp | 2 +- sycl/test/basic_tests/vectors/vectors.cpp | 4 +-- sycl/test/esimd/odr.cpp | 6 ++-- .../device_architecture.cpp | 2 +- .../properties/properties_get_property.cpp | 2 +- sycl/test/invoke_simd/return-type-uniform.cpp | 2 +- sycl/test/lit.cfg.py | 15 ++++++---- sycl/test/lit.site.cfg.py.in | 2 +- sycl/test/matrix/compile-query.cpp | 2 +- .../matrix-bfloat16-test-coord-basicB.cpp | 2 +- sycl/test/matrix/matrix-bfloat16-test.cpp | 2 +- sycl/test/matrix/matrix-elemwise-ops.cpp | 2 +- sycl/test/matrix/matrix-tf32-test.cpp | 2 +- sycl/test/regression/abs_diff_host.cpp | 4 +-- .../atomic_ref_assignment_ambiguity.cpp | 2 +- sycl/test/regression/bit_cast_win.cpp | 2 +- .../regression/check_config_processing.cpp | 2 +- sycl/test/regression/fsycl-save-temps.cpp | 2 +- .../regression/half_host_subnormal_min.cpp | 2 +- sycl/test/regression/host_half_nextafter.cpp | 2 +- .../regression/host_tanpi_double_accuracy.cpp | 2 +- sycl/test/scheduler/GetWaitList.cpp | 2 +- sycl/ur_win_proxy_loader/CMakeLists.txt | 5 +++- unified-runtime/cmake/FetchLevelZero.cmake | 6 ++-- unified-runtime/cmake/helpers.cmake | 6 ++-- .../source/adapters/CMakeLists.txt | 6 +++- unified-runtime/source/common/CMakeLists.txt | 5 +++- unified-runtime/source/loader/CMakeLists.txt | 4 +-- unified-runtime/source/mock/CMakeLists.txt | 3 ++ xptifw/src/CMakeLists.txt | 6 ++-- 53 files changed, 115 insertions(+), 81 deletions(-) diff --git a/buildbot/configure.py b/buildbot/configure.py index 30fcfe8afc8b2..3f1cc465f81e1 100644 --- a/buildbot/configure.py +++ b/buildbot/configure.py @@ -234,6 +234,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 @@ -423,6 +426,9 @@ def main(): parser.add_argument( "--use-zstd", action="store_true", help="Force zstd linkage while building." ) + 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() print("args:{}".format(args)) diff --git a/opencl/CMakeLists.txt b/opencl/CMakeLists.txt index 808fc98c6bcc2..e3e406ae0af75 100644 --- a/opencl/CMakeLists.txt +++ b/opencl/CMakeLists.txt @@ -11,6 +11,9 @@ if (MSVC) ) endif() +# Backup MSVC runtime option +set(CMAKE_MSVC_RUNTIME_LIBRARY_BAK "${CMAKE_MSVC_RUNTIME_LIBRARY}") + # Repo URLs set(OCL_HEADERS_REPO @@ -78,4 +81,7 @@ endif() FetchContent_MakeAvailable(ocl-icd) add_library(OpenCL-ICD ALIAS OpenCL) +# Restore MSVC runtime option +set(CMAKE_MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY_BAK}") + add_subdirectory(opencl-aot) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 5edcde697cabc..3648ae71ad1bf 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -227,12 +227,6 @@ function(add_sycl_rt_library LIB_TARGET_NAME LIB_OBJ_NAME LIB_OUTPUT_NAME) file(REMOVE ${VERSION_FILE}) endif() endif() - - # Ensure that we use the dynamic CRT on Windows, i.e. /MD or /MDd. - set_target_properties(${LIB_TARGET_NAME} PROPERTIES - MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - set_target_properties(${LIB_OBJ_NAME} PROPERTIES - MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") endfunction(add_sycl_rt_library) set(SYCL_COMMON_SOURCES @@ -343,17 +337,23 @@ if (HAS_SEMANTIC_INTERPOSITION_FLAG AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) endif() if (WIN32) -set(LIB_NAME "sycl${SYCL_MAJOR_VERSION}") -set(LIB_OUTPUT_NAME "${LIB_NAME}$<$:d>") + set(LIB_NAME "sycl${SYCL_MAJOR_VERSION}") + set(LIB_OUTPUT_NAME "${LIB_NAME}") + if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set(LIB_OUTPUT_NAME "${LIB_OUTPUT_NAME}d") + endif() else() -set(LIB_NAME "sycl") -set(LIB_OUTPUT_NAME "${LIB_NAME}") + set(LIB_NAME "sycl") + set(LIB_OUTPUT_NAME "${LIB_NAME}") endif() set(LIB_PREVIEW_NAME ${LIB_NAME}-preview) set(LIB_PREVIEW_OUTPUT_NAME ${LIB_OUTPUT_NAME}-preview) # Version-agnostic name of the import library, has effect on Windows only. -set(IMPLIB_NAME "sycl$<$:d>") +set(IMPLIB_NAME "sycl") +if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set(IMPLIB_NAME "${IMPLIB_NAME}d") +endif() set(IMPLIB_PREVIEW_NAME "${IMPLIB_NAME}-preview") add_sycl_rt_library(${LIB_NAME} sycl_object ${LIB_OUTPUT_NAME} @@ -378,7 +378,11 @@ endif() if (CMAKE_SYSTEM_NAME STREQUAL Windows) set_target_properties(${LIB_NAME} PROPERTIES DEBUG_POSTFIX d) - if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB AND (CMAKE_BUILD_TYPE STREQUAL Debug)) + if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set_target_properties(${LIB_NAME} PROPERTIES RELEASE_POSTFIX d) + endif() + if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB AND + (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL)) set_target_properties(sycl${SYCL_MAJOR_VERSION}-preview PROPERTIES OUTPUT_NAME sycl${SYCL_MAJOR_VERSION}d-preview) endif() endif() 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/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 7f74819e77181..94fe21a63318d 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 #include diff --git a/sycl/test/basic_tests/accessor/target_device.cpp b/sycl/test/basic_tests/accessor/target_device.cpp index edf0f3595976c..858c94de1ad09 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 // This short test simply confirms that target::device // is supported correctly. diff --git a/sycl/test/basic_tests/builtins/relational_builtins.cpp b/sycl/test/basic_tests/builtins/relational_builtins.cpp index eabd7e26c35cb..36820eef716ce 100644 --- a/sycl/test/basic_tests/builtins/relational_builtins.cpp +++ b/sycl/test/basic_tests/builtins/relational_builtins.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl %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 %} // NOTE: Compile the test fully to ensure the library exports the right host 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 2256b7f4745b8..55557840ea885 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 da08b87e60a2b..a7812f2d0adec 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 c72eef464b625..93e1dc65e5d93 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 //==--------------- group.cpp - SYCL group test ----------------------------==// diff --git a/sycl/test/basic_tests/host_image_accessor_read.cpp b/sycl/test/basic_tests/host_image_accessor_read.cpp index 97f32e077a6a0..90d72ce84fa8a 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 //==---- host_image_accessor_read.cpp - SYCL host image accessor check ----==// diff --git a/sycl/test/basic_tests/id.cpp b/sycl/test/basic_tests/id.cpp index 4be7959ab5631..0d6272190ed2a 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 //==--------------- id.cpp - SYCL id test ----------------------------------==// diff --git a/sycl/test/basic_tests/item.cpp b/sycl/test/basic_tests/item.cpp index 2952628976b9a..433777f8e90d4 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 //==--------------- item.cpp - SYCL item test ------------------------------==// // 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 0312245920fa0..77d09d549d31f 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 //==--------------- range.cpp - SYCL range test ----------------------------==// // 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 2b288b01c0bb5..2521c244cca93 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 %} //==--------------- vectors.cpp - SYCL vectors test ------------------------==// diff --git a/sycl/test/esimd/odr.cpp b/sycl/test/esimd/odr.cpp index ae6891149886c..2c99038202da6 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 #include #include diff --git a/sycl/test/extensions/device_architecture/device_architecture.cpp b/sycl/test/extensions/device_architecture/device_architecture.cpp index bf11327fbba44..f8d8d34014160 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 #include #include 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 13be728f32d25..f4d3f627b00ca 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 #include #include #include diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index f1b97ad4c1556..04c653ab4158d 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -70,7 +70,7 @@ config.available_features.add("preview-breaking-changes-supported") # Check if the current build mode is debug. -if config.build_mode == "Debug": +if config.use_debug_win_crt: config.available_features.add("debug_sycl_library") # Configure LD_LIBRARY_PATH or corresponding os-specific alternatives @@ -141,12 +141,18 @@ sycl_host_only_options += " -isystem %s" % include_dir config.substitutions.append(("%fsycl-host-only", sycl_host_only_options)) +fsycl_opt = "-fsycl" if platform.system() == "Windows": config.substitutions.append( - ("%sycl_lib", " -lsycl8d" if config.build_mode == "Debug" else " -lsycl8") + ("%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 + " -g" else: config.substitutions.append(("%sycl_lib", "-lsycl")) +config.substitutions.append(("%fsycl", fsycl_opt)) llvm_config.add_tool_substitutions(["llvm-spirv"], [config.sycl_tools_dir]) @@ -209,9 +215,6 @@ try: import psutil - if config.build_mode != "Debug": - lit_config.maxIndividualTestTime = 600 - else: - lit_config.maxIndividualTestTime = 1200 + lit_config.maxIndividualTestTime = 600 except ImportError: pass diff --git a/sycl/test/lit.site.cfg.py.in b/sycl/test/lit.site.cfg.py.in index 3da06e7ed9134..6ce1926aa4bf1 100644 --- a/sycl/test/lit.site.cfg.py.in +++ b/sycl/test/lit.site.cfg.py.in @@ -36,7 +36,7 @@ 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.build_mode = "@CMAKE_BUILD_TYPE@" +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 baefb8d602487..93fab94ff7e92 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 // Kernel B sum by col #include diff --git a/sycl/test/matrix/matrix-bfloat16-test.cpp b/sycl/test/matrix/matrix-bfloat16-test.cpp index 4a3b316dac154..d6d979ceb68ad 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 #include #include diff --git a/sycl/test/matrix/matrix-elemwise-ops.cpp b/sycl/test/matrix/matrix-elemwise-ops.cpp index fc75cab241287..b426848c1ae46 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 #include #include diff --git a/sycl/test/matrix/matrix-tf32-test.cpp b/sycl/test/matrix/matrix-tf32-test.cpp index 5e8413346c3d0..12762b9531c42 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 #include #include 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..ea20e7fd90e7a 100644 --- a/sycl/test/regression/bit_cast_win.cpp +++ b/sycl/test/regression/bit_cast_win.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-host-compiler=cl -fsycl-host-compiler-options='/std:c++17 /Zc:__cplusplus' %s -o %t.out +// RUN: %clangxx %fsycl -fsycl-host-compiler=cl -fsycl-host-compiler-options='/std:c++17 /Zc:__cplusplus' %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 f2cb4a61f8799..34cb60c63fd8c 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 41a2b3a2c21a4..984da747ef997 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 #include 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/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/ur_win_proxy_loader/CMakeLists.txt b/sycl/ur_win_proxy_loader/CMakeLists.txt index 65421deffc4d4..eb00bd50ac24c 100644 --- a/sycl/ur_win_proxy_loader/CMakeLists.txt +++ b/sycl/ur_win_proxy_loader/CMakeLists.txt @@ -14,7 +14,10 @@ configure_file(../../llvm/resources/windows_version_resource.rc ${CMAKE_CURRENT_ add_library(ur_win_proxy_loader SHARED ur_win_proxy_loader.cpp ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc) if (CMAKE_SYSTEM_NAME STREQUAL Windows) set_target_properties(ur_win_proxy_loader PROPERTIES DEBUG_POSTFIX d) - if(CMAKE_BUILD_TYPE STREQUAL Debug) + if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set_target_properties(ur_win_proxy_loader PROPERTIES RELEASE_POSTFIX d) + endif() + if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) target_compile_definitions(ur_win_proxy_loader PRIVATE UR_WIN_PROXY_LOADER_DEBUG_POSTFIX) endif() endif() diff --git a/unified-runtime/cmake/FetchLevelZero.cmake b/unified-runtime/cmake/FetchLevelZero.cmake index cf1ca5e8235bf..6a591cad0e559 100644 --- a/unified-runtime/cmake/FetchLevelZero.cmake +++ b/unified-runtime/cmake/FetchLevelZero.cmake @@ -56,8 +56,10 @@ if (NOT DEFINED LEVEL_ZERO_LIBRARY OR NOT DEFINED LEVEL_ZERO_INCLUDE_DIR) 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") + if (NOT CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$") + # UMF has not yet been able to build as static + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") + endif() message(STATUS "Level Zero Adapter: Will fetch Level Zero Loader from ${UR_LEVEL_ZERO_LOADER_REPO}") include(FetchContent) FetchContent_Declare(level-zero-loader diff --git a/unified-runtime/cmake/helpers.cmake b/unified-runtime/cmake/helpers.cmake index 1af00c658e9e0..ccf5055f28a02 100644 --- a/unified-runtime/cmake/helpers.cmake +++ b/unified-runtime/cmake/helpers.cmake @@ -120,9 +120,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 @@ -199,6 +196,9 @@ function(add_ur_library name) endif() if(CMAKE_SYSTEM_NAME STREQUAL Windows) set_target_properties(${name} PROPERTIES DEBUG_POSTFIX d) + if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set_target_properties(${name} PROPERTIES RELEASE_POSTFIX d) + endif() 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 3270c74f7707c..d3cb53be3c841 100644 --- a/unified-runtime/source/adapters/CMakeLists.txt +++ b/unified-runtime/source/adapters/CMakeLists.txt @@ -6,7 +6,7 @@ function(add_ur_adapter name) add_ur_library(${name} ${ARGN}) if(MSVC) - if(CMAKE_BUILD_TYPE STREQUAL Debug) + if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) set(TARGET_LIBNAME ${name}d) else() set(TARGET_LIBNAME ${name}) @@ -32,6 +32,10 @@ function(add_ur_adapter name) endif() if(WIN32) set_target_properties(${name} PROPERTIES DEBUG_POSTFIX d) + if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set_target_properties(${name} PROPERTIES RELEASE_POSTFIX d) + set_target_properties(${name} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL") + endif() endif() add_dependencies(ur_loader ${name}) endfunction() diff --git a/unified-runtime/source/common/CMakeLists.txt b/unified-runtime/source/common/CMakeLists.txt index f8c809e33c13b..4f5539364aa65 100644 --- a/unified-runtime/source/common/CMakeLists.txt +++ b/unified-runtime/source/common/CMakeLists.txt @@ -74,7 +74,7 @@ else() 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) + if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) set(UMF_USE_DEBUG_POSTFIX ON) endif() endif() @@ -136,4 +136,7 @@ target_link_libraries(ur_umf INTERFACE if (CMAKE_SYSTEM_NAME STREQUAL Windows) set_target_properties(ur_umf PROPERTIES DEBUG_POSTFIX d) + if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set_target_properties(ur_umf PROPERTIES RELEASE_POSTFIX d) + endif() endif() diff --git a/unified-runtime/source/loader/CMakeLists.txt b/unified-runtime/source/loader/CMakeLists.txt index 0b24565cf3fc9..517650e60a5fe 100644 --- a/unified-runtime/source/loader/CMakeLists.txt +++ b/unified-runtime/source/loader/CMakeLists.txt @@ -22,13 +22,13 @@ add_ur_library(ur_loader install_ur_library(ur_loader) if (CMAKE_SYSTEM_NAME STREQUAL Windows) - if(CMAKE_BUILD_TYPE STREQUAL Debug) + 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) - if(CMAKE_BUILD_TYPE STREQUAL Debug) + if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) set(TARGET_LIBNAME ur_loaderd) else() set(TARGET_LIBNAME ur_loader) diff --git a/unified-runtime/source/mock/CMakeLists.txt b/unified-runtime/source/mock/CMakeLists.txt index affb350dadbdb..102e6f456a9f2 100644 --- a/unified-runtime/source/mock/CMakeLists.txt +++ b/unified-runtime/source/mock/CMakeLists.txt @@ -8,6 +8,9 @@ add_library (ur_mock_headers SHARED if(CMAKE_SYSTEM_NAME STREQUAL Windows) set_target_properties(ur_mock_headers PROPERTIES DEBUG_POSTFIX d) + if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set_target_properties(ur_mock_headers PROPERTIES RELEASE_POSTFIX d) + endif() endif() target_include_directories(ur_mock_headers diff --git a/xptifw/src/CMakeLists.txt b/xptifw/src/CMakeLists.txt index 8b08f871827cf..6f652c58e3d38 100644 --- a/xptifw/src/CMakeLists.txt +++ b/xptifw/src/CMakeLists.txt @@ -32,9 +32,6 @@ function(add_xpti_library LIB_NAME) remove_definitions(-DXPTI_STATIC_LIBRARY) add_library(${LIB_NAME} SHARED ${SOURCES}) - set_target_properties(${LIB_NAME} PROPERTIES - MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - target_compile_definitions(${LIB_NAME} PRIVATE -DXPTI_API_EXPORTS) target_include_directories(${LIB_NAME} PUBLIC $ @@ -58,6 +55,9 @@ function(add_xpti_library LIB_NAME) if (CMAKE_SYSTEM_NAME STREQUAL Windows) set_target_properties(${LIB_NAME} PROPERTIES DEBUG_POSTFIX d) + if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set_target_properties(${LIB_NAME} PROPERTIES RELEASE_POSTFIX d) + endif() endif() # Set the location of the library installation From 00c606244c32ff42906db28f4108e2d2f3983801 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Wed, 21 May 2025 23:53:25 -0700 Subject: [PATCH 20/35] Fix formatting Signed-off-by: Larsen, Steffen --- buildbot/configure.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/buildbot/configure.py b/buildbot/configure.py index 3f1cc465f81e1..580d9b98a79a2 100644 --- a/buildbot/configure.py +++ b/buildbot/configure.py @@ -427,7 +427,9 @@ def main(): "--use-zstd", action="store_true", help="Force zstd linkage while building." ) parser.add_argument( - "--use-debug-crt-dll", action="store_true", help="Link libraries with MSVC debug dll in release mode." + "--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() From d779890e1f37221ee31b463fe9834aa7df0aa11f Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 22 May 2025 02:18:50 -0700 Subject: [PATCH 21/35] Remove unnecessary UCRT propagation Signed-off-by: Larsen, Steffen --- unified-runtime/source/adapters/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/unified-runtime/source/adapters/CMakeLists.txt b/unified-runtime/source/adapters/CMakeLists.txt index d3cb53be3c841..537715fb26d24 100644 --- a/unified-runtime/source/adapters/CMakeLists.txt +++ b/unified-runtime/source/adapters/CMakeLists.txt @@ -34,7 +34,6 @@ function(add_ur_adapter name) set_target_properties(${name} PROPERTIES DEBUG_POSTFIX d) if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) set_target_properties(${name} PROPERTIES RELEASE_POSTFIX d) - set_target_properties(${name} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL") endif() endif() add_dependencies(ur_loader ${name}) From b1355135ce723285d1b52686bf0a31ae0dc06b13 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 22 May 2025 05:07:05 -0700 Subject: [PATCH 22/35] Fix release build failures Signed-off-by: Larsen, Steffen --- opencl/CMakeLists.txt | 6 ------ unified-runtime/cmake/helpers.cmake | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/opencl/CMakeLists.txt b/opencl/CMakeLists.txt index e3e406ae0af75..808fc98c6bcc2 100644 --- a/opencl/CMakeLists.txt +++ b/opencl/CMakeLists.txt @@ -11,9 +11,6 @@ if (MSVC) ) endif() -# Backup MSVC runtime option -set(CMAKE_MSVC_RUNTIME_LIBRARY_BAK "${CMAKE_MSVC_RUNTIME_LIBRARY}") - # Repo URLs set(OCL_HEADERS_REPO @@ -81,7 +78,4 @@ endif() FetchContent_MakeAvailable(ocl-icd) add_library(OpenCL-ICD ALIAS OpenCL) -# Restore MSVC runtime option -set(CMAKE_MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY_BAK}") - add_subdirectory(opencl-aot) diff --git a/unified-runtime/cmake/helpers.cmake b/unified-runtime/cmake/helpers.cmake index ccf5055f28a02..47719e78d4423 100644 --- a/unified-runtime/cmake/helpers.cmake +++ b/unified-runtime/cmake/helpers.cmake @@ -136,6 +136,12 @@ function(add_ur_target_compile_options name) _CRT_SECURE_NO_WARNINGS # Slience warnings about getenv ) + get_target_property(MSVC_RT_PROP ${name} MSVC_RUNTIME_LIBRARY) + if (NOT CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$" AND NOT MSVC_RT_PROP MATCHES "DLL$") + set_property(TARGET ${name} PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") + endif() + if(UR_DEVELOPER_MODE) target_compile_options(${name} PRIVATE /WX # Enable: Treat all warnings as errors From bc70f4dc1ece83c9f85f70d6beb609309eb02e7c Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 22 May 2025 06:53:33 -0700 Subject: [PATCH 23/35] Fix testing Signed-off-by: Larsen, Steffen --- clang/lib/Driver/ToolChains/Clang.cpp | 4 ++-- sycl/test/basic_tests/builtins/relational_builtins.cpp | 2 +- sycl/test/lit.cfg.py | 2 +- sycl/test/regression/bit_cast_win.cpp | 3 ++- sycl/test/regression/memcpy-in-vec-as.cpp | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index b573ae41882d5..94a02af1e1bf1 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5433,7 +5433,7 @@ static void ProcessVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args, if (RTOptionID == options::OPT__SLASH_MDd) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION - "-previewd"); + "d-preview"); else CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION "d"); } else { @@ -7055,7 +7055,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (isDependentLibAdded(Args, "msvcrtd")) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION - "-previewd"); + "d-preview"); else CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION "d"); } diff --git a/sycl/test/basic_tests/builtins/relational_builtins.cpp b/sycl/test/basic_tests/builtins/relational_builtins.cpp index 36820eef716ce..5cafeed51528b 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: %if preview-breaking-changes-supported %{ %clangxx %fsycl -fpreview-breaking-changes %s -o %t.out %} // NOTE: Compile the test fully to ensure the library exports the right host // symbols. diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index 04c653ab4158d..393d2ea716207 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -149,7 +149,7 @@ 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 + " -g" + fsycl_opt = fsycl_opt + " -Xclang --dependent-lib=msvcrtd" else: config.substitutions.append(("%sycl_lib", "-lsycl")) config.substitutions.append(("%fsycl", fsycl_opt)) diff --git a/sycl/test/regression/bit_cast_win.cpp b/sycl/test/regression/bit_cast_win.cpp index ea20e7fd90e7a..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/memcpy-in-vec-as.cpp b/sycl/test/regression/memcpy-in-vec-as.cpp index f48eb1be44cda..844254171fed5 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 #include #include From ec2568b4c4e07f3a2e7c046dc7a26f424198e350 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 22 May 2025 07:37:12 -0700 Subject: [PATCH 24/35] Fix unintended change in preview library name Signed-off-by: Larsen, Steffen --- clang/lib/Driver/ToolChains/Clang.cpp | 4 ++-- sycl/source/CMakeLists.txt | 5 ++++- sycl/test/win_ucrt/ucrt_check.py | 5 ++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 94a02af1e1bf1..b573ae41882d5 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5433,7 +5433,7 @@ static void ProcessVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args, if (RTOptionID == options::OPT__SLASH_MDd) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION - "d-preview"); + "-previewd"); else CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION "d"); } else { @@ -7055,7 +7055,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (isDependentLibAdded(Args, "msvcrtd")) { if (Args.hasArg(options::OPT_fpreview_breaking_changes)) CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION - "d-preview"); + "-previewd"); else CmdArgs.push_back("--dependent-lib=sycl" SYCL_MAJOR_VERSION "d"); } diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 3648ae71ad1bf..bbfcbeb2441a6 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -383,7 +383,10 @@ if (CMAKE_SYSTEM_NAME STREQUAL Windows) endif() if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB AND (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL)) - set_target_properties(sycl${SYCL_MAJOR_VERSION}-preview PROPERTIES OUTPUT_NAME sycl${SYCL_MAJOR_VERSION}d-preview) + set_target_properties(sycl${SYCL_MAJOR_VERSION}-preview PROPERTIES DEBUG_POSTFIX d) + if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) + set_target_properties(sycl${SYCL_MAJOR_VERSION}-preview PROPERTIES RELEASE_POSTFIX d) + endif() endif() endif() diff --git a/sycl/test/win_ucrt/ucrt_check.py b/sycl/test/win_ucrt/ucrt_check.py index 4e51c2702737a..2314c0267e5e7 100644 --- a/sycl/test/win_ucrt/ucrt_check.py +++ b/sycl/test/win_ucrt/ucrt_check.py @@ -2,8 +2,7 @@ # 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 either "d" or -# "d-preview". +# library uses a the debug URCT it must be postfixed with "d". # import argparse import os @@ -24,7 +23,7 @@ def check_file(filepath): if not (file_ext == ".dll" or file_ext == ".lib"): return 0 - has_debug_postfix = filename.endswith("d") or filename.endswith("d-preview") + has_debug_postfix = filename.endswith("d") dep_output = subprocess.run( ["dumpbin", "/dependents", filepath], shell=False, capture_output=True ) From 15e9a3f367e04093cdb536456e4060e08d2533d2 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 22 May 2025 08:00:22 -0700 Subject: [PATCH 25/35] Fix copy name Signed-off-by: Larsen, Steffen --- sycl/source/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index bbfcbeb2441a6..383ab1f69be66 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -351,10 +351,11 @@ set(LIB_PREVIEW_OUTPUT_NAME ${LIB_OUTPUT_NAME}-preview) # 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() -set(IMPLIB_PREVIEW_NAME "${IMPLIB_NAME}-preview") add_sycl_rt_library(${LIB_NAME} sycl_object ${LIB_OUTPUT_NAME} XPTI_LIB xpti From 16452538f5e0d334ad655ef05bff16a3811f497f Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 22 May 2025 08:16:15 -0700 Subject: [PATCH 26/35] Use %fsycl in changed test Signed-off-by: Larsen, Steffen --- sycl/test/regression/std_array_vec_constructor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test/regression/std_array_vec_constructor.cpp b/sycl/test/regression/std_array_vec_constructor.cpp index 92a3207e0b9f6..5560b566c7edb 100644 --- a/sycl/test/regression/std_array_vec_constructor.cpp +++ b/sycl/test/regression/std_array_vec_constructor.cpp @@ -2,7 +2,7 @@ // the constructor. // 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 From 1f01b9623f145ee456bcc29e988625ecea860f0b Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 22 May 2025 08:24:29 -0700 Subject: [PATCH 27/35] Fix another case of missnamed preview Signed-off-by: Larsen, Steffen --- sycl/source/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 383ab1f69be66..e30be799806cb 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -339,15 +339,18 @@ endif() if (WIN32) 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_OUTPUT_NAME "${LIB_NAME}") + set(LIB_PREVIEW_NAME ${LIB_NAME}-preview) + set(LIB_PREVIEW_OUTPUT_NAME ${LIB_OUTPUT_NAME}-preview) endif() -set(LIB_PREVIEW_NAME ${LIB_NAME}-preview) -set(LIB_PREVIEW_OUTPUT_NAME ${LIB_OUTPUT_NAME}-preview) # Version-agnostic name of the import library, has effect on Windows only. set(IMPLIB_NAME "sycl") From a9f4348bff70d70fac5c98bdac47faf7b6b94cf3 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 23 May 2025 06:31:08 -0700 Subject: [PATCH 28/35] Add debug_sycl_library requirement to std_array test Signed-off-by: Larsen, Steffen --- sycl/test-e2e/Basic/std_array.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test-e2e/Basic/std_array.cpp b/sycl/test-e2e/Basic/std_array.cpp index 12a2fb05160e2..1e1af1124fb60 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 // RUN: %clangxx --driver-mode=cl -fsycl -o %t.exe %s /Od /MDd /Zi /EHsc // RUN: %{run} %t.exe From be444f7d12066fd80ed19ee20bc30a73487f2568 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 23 May 2025 07:25:38 -0700 Subject: [PATCH 29/35] Try conjunction Signed-off-by: Larsen, Steffen --- sycl/test-e2e/Basic/std_array.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test-e2e/Basic/std_array.cpp b/sycl/test-e2e/Basic/std_array.cpp index 1e1af1124fb60..cfbb9b74a553a 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, debug_sycl_library +// REQUIRES: windows && debug_sycl_library // RUN: %clangxx --driver-mode=cl -fsycl -o %t.exe %s /Od /MDd /Zi /EHsc // RUN: %{run} %t.exe From e5988478351dda61d94863dd7d3d7d3e072edac8 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Sun, 25 May 2025 22:11:59 -0700 Subject: [PATCH 30/35] Avoid linking error during build-only Signed-off-by: Larsen, Steffen --- sycl/test-e2e/Basic/std_array.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test-e2e/Basic/std_array.cpp b/sycl/test-e2e/Basic/std_array.cpp index cfbb9b74a553a..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 && debug_sycl_library +// 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 From 82914da864773de2fffc6d8379439e30a6175cd5 Mon Sep 17 00:00:00 2001 From: Steffen Larsen Date: Wed, 28 May 2025 11:51:58 +0200 Subject: [PATCH 31/35] Update sycl/test/lit.cfg.py --- sycl/test/lit.cfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index 393d2ea716207..e64932ed0b9de 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -211,7 +211,7 @@ if not dump_only_tests: llvm_config.use_clang(additional_flags=additional_flags) -# Set timeout for test = 10 mins (Release) or 20 mins (Debug) +# Set timeout for test = 10 mins try: import psutil From 9c474875ab63c642c9d32a82ff427a940790f55a Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Tue, 3 Jun 2025 02:01:22 -0700 Subject: [PATCH 32/35] Make suffix config-independent Signed-off-by: Larsen, Steffen --- sycl/source/CMakeLists.txt | 16 +++++----------- sycl/ur_win_proxy_loader/CMakeLists.txt | 10 +++------- unified-runtime/cmake/helpers.cmake | 8 +++----- unified-runtime/source/adapters/CMakeLists.txt | 8 +++----- unified-runtime/source/common/CMakeLists.txt | 8 +++----- unified-runtime/source/mock/CMakeLists.txt | 8 +++----- xptifw/src/CMakeLists.txt | 8 +++----- 7 files changed, 23 insertions(+), 43 deletions(-) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index e30be799806cb..1cda81664fba9 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -380,17 +380,11 @@ if (CMAKE_SYSTEM_NAME STREQUAL Windows) endif() endif() -if (CMAKE_SYSTEM_NAME STREQUAL Windows) - set_target_properties(${LIB_NAME} PROPERTIES DEBUG_POSTFIX d) - if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) - set_target_properties(${LIB_NAME} PROPERTIES RELEASE_POSTFIX d) - endif() - if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB AND - (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL)) - set_target_properties(sycl${SYCL_MAJOR_VERSION}-preview PROPERTIES DEBUG_POSTFIX d) - if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) - set_target_properties(sycl${SYCL_MAJOR_VERSION}-preview PROPERTIES RELEASE_POSTFIX d) - 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() diff --git a/sycl/ur_win_proxy_loader/CMakeLists.txt b/sycl/ur_win_proxy_loader/CMakeLists.txt index eb00bd50ac24c..9f6e51dcb1ed5 100644 --- a/sycl/ur_win_proxy_loader/CMakeLists.txt +++ b/sycl/ur_win_proxy_loader/CMakeLists.txt @@ -12,14 +12,10 @@ 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) - set_target_properties(ur_win_proxy_loader PROPERTIES DEBUG_POSTFIX d) - if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) - set_target_properties(ur_win_proxy_loader PROPERTIES RELEASE_POSTFIX d) - endif() - if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) +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() endif() add_dependencies(ur_win_proxy_loader UnifiedRuntimeLoader) install(TARGETS ur_win_proxy_loader diff --git a/unified-runtime/cmake/helpers.cmake b/unified-runtime/cmake/helpers.cmake index 47719e78d4423..c7a690911effe 100644 --- a/unified-runtime/cmake/helpers.cmake +++ b/unified-runtime/cmake/helpers.cmake @@ -200,11 +200,9 @@ function(add_ur_library name) $<$,link.exe>:LINKER:/DEPENDENTLOADFLAG:0x2000> ) endif() - if(CMAKE_SYSTEM_NAME STREQUAL Windows) - set_target_properties(${name} PROPERTIES DEBUG_POSTFIX d) - if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) - set_target_properties(${name} PROPERTIES RELEASE_POSTFIX d) - 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() 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 537715fb26d24..62f7bc7a59943 100644 --- a/unified-runtime/source/adapters/CMakeLists.txt +++ b/unified-runtime/source/adapters/CMakeLists.txt @@ -30,11 +30,9 @@ function(add_ur_adapter name) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../adapter.map.in ${ADAPTER_VERSION_SCRIPT} @ONLY) target_link_options(${name} PRIVATE "-Wl,--version-script=${ADAPTER_VERSION_SCRIPT}") endif() - if(WIN32) - set_target_properties(${name} PROPERTIES DEBUG_POSTFIX d) - if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) - set_target_properties(${name} PROPERTIES RELEASE_POSTFIX d) - 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 4f5539364aa65..f23aa842b4526 100644 --- a/unified-runtime/source/common/CMakeLists.txt +++ b/unified-runtime/source/common/CMakeLists.txt @@ -134,9 +134,7 @@ target_link_libraries(ur_umf INTERFACE umf::headers ) -if (CMAKE_SYSTEM_NAME STREQUAL Windows) - set_target_properties(ur_umf PROPERTIES DEBUG_POSTFIX d) - if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) - set_target_properties(ur_umf PROPERTIES RELEASE_POSTFIX d) - endif() +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/mock/CMakeLists.txt b/unified-runtime/source/mock/CMakeLists.txt index 102e6f456a9f2..eee85fcdaea69 100644 --- a/unified-runtime/source/mock/CMakeLists.txt +++ b/unified-runtime/source/mock/CMakeLists.txt @@ -6,11 +6,9 @@ add_library (ur_mock_headers SHARED "${CMAKE_CURRENT_SOURCE_DIR}/ur_mock_helpers.cpp") -if(CMAKE_SYSTEM_NAME STREQUAL Windows) - set_target_properties(ur_mock_headers PROPERTIES DEBUG_POSTFIX d) - if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) - set_target_properties(ur_mock_headers PROPERTIES RELEASE_POSTFIX d) - endif() +if(CMAKE_SYSTEM_NAME STREQUAL Windows AND + (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL)) + set_target_properties(ur_mock_headers PROPERTIES OUTPUT_NAME "ur_mock_headersd") endif() target_include_directories(ur_mock_headers diff --git a/xptifw/src/CMakeLists.txt b/xptifw/src/CMakeLists.txt index 6f652c58e3d38..7ffa43f0d6400 100644 --- a/xptifw/src/CMakeLists.txt +++ b/xptifw/src/CMakeLists.txt @@ -53,11 +53,9 @@ function(add_xpti_library LIB_NAME) 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() - if (CMAKE_SYSTEM_NAME STREQUAL Windows) - set_target_properties(${LIB_NAME} PROPERTIES DEBUG_POSTFIX d) - if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) - set_target_properties(${LIB_NAME} PROPERTIES RELEASE_POSTFIX d) - endif() + if (CMAKE_SYSTEM_NAME STREQUAL Windows AND + (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL)) + set_target_properties(${LIB_NAME} PROPERTIES OUTPUT_NAME "${LIB_NAME}d") endif() # Set the location of the library installation From dfb5a66bdd135417c6925f5ed39a24cae13e6fdf Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 5 Jun 2025 04:16:11 -0700 Subject: [PATCH 33/35] Configure CRT for xpti again Signed-off-by: Larsen, Steffen --- xpti/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xpti/CMakeLists.txt b/xpti/CMakeLists.txt index 53ae5d38668cb..745b9ce00aa13 100644 --- a/xpti/CMakeLists.txt +++ b/xpti/CMakeLists.txt @@ -22,6 +22,10 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE) endif() +if (NOT CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") +endif() + if (SYCL_USE_LIBCXX) if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) From 73f0ea82d84ae95220ff5d99d3ae7e22377d52e0 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 5 Jun 2025 05:39:53 -0700 Subject: [PATCH 34/35] Stop forcing CRT if unset Signed-off-by: Larsen, Steffen --- unified-runtime/cmake/FetchLevelZero.cmake | 6 ------ unified-runtime/cmake/helpers.cmake | 6 ------ xpti/CMakeLists.txt | 4 ---- 3 files changed, 16 deletions(-) diff --git a/unified-runtime/cmake/FetchLevelZero.cmake b/unified-runtime/cmake/FetchLevelZero.cmake index 6a591cad0e559..5e14b3c0e0f18 100644 --- a/unified-runtime/cmake/FetchLevelZero.cmake +++ b/unified-runtime/cmake/FetchLevelZero.cmake @@ -55,11 +55,6 @@ if (NOT DEFINED LEVEL_ZERO_LIBRARY OR NOT DEFINED LEVEL_ZERO_INCLUDE_DIR) # Prevent L0 loader from exporting extra symbols set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF) - set(CMAKE_MSVC_RUNTIME_LIBRARY_BAK "${CMAKE_MSVC_RUNTIME_LIBRARY}") - if (NOT CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$") - # UMF has not yet been able to build as static - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - endif() 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 +69,6 @@ if (NOT DEFINED LEVEL_ZERO_LIBRARY OR NOT DEFINED LEVEL_ZERO_INCLUDE_DIR) # Restore original flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BAK}") - set(CMAKE_MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY_BAK}") target_compile_options(ze_loader PRIVATE $<$,GNU;Clang;Intel;IntelLLVM>:-Wno-error> diff --git a/unified-runtime/cmake/helpers.cmake b/unified-runtime/cmake/helpers.cmake index 0dad643da68eb..e77fa28c1a0ee 100644 --- a/unified-runtime/cmake/helpers.cmake +++ b/unified-runtime/cmake/helpers.cmake @@ -136,12 +136,6 @@ function(add_ur_target_compile_options name) _CRT_SECURE_NO_WARNINGS # Slience warnings about getenv ) - get_target_property(MSVC_RT_PROP ${name} MSVC_RUNTIME_LIBRARY) - if (NOT CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$" AND NOT MSVC_RT_PROP MATCHES "DLL$") - set_property(TARGET ${name} PROPERTY - MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - endif() - if(UR_DEVELOPER_MODE) target_compile_options(${name} PRIVATE /WX # Enable: Treat all warnings as errors diff --git a/xpti/CMakeLists.txt b/xpti/CMakeLists.txt index 745b9ce00aa13..53ae5d38668cb 100644 --- a/xpti/CMakeLists.txt +++ b/xpti/CMakeLists.txt @@ -22,10 +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 (NOT CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$") - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") -endif() - if (SYCL_USE_LIBCXX) if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) From 50e6aed71a6103f5bdd81c37a0edd2007b497499 Mon Sep 17 00:00:00 2001 From: Steffen Larsen Date: Wed, 2 Jul 2025 14:07:40 +0200 Subject: [PATCH 35/35] Update CMakeLists.txt --- sycl/source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index f8fe34cce440a..fb34eebb1a0a5 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -198,7 +198,7 @@ function(add_sycl_rt_library LIB_TARGET_NAME LIB_OBJ_NAME LIB_OUTPUT_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)