Skip to content

Commit bc72048

Browse files
authored
[bazel] Add a bazel flag to enable building MLIR with CUDA support (llvm#88856)
This makes it possible to specify `--@llvm-project//mlir:enable_cuda=true` on the bazel command line and get a build that includes NVIDIA GPU support in MLIR.
1 parent 8cc34fa commit bc72048

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# The MLIR "Multi-Level Intermediate Representation" Compiler Infrastructure
77

88
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
9+
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
910
load(
1011
":build_defs.bzl",
1112
"cc_headers_only",
@@ -28,6 +29,18 @@ exports_files([
2829
"utils/textmate/mlir.json",
2930
])
3031

32+
bool_flag(
33+
name = "enable_cuda",
34+
build_setting_default = False,
35+
)
36+
37+
config_setting(
38+
name = "enable_cuda_config",
39+
flag_values = {
40+
":enable_cuda": "True",
41+
},
42+
)
43+
3144
expand_template(
3245
name = "mlir_config_h_gen",
3346
out = "include/mlir/Config/mlir-config.h",

utils/bazel/llvm-project-overlay/mlir/build_defs.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
def if_cuda_available(if_true, if_false = []):
88
return select({
9-
# CUDA is not yet supported.
9+
# CUDA auto-detection is not yet supported.
10+
"//mlir:enable_cuda_config": if_true,
1011
"//conditions:default": if_false,
1112
})
1213

0 commit comments

Comments
 (0)