Skip to content

Commit

Permalink
Add support for clang-cl compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
fhanau committed Jun 19, 2023
1 parent ed1995b commit 617dd3f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ create_msvc_config()

STRICT_C_OPTIONS = select({
":msvc": [],
":clang-cl": [
"/W4",
"-Wconversion",
"-Wlong-long",
"-Wmissing-declarations",
"-Wmissing-prototypes",
"-Wno-strict-aliasing",
"-Wshadow",
"-Wsign-compare",
"-Wno-sign-conversion",
],
"//conditions:default": [
"--pedantic-errors",
"-Wall",
Expand Down Expand Up @@ -124,6 +135,7 @@ cc_library(
hdrs = [":enc_headers"],
copts = STRICT_C_OPTIONS,
linkopts = select({
":clang-cl": [],
":msvc": [],
"//conditions:default": ["-lm"],
}),
Expand Down
12 changes: 12 additions & 0 deletions compiler_config_setting.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ def create_msvc_config():
# flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can
# be removed.
if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"):
native.config_setting(
name = "clang-cl",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "clang-cl",
},
visibility = ["//visibility:public"],
)
native.config_setting(
name = "msvc",
flag_values = {
Expand All @@ -21,6 +28,11 @@ def create_msvc_config():
visibility = ["//visibility:public"],
)
else:
native.config_setting(
name = "clang-cl",
values = {"compiler": "clang-cl"},
visibility = ["//visibility:public"],
)
native.config_setting(
name = "msvc",
values = {"compiler": "msvc-cl"},
Expand Down

0 comments on commit 617dd3f

Please sign in to comment.