Add support for clang-cl compiler (#1021)

This commit is contained in:
Felix Hanau 2023-07-03 05:43:35 -04:00 committed by GitHub
parent 50ebce107f
commit 534076fa67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

12
BUILD
View File

@ -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",
@ -124,6 +135,7 @@ cc_library(
hdrs = [":enc_headers"],
copts = STRICT_C_OPTIONS,
linkopts = select({
":clang-cl": [],
":msvc": [],
"//conditions:default": ["-lm"],
}),

View File

@ -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 = {
@ -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"},