Skip to content

[SYCL][UR][CMake] Stop creating debug library builds on Windows during release builds #18200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: sycl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,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)
Expand Down Expand Up @@ -366,11 +359,7 @@ if(SYCL_ENABLE_XPTI_TRACING AND
endif()

if (SYCL_ENABLE_XPTI_TRACING)
if (MSVC)
set(XPTIFW_LIBS xpti xptid xptifw xptifwd)
else()
set(XPTIFW_LIBS xpti xptifw)
endif()
set(XPTIFW_LIBS xpti xptifw)
endif()

# SYCL toolchain builds all components: compiler, libraries, headers, etc.
Expand Down Expand Up @@ -408,7 +397,7 @@ add_custom_target( sycl-toolchain ALL
)

if (WIN32)
add_dependencies(sycl-toolchain ur_win_proxy_loader unified-runtimed-build)
add_dependencies(sycl-toolchain ur_win_proxy_loader)
endif()

if("cuda" IN_LIST SYCL_ENABLE_BACKENDS)
Expand Down
9 changes: 2 additions & 7 deletions sycl/cmake/modules/AddSYCLUnitTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
107 changes: 0 additions & 107 deletions sycl/cmake/modules/FetchUnifiedRuntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -317,113 +317,6 @@ if("native_cpu" IN_LIST SYCL_ENABLE_BACKENDS)
endif()
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Windows)
# On Windows, also build/install debug libraries with the d suffix that are
# compiled with /MDd so users can link against these in debug builds.
include(ExternalProject)
set(URD_BINARY_DIR ${CMAKE_BINARY_DIR}/unified-runtimed)
set(URD_INSTALL_DIR ${URD_BINARY_DIR}/install)

# This creates a subbuild which can be used in dependencies with the
# unified-runtimed target. It invokes the install-unified-runtime-libraries
# target to install the UR runtime libraries.
ExternalProject_Add(unified-runtimed
SOURCE_DIR ${UNIFIED_RUNTIME_SOURCE_DIR}
BINARY_DIR ${URD_BINARY_DIR}
INSTALL_DIR ${URD_INSTALL_DIR}
INSTALL_COMMAND ${CMAKE_COMMAND}
--build <BINARY_DIR> --config Debug
--target install-unified-runtime-libraries
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_INSTALL_PREFIX:STRING=<INSTALL_DIR>
# Enable d suffix on libraries
-DUR_USE_DEBUG_POSTFIX:BOOL=ON
# Don't build unnecessary targets in subbuild.
-DUR_BUILD_EXAMPLES:BOOL=OFF
-DUR_BUILD_TESTS:BOOL=OFF
-DUR_BUILD_TOOLS:BOOL=OFF
# Sanitizer layer is not supported on Windows.
-DUR_ENABLE_SYMBOLIZER:BOOL=OFF
# Inherit settings from parent build.
-DUR_ENABLE_TRACING:BOOL=${UR_ENABLE_TRACING}
-DUR_ENABLE_COMGR:BOOL=${UR_ENABLE_COMGR}
-DUR_BUILD_ADAPTER_L0:BOOL=${UR_BUILD_ADAPTER_L0}
-DUR_BUILD_ADAPTER_L0_V2:BOOL=${UR_BUILD_ADAPTER_L0_V2}
-DUR_BUILD_ADAPTER_OPENCL:BOOL=${UR_BUILD_ADAPTER_OPENCL}
-DUR_BUILD_ADAPTER_CUDA:BOOL=${UR_BUILD_ADAPTER_CUDA}
-DUR_BUILD_ADAPTER_HIP:BOOL=${UR_BUILD_ADAPTER_HIP}
-DUR_BUILD_ADAPTER_NATIVE_CPU:BOOL=${UR_BUILD_ADAPTER_NATIVE_CPU}
-DUMF_BUILD_EXAMPLES:BOOL=${UMF_BUILD_EXAMPLES}
-DUMF_BUILD_SHARED_LIBRARY:BOOL=${UMF_BUILD_SHARED_LIBRARY}
-DUMF_LINK_HWLOC_STATICALLY:BOOL=${UMF_LINK_HWLOC_STATICALLY}
-DUMF_DISABLE_HWLOC:BOOL=${UMF_DISABLE_HWLOC}
# Enable d suffix in UMF
-DUMF_USE_DEBUG_POSTFIX:BOOL=ON
)

# Copy the debug UR runtime libraries to <build>/bin & <build>/lib for use in
# the parent build, e.g. integration testing.
set(URD_COPY_FILES)
macro(urd_copy_library_to_build library shared)
if(${shared})
list(APPEND URD_COPY_FILES
${LLVM_BINARY_DIR}/bin/${library}.dll
)
add_custom_command(
OUTPUT
${LLVM_BINARY_DIR}/bin/${library}.dll
COMMAND ${CMAKE_COMMAND} -E copy
${URD_INSTALL_DIR}/bin/${library}.dll
${LLVM_BINARY_DIR}/bin/${library}.dll
)
endif()

list(APPEND URD_COPY_FILES
${LLVM_BINARY_DIR}/lib/${library}.lib
)
add_custom_command(
OUTPUT
${LLVM_BINARY_DIR}/lib/${library}.lib
COMMAND ${CMAKE_COMMAND} -E copy
${URD_INSTALL_DIR}/lib/${library}.lib
${LLVM_BINARY_DIR}/lib/${library}.lib
)
endmacro()

urd_copy_library_to_build(ur_loaderd "NOT;${UR_STATIC_LOADER}")
foreach(adatper ${SYCL_ENABLE_BACKENDS})
if(adapter MATCHES "level_zero")
set(shared "NOT;${UR_STATIC_ADAPTER_L0}")
else()
set(shared TRUE)
endif()
urd_copy_library_to_build(ur_adapter_${adatper}d "${shared}")
endforeach()
# Also copy umfd.dll/umfd.lib
urd_copy_library_to_build(umfd ${UMF_BUILD_SHARED_LIBRARY})

add_custom_target(unified-runtimed-build ALL DEPENDS ${URD_COPY_FILES})
add_dependencies(unified-runtimed-build unified-runtimed)

# Add the debug UR runtime libraries to the parent install.
install(
FILES ${URD_INSTALL_DIR}/bin/ur_loaderd.dll
DESTINATION "bin" COMPONENT unified-runtime-loader)
foreach(adapter ${SYCL_ENABLE_BACKENDS})
install(
FILES ${URD_INSTALL_DIR}/bin/ur_adapter_${adapter}d.dll
DESTINATION "bin" COMPONENT ur_adapter_${adapter})
add_dependencies(install-sycl-ur-adapter-${adapter} unified-runtimed)
endforeach()
if(UMF_BUILD_SHARED_LIBRARY)
# Also install umfd.dll
install(
FILES ${URD_INSTALL_DIR}/bin/umfd.dll
DESTINATION "bin" COMPONENT unified-memory-framework)
endif()
endif()

install(TARGETS umf
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT unified-memory-framework
ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT unified-memory-framework
Expand Down
11 changes: 6 additions & 5 deletions sycl/cmake/modules/SYCLUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}$<$<CONFIG:Debug>: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()
Expand Down
Loading