Skip to content

Commit 238c15b

Browse files
committed
Add option to build loader as a static library
1 parent 6c2329e commit 238c15b

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

.github/workflows/build-hw-reusable.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
required: false
1212
type: string
1313
default: ""
14+
static_loader:
15+
required: false
16+
type: string
17+
default: OFF
1418

1519
permissions:
1620
contents: read
@@ -29,14 +33,19 @@ jobs:
2933
strategy:
3034
matrix:
3135
adapter: [
32-
{name: "${{inputs.name}}", platform: "${{inputs.platform}}"},
36+
{name: "${{inputs.name}}", platform: "${{inputs.platform}}", static_Loader: "${{inputs.static_loader}}"},
3337
]
3438
build_type: [Debug, Release]
3539
compiler: [{c: gcc, cxx: g++}, {c: clang, cxx: clang++}]
3640
# TODO: The latest L0 loader segfaults when built with clang.
3741
exclude:
3842
- adapter: {name: L0, platform: ""}
3943
compiler: {c: clang, cxx: clang++}
44+
# Exclude these configurations to avoid overloading the runners.
45+
- adapter: {static_Loader: ON}
46+
build_type: Release
47+
- adapter: {static_Loader: ON}
48+
compiler: {c: clang, cxx: clang++}
4049

4150
runs-on: ${{matrix.adapter.name}}
4251

@@ -63,6 +72,7 @@ jobs:
6372
-DUR_DEVELOPER_MODE=ON
6473
-DUR_BUILD_TESTS=ON
6574
-DUR_BUILD_ADAPTER_${{matrix.adapter.name}}=ON
75+
-DUR_STATIC_LOADER=${{matrix.adapter.static_Loader}}
6676
-DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++
6777
-DUR_SYCL_LIBRARY_DIR=${{github.workspace}}/dpcpp_compiler/lib
6878
${{ matrix.adapter.name == 'HIP' && '-DUR_CONFORMANCE_AMD_ARCH=gfx1030' || '' }}

.github/workflows/cmake.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,20 @@ jobs:
121121
uses: ./.github/workflows/build-fuzz-reusable.yml
122122
with:
123123
test_label: "fuzz-short"
124-
124+
125125
level-zero:
126126
name: Level Zero
127127
uses: ./.github/workflows/build-hw-reusable.yml
128128
with:
129129
name: L0
130130

131+
level-zero-static:
132+
name: Level Zero static
133+
uses: ./.github/workflows/build-hw-reusable.yml
134+
with:
135+
name: L0
136+
static_loader: ON
137+
131138
opencl:
132139
name: OpenCL
133140
uses: ./.github/workflows/build-hw-reusable.yml

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ option(UR_BUILD_EXAMPLE_CODEGEN "Build the codegen example." OFF)
4949
option(VAL_USE_LIBBACKTRACE_BACKTRACE "enable libbacktrace validation backtrace for linux" OFF)
5050
option(UR_ENABLE_ASSERTIONS "Enable assertions for all build types" OFF)
5151
option(UR_BUILD_XPTI_LIBS "Build the XPTI libraries when tracing is enabled" ON)
52+
option(UR_STATIC_LOADER "Build loader as a static library" OFF)
5253
set(UR_DPCXX "" CACHE FILEPATH "Path of the DPC++ compiler executable")
5354
set(UR_DPCXX_BUILD_FLAGS "" CACHE STRING "Build flags to pass to DPC++ when compiling device programs")
5455
set(UR_SYCL_LIBRARY_DIR "" CACHE PATH
@@ -179,7 +180,7 @@ endif()
179180
if(UR_FORMAT_CPP_STYLE)
180181
find_program(CLANG_FORMAT NAMES clang-format-15 clang-format-15.0 clang-format)
181182

182-
if(CLANG_FORMAT)
183+
if(CLANG_FORMAT)
183184
get_program_version_major_minor(${CLANG_FORMAT} CLANG_FORMAT_VERSION)
184185
message(STATUS "Found clang-format: ${CLANG_FORMAT} (version: ${CLANG_FORMAT_VERSION})")
185186

source/loader/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,21 @@ configure_file(
99
@ONLY
1010
)
1111

12+
set(LOADER_LIB_TYPE SHARED)
13+
if(UR_STATIC_LOADER)
14+
set(LOADER_LIB_TYPE STATIC)
15+
endif()
16+
1217
add_ur_library(ur_loader
13-
SHARED
18+
${LOADER_LIB_TYPE}
1419
""
1520
${CMAKE_CURRENT_BINARY_DIR}/UrLoaderVersion.rc
1621
)
1722

1823
if (MSVC)
1924
set(TARGET_LIBNAME ur_loader)
2025
string(TOUPPER ${TARGET_LIBNAME} TARGET_LIBNAME)
21-
26+
2227
set(LOADER_VERSION_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/ur_loader.def)
2328
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/loader.def.in ${LOADER_VERSION_SCRIPT} @ONLY)
2429
set_target_properties(ur_loader PROPERTIES

0 commit comments

Comments
 (0)