Skip to content

Commit

Permalink
Fix build with msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhan committed Jun 3, 2023
1 parent 08e6082 commit 8303ae2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
16 changes: 12 additions & 4 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "td_library")
# copybara:uncomment load("//tools/build_defs/license:license.bzl", "license")
load("//:triton.bzl", "if_not_msvc")

package(
# copybara:uncomment_begin
Expand Down Expand Up @@ -37,6 +38,13 @@ package(
# exports_files(["LICENSE"])
# copybara:uncomment_end

config_setting(
name = "compiler_is_msvc",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "msvc-cl",
},
)

td_library(
name = "td_files",
srcs = glob(["include/triton/**/*.td"]),
Expand Down Expand Up @@ -276,7 +284,7 @@ cc_library(
name = "TritonDialect",
srcs = glob(["lib/Dialect/Triton/IR/*.cpp"]),
hdrs = glob(["include/triton/Dialect/Triton/IR/*.h"]),
copts = ["-Wno-unused-variable"], # TODO(manany): fix
copts = if_not_msvc(["-Wno-unused-variable"]),
includes = ["include"],
deps = [
":triton_dialect_inc_gen",
Expand Down Expand Up @@ -328,7 +336,7 @@ cc_library(
"include/triton/Analysis/*.h",
"include/triton/Dialect/TritonGPU/IR/*.h",
]),
copts = ["-Wno-unused-variable"], # TODO(csigg): fix
copts = if_not_msvc(["-Wno-unused-variable"]),
includes = ["include"],
deps = [
":TritonDialect",
Expand Down Expand Up @@ -356,7 +364,7 @@ cc_library(
"lib/Dialect/TritonGPU/Transforms/*.h",
]),
hdrs = glob(["include/triton/Dialect/TritonGPU/Transforms/*.h"]),
copts = ["-Wno-unused-variable"], # TODO(csigg): fix
copts = if_not_msvc(["-Wno-unused-variable"]),
includes = ["include"],
deps = [
":TritonDialect",
Expand Down Expand Up @@ -391,7 +399,7 @@ cc_library(
"include/triton/Tools/Sys/*.hpp",
"include/triton/Conversion/TritonGPUToLLVM/*.h",
]),
copts = ["-Wno-unused-variable"], # TODO(csigg): fix
copts = if_not_msvc(["-Wno-unused-variable"]),
includes = [
"include",
"lib/Conversion/TritonGPUToLLVM",
Expand Down
10 changes: 10 additions & 0 deletions triton.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Bazel macros used by the triton build."""

def if_msvc(if_true, if_false = []):
return select({
":compiler_is_msvc": if_true,
"//conditions:default": if_false,
})

def if_not_msvc(a):
return if_msvc([], a)

0 comments on commit 8303ae2

Please sign in to comment.