bazelbuild / bazelbuild/bazel

Bazel 7 no longer compiles with mingw and instead uses visual studio

Open
#20,492 8 comments 2 reactions 1 assignee Claimed by @comius View on GitHub
P3 team-Rules-CPP type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the bug:

in v6.4.0 I had bazel configured so that it would use mingw-gcc , my .bazelrc was as follows:

```
build:windows --compiler=mingw-gcc
build:windows --enable_runfiles
build:windows --cxxopt=-std=c++2a
build:windows --cxxopt=-Wall
build:windows --cxxopt=-Wno-restrict
build:windows --cxxopt=-O3

build:macos --cxxopt=-std=c++2a
build:macos --cxxopt=-Wall
build:macos --cxxopt=-O3

build --enable_platform_specific_config

test --test_output=all
```

Everything compiled and worked correctly to this point. Now upgrading to bazel 7.0.0 , I get this error:

```
WARNING: --enable_bzlmod is set, but no MODULE.bazel file was found at the workspace root. Bazel will create an empty MODULE.bazel file. Please consider migrating your
external dependencies from WORKSPACE to MODULE.bazel. For more details, please refer to https://github.com/bazelbuild/bazel/issues/18958.
INFO: Analyzed target (93 packages loaded, 2584 targets configured).
ERROR: C:/users//documents/programming/c++/projects///assets/BUILD:3:12: Compiling /assets/.cpp failed: (Exit 2): cl.exe failed: error executing CppCompile command (from target ///assets:) C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\cl.exe @bazel-out/x64_windows-fastbuild/bin//assets/_objs//_gen.obj.params
cl : Command line error D8021 : invalid numeric argument '/Wno-restrict'
ERROR: C:/users//documents/programming/c++/projects///assets/BUILD:12:12: Compiling /assets/minimap-cursor_gen.cpp failed: (Exit 2): cl.exe failed: error executing CppCompile command (from target ///assets:minimap-cursor) C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\cl.exe ... (remaining 1 argument skipped)
cl : Command line error D8021 : invalid numeric argument '/Wno-restrict'
Target failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 15.841s, Critical Path: 1.23s
INFO: 9 processes: 6 internal, 3 local.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

```

As you can see its now trying to use visual studio *despite* specifying `--compiler=mingw-gcc`

This is on windows 10, and I have some of the following relevant ENV set:

```
BAZEL_SH=C:\msys64\usr\bin\bash.exe
BAZEL_VC=C:\Program Files\Microsoft Visual Studio\2022\Community\VC
CC=C:\msys64\mingw64\bin\gcc.exe
```

As well as mingw being available in the PATH. Again, this DOES work in v6.4.0, it stops working in v7.0.0

Thanks for any help

### Which category does this issue belong to?

C++/Objective-C Rules

### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Attempt to use mingw with above flags / ENV vars in the new bazel 7.0.0

### Which operating system are you running Bazel on?

Windows 10

### What is the output of `bazel info release`?

release 7.0.0

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?

```text
My repository is private, and don't intend to make it public (yet)
```

### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

_No response_

### Have you found anything relevant by searching the web?

No

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.