bazelbuild / bazelbuild/bazel

Incorrect `undeclared inclusion(s)` on Windows

Open
#27,637 14 comments 0 reactions 0 assignees View on GitHub
team-Rules-CPP 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:

I noticed this in OpenSSL in BCR and have some data for it here:
https://github.com/raccoons-build/bazel-openssl-cc/pull/45#issuecomment-3499772102

```
ERROR: C:/users/runneradmin/_bazel_runneradmin/hjc222nr/external/openssl+/test_bazel_build/BUILD.bazel:28:11: Compiling external/openssl+/test_bazel_build/includes_bh.cpp failed: undeclared inclusion(s) in rule '@@openssl+//test_bazel_build:includes_bn':
this rule is missing dependency declarations for the following files included by 'external/openssl+/test_bazel_build/includes_bh.cpp':
'external/openssl+/include/openssl/opensslconf.h'
```

Essentially we can see in a cquery that the header that Bazel claims is not a declared include is definitely directly passed to `hdrs` for the target.
```python
cc_library(
name = "crypto",
# ...
hdrs = [
# ...
"@openssl//:include/openssl/opensslconf.h",
# ...
],
# ...
)
```

I lack a Windows machine or sufficient context in the Java code to know what's going on here but this seems like a Bazel 9 bug as the targets work on Bazel 7 and Bazel 8.

### Which category does this issue belong to?

C++ Rules

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

Use the following `MODULE.bazel`
```python
bazel_dep(name = "openssl", version = "3.3.1.bcr.9")
```

Run the following command
```powershell
bazel build @openssl
```

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

Windows

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

release 9.0.0-pre.20251029.2

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

```text

```

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

_No response_

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

_No response_

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

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure on Windows using the provided MODULE.bazel and `bazel build @openssl` command, then compare the behavior with Bazel 7 and Bazel 8. Start from the C++ include-dependency checking path in the Java code and the reported `opensslconf.h` declaration; done means the declared header is no longer reported as an undeclared inclusion without regressing the supported Bazel versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, java
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.