MinGW toolchain produces binaries that cannot be run with ctx.actions.run() by default #15059
Labels
not stale
Issues or PRs that are inactive but not considered stale
P4
This is either out of scope or we don't have bandwidth to review a PR. (No assignee)
team-Rules-CPP
Issues for C++ rules
type: support / not a bug (process)
Description of the problem / feature request:
Bazel's default MinGW toolchain produces binaries that depend on
C:\msys64\mingw64\bin\libstdc++-6.dll
and thus cannot be run withoutC:\msys64\mingw64\bin
in the PATH.A consequence of this is that Bazel rules fail to execute
cc_binary
binaries withctx.actions.run
when run with--compiler=mingw-gcc
. The rule author must passuse_default_shell_env = True
just to support MinGW, in combination with the user addingC:\msys64\mingw64\bin
to the PATH of the Bazel invocation (or via--action_env
).Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Create a workspace with the following 4 files.
WORKSPACE
# empty
BUILD.bazel
defs.bzl
write_hello.cpp
bazel build //:hello.txt
works:bazel build --compiler=mingw-gcc //:hello.txt
fails:Opening
bazel-out\x64_windows-opt-exec-2B5CBBC6\bin\write_hello.exe
in File Explorer reveals the problem:Adding
use_default_shell_env = True
to thectx.actions.run
and runningbazel build --compiler=mingw-gcc --action_env="PATH=C:\msys64\mingw64\bin" //:hello.txt
works:but rule authors do not know this until a user complains that their rules don't work on MinGW. Binaries produce by the MinGW toolchain should work by default without special adaptions by rules to support it.
What operating system are you running Bazel on?
What's the output of
bazel info release
?The text was updated successfully, but these errors were encountered: