Skip to content

Commit db70c3f

Browse files
committed
optional nvrtc static
1 parent bff1c77 commit db70c3f

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

common/BUILD

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ config_setting(
109109
},
110110
)
111111

112+
113+
# Flag for linking static CUDA NVRTC libs
114+
bool_flag(
115+
name = "link_nvrtc_static_libs",
116+
build_setting_default = False,
117+
)
118+
119+
config_setting(
120+
name = "is_nvrtc_static_linking_enabled",
121+
flag_values = {
122+
":link_nvrtc_static_libs": "True",
123+
},
124+
)
125+
112126
#######################################################
113127
# Enable SYCL support flags
114128

third_party/gpus/cuda/build_defs.bzl.tpl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ def if_static_cuda(if_true, if_false = []):
3636
"//conditions:default": if_false,
3737
})
3838

39+
# Macros for building NVRTC static code.
40+
def if_static_nvrtc(if_true, if_false = []):
41+
"""Shorthand for select()'ing on whether we're building with static NVRTC libs.
42+
43+
Returns a select statement which evaluates to if_true if we're building
44+
with static NVRTC enabled. Otherwise, the select statement evaluates to if_false.
45+
"""
46+
return select({
47+
"@rules_ml_toolchain//common:is_nvrtc_static_linking_enabled": if_true,
48+
"//conditions:default": if_false,
49+
})
50+
51+
3952
def if_cuda_clang(if_true, if_false = []):
4053
"""Shorthand for select()'ing on wheteher we're building with cuda-clang.
4154

third_party/gpus/cuda/hermetic/cuda_nvrtc.BUILD.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ cc_import(
4444
%{multiline_comment}
4545
cc_library(
4646
name = "nvrtc",
47-
%{comment}deps = if_static_cuda([
47+
%{comment}deps = if_static_nvrtc([
4848
%{comment}":nvrtc_static",
4949
%{comment}":nvrtc_builtins_static",
5050
%{comment}"@cuda_nvcc//:nvptxcompiler",

0 commit comments

Comments
 (0)