bazelbuild / bazelbuild/bazel

exec builds fail with `cl : Command line error D8043 : unknown option '-g0'` with MSVC and `/options:strict`

Open
#24,545 12 comments 0 reactions 0 assignees View on GitHub
P2 team-Rules-CPP team-Starlark-Integration type: bug untriaged
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the bug:

We use `/options:strict` with MSVC as part of our minimum quality bar. As part of the bazel 8.0 upgrade everything it now fails to build any tool for exec.

example error:
```
ERROR: D:/bazel_bugs/strict_error/BUILD.bazel:2:10: Compiling tool.cpp [for tool] failed: (Exit 2): cl.exe failed: error executing CppCompile command (from target //:tool) C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.40.33807\bin\HostX64\x64\cl.exe @bazel-out/x64_windows-opt-exec-ST-d57f47055a04/bin/_objs/tool/tool.obj.params
cl : Command line error D8043 : unknown option '-g0'
cl : Command line error D8043 : unknown option '-g0'
```

### Which category does this issue belong to?

C++ Rules, Starlark Integration

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

With the following example
[strict_error2.zip](https://github.com/user-attachments/files/17992933/strict_error2.zip)
run:

`bazel build //... --host_copt=-options:strict`

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

windows

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

release 8.0.0rc6

### 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 HEAD` ?

_No response_

### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

first bad commit is https://github.com/bazelbuild/bazel/commit/1acfb85b0324bbdaf0d441fdc4dffad31e8f4c9f

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

I believe the following lines introduced the problem.
https://github.com/bazelbuild/bazel/blob/3d7d157a29814cd97f82e20c7f8fb83555c7bbc0/src/main/starlark/builtins_bzl/common/builtin_exec_platforms.bzl#L343

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

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with strict_error2.zip using `bazel build //... --host_copt=-options:strict` on Windows. Then inspect `src/main/starlark/builtins_bzl/common/builtin_exec_platforms.bzl` around line 343 and the cited regression commit. Done means exec tools build with MSVC and `/options:strict` without passing the unsupported `-g0` option.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.