Skip to content

Commit 5871949

Browse files
committed
Add Windows debug libs to install target (#17512)
1. Add install target for Windows debug libs called `install-unified-runtime-libraries` which installs only the runtime library subset of targets. This can be used to provide `ur_loaderd.dll` and `ur_adatper_<name>d.dll` which link against the multithreaded debug DLL C runtime by using the `DEBUG_POSTFIX` target property to append `d` to the library names. 2. Add `UR_USE_DEBUG_POSTFIX` option to enable adding the `d` suffix to library names. 3. Remove setting redundant `OUTPUT_NAME`s as combining `DEBUG_POSTFIX=d` and then setting `LIBRARY_OUTPUT_NAME`/`RUNTIME_OUTPUT_NAME` exposes a bug in CMake where the `DEBUG_POSTFIX` is ignored for the `ur_loader.dll`. Removing these redundant property setters fixed the previous issue. 4. Add debug UR subbuild on Windows `ExternalProject` compiled in debug mode and with the `UR_USE_DEBUG_POSTFIX` option enabled. * The resulting libraries are then copied to the `<build>/bin`/`<build>/lib` directories so they can be used in testing (not yet implemented). * Additionally, they are also included in the `deploy-sycl-toolchain` install target alongside the normally named runtime libraries. 5. Update `ur_proxy_loaderd.dll` to use Windows debug libs
1 parent 05e74bb commit 5871949

File tree

4 files changed

+41
-9
lines changed

4 files changed

+41
-9
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ set(UR_CONFORMANCE_TARGET_TRIPLES "" CACHE STRING
6666
set(UR_CONFORMANCE_AMD_ARCH "" CACHE STRING "AMD device target ID to build CTS binaries for")
6767
option(UR_CONFORMANCE_ENABLE_MATCH_FILES "Enable CTS match files" ON)
6868
option(UR_CONFORMANCE_TEST_LOADER "Also test the loader in the conformance tests" OFF)
69+
option(UR_USE_DEBUG_POSTFIX "Enable debug postfix 'd' for libraries" OFF)
6970
set(UR_ADAPTER_LEVEL_ZERO_SOURCE_DIR "" CACHE PATH
7071
"Path to external 'level_zero' adapter source dir")
7172
set(UR_ADAPTER_OPENCL_SOURCE_DIR "" CACHE PATH

cmake/helpers.cmake

+25-1
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,44 @@ function(add_ur_library name)
197197
$<$<STREQUAL:$<TARGET_LINKER_FILE_NAME:${name}>,link.exe>:LINKER:/DEPENDENTLOADFLAG:0x2000>
198198
)
199199
endif()
200+
if(UR_USE_DEBUG_POSTFIX)
201+
set_target_properties(${name} PROPERTIES DEBUG_POSTFIX d)
202+
endif()
200203
if(UR_EXTERNAL_DEPENDENCIES)
201204
add_dependencies(${name} ${UR_EXTERNAL_DEPENDENCIES})
202205
endif()
206+
add_dependencies(unified-runtime-libraries ${name})
203207
endfunction()
204208

209+
if(NOT TARGET unified-runtime-libraries)
210+
add_custom_target(unified-runtime-libraries)
211+
endif()
212+
205213
function(install_ur_library name)
206214
install(TARGETS ${name}
215+
COMPONENT unified-runtime
207216
EXPORT ${PROJECT_NAME}-targets
208217
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
209218
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
210-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT unified-runtime
219+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
211220
)
212221
endfunction()
213222

223+
if(UR_USE_DEBUG_POSTFIX AND NOT TARGET install-unified-runtime-libraries)
224+
add_custom_target(install-unified-runtime-libraries
225+
COMMAND ${CMAKE_COMMAND}
226+
-DCOMPONENT=unified-runtime
227+
-P ${CMAKE_BINARY_DIR}/cmake_install.cmake
228+
COMMAND ${CMAKE_COMMAND}
229+
-DCOMPONENT=umfd
230+
-P ${CMAKE_BINARY_DIR}/cmake_install.cmake
231+
DEPENDS unified-runtime-libraries
232+
)
233+
if(TARGET build_umfd)
234+
add_dependencies(install-unified-runtime-libraries build_umfd)
235+
endif()
236+
endif()
237+
214238
include(FetchContent)
215239

216240
function(FetchSource GIT_REPOSITORY GIT_TAG GIT_DIR DEST)

source/common/ur_util.hpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,23 @@ int ur_duplicate_fd(int pid, int fd_in);
5959
defined(SANITIZER_THREAD)
6060
#define SANITIZER_ANY
6161
#endif
62+
6263
///////////////////////////////////////////////////////////////////////////////
64+
#if UR_USE_DEBUG_POSTFIX
65+
#define LIBRARY_NAME(NAME) NAME "d"
66+
#else
67+
#define LIBRARY_NAME(NAME) NAME
68+
#endif
69+
6370
#if defined(_WIN32)
64-
#define MAKE_LIBRARY_NAME(NAME, VERSION) NAME ".dll"
71+
#define MAKE_LIBRARY_NAME(NAME, VERSION) LIBRARY_NAME(NAME) ".dll"
6572
#define STATIC_LIBRARY_EXTENSION ".lib"
6673
#else
6774
#if defined(__APPLE__)
68-
#define MAKE_LIBRARY_NAME(NAME, VERSION) "lib" NAME "." VERSION ".dylib"
75+
#define MAKE_LIBRARY_NAME(NAME, VERSION) \
76+
"lib" LIBRARY_NAME(NAME) "." VERSION ".dylib"
6977
#else
70-
#define MAKE_LIBRARY_NAME(NAME, VERSION) "lib" NAME ".so." VERSION
78+
#define MAKE_LIBRARY_NAME(NAME, VERSION) "lib" LIBRARY_NAME(NAME) ".so." VERSION
7179
#endif
7280
#define STATIC_LIBRARY_EXTENSION ".a"
7381
#endif

source/loader/CMakeLists.txt

+4-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ add_ur_library(ur_loader
2121
)
2222
install_ur_library(ur_loader)
2323

24+
target_compile_definitions(ur_loader PRIVATE
25+
UR_USE_DEBUG_POSTFIX=$<BOOL:${UR_USE_DEBUG_POSTFIX}>
26+
)
27+
2428
if (MSVC)
2529
set(TARGET_LIBNAME ur_loader)
2630
string(TOUPPER ${TARGET_LIBNAME} TARGET_LIBNAME)
@@ -39,11 +43,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
3943
target_link_options(ur_loader PRIVATE "-Wl,--version-script=${LOADER_VERSION_SCRIPT}")
4044
endif()
4145

42-
set_target_properties(ur_loader PROPERTIES
43-
LIBRARY_OUTPUT_NAME ur_loader
44-
RUNTIME_OUTPUT_NAME ur_loader
45-
)
46-
4746
add_library(${PROJECT_NAME}::loader ALIAS ur_loader)
4847

4948
target_include_directories(ur_loader PRIVATE

0 commit comments

Comments
 (0)