You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't have a specific reproducible error but I just noticed that the select()s that assume that @platforms//os:windows means MSVC are most likely wrong, such as
I use MinGW to cross compile to Windows from Linux, so @platforms//os:windows is active but the compiler wont understand something like /D_WIN32_WINNT=0x0601.
Bazel doesn't document how to select() on the chosen compiler in a way that doesn't require the compiler to be specified as a constraint in target platform and available toolchains, but Abseil has the correct way in its sources here:
select({
":is_msvc_like": "I'm msvc or clang-cl",
"//conditions:default": "I'm probably gcc or gcc-compatible",
})
The values for @bazel_tools//tools/cpp:compiler come from the compiler attribute on the cc_toolchain_config. When targeting Windows the possible values are mingw-gcc, msys-gcc, msvc-cl and clang-cl, defined in this file:
I don't have a specific reproducible error but I just noticed that the
select()
s that assume that@platforms//os:windows
means MSVC are most likely wrong, such asrules_boost/BUILD.zlib
Line 78 in 5be5ea4
and
rules_boost/BUILD.boost
Line 281 in 5be5ea4
I use MinGW to cross compile to Windows from Linux, so
@platforms//os:windows
is active but the compiler wont understand something like/D_WIN32_WINNT=0x0601
.Bazel doesn't document how to
select()
on the chosen compiler in a way that doesn't require the compiler to be specified as a constraint in target platform and available toolchains, but Abseil has the correct way in its sources here:https://github.com/abseil/abseil-cpp/blob/46d939a918092ef94498a126dc1244b437100b31/absl/BUILD.bazel#L28
Note that both
msvc
andclang-cl
should be effectively treated as MSVC, so I typically define:And then use:
The values for
@bazel_tools//tools/cpp:compiler
come from thecompiler
attribute on thecc_toolchain_config
. When targeting Windows the possible values aremingw-gcc
,msys-gcc
,msvc-cl
andclang-cl
, defined in this file:https://github.com/bazelbuild/bazel/blob/36116ce73f97a7d2ac528dca07cc77bc772c9a22/tools/cpp/BUILD.windows.tpl#L132
The text was updated successfully, but these errors were encountered: