如何使Bazel荣誉Windows上的CC环境变量?
我正在尝试使用Bazel在Windows上构建针对MingW32的程序。没有内置的编译器,因此我必须尝试以某种方式伪造它。
在Linux上,我可以对任何类似于GCC的编译器进行编译:
CC=path-to-some-compiler-gcc bazel build ...
这显然在Windows上不起作用,因为Bazel默认使用MSVC,我没有。但这也不起作用 - cc
变量被忽略:
CC=path-to-some-compiler-gcc bazel build --compiler=mingw_windows
有没有办法获得我在Linux上看到的相同行为,但是在Windows上看到了相同的行为?
I'm trying to use bazel to build a program against mingw32 on Windows. There isn't a built-in compiler for this, so I have to try and fake it somehow.
On Linux, I can compile against any gcc-like compiler with this:
CC=path-to-some-compiler-gcc bazel build ...
This doesn't work on Windows, obviously, since bazel defaults to using MSVC, which I don't have. But this also doesn't work --- the CC
variable is ignored:
CC=path-to-some-compiler-gcc bazel build --compiler=mingw_windows
Is there a way to get the same behaviour I'm seeing on Linux, but on Windows?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
var = value命令
是一种类似bash的语法,所以显然cc = to to Path to to path to path to some-compiler-gcc bazel build ...
如果您不don' t使用这样的任何外壳。为了使用它,您必须在Windows上安装bash或类似的外壳。在本机Windows Shell(CMD和PowerShell)中,该变量是单独设置的。您需要在CMD中喜欢这样做:并且
在MSYS2中的PowerShell中,您需要
导出cc = to Path to path to path to some-compiler-gcc
使环境变量可用于Win32应用程序,否则该变量仅在当前的bash会话中包含VAR=value command
is a bash-like syntax so obviouslyCC=path-to-some-compiler-gcc bazel build ...
won't work if you don't use any shells like that. To use that you must install bash or similar shells on Windows. In native Windows shells (cmd and PowerShell) the variable is set separately. You need to do like this in cmd:and like this in PowerShell
In MSYS2 you'll need
export CC=path-to-some-compiler-gcc
to make the environment variable available to Win32 apps, otherwise the variable will be contained in the current bash session only