-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
layering_check
doesn't work without sandboxing
#21592
Comments
I briefly discussed this with @oquenchil, who mentioned that this was likely a design decision for Blaze. This leads to a few questions:
|
layering_check
requires sandboxinglayering_check
doesn't work without sandboxing
Work around bazelbuild/bazel#21592 as discovered in bazel-contrib/rules_fuzzing#242 (comment).
Hit this same case trying to upgrade LLVM to bazel 7.x, not sure yet how I can workaround it |
@keith Does it happen with sandboxing enabled? |
Yes, but I can't currently repro to test without sandboxing llvm/llvm-project#86297 (comment) |
We stumbled upon this issue here. We need to turn off sandboxing to do static analysis. Our workaround just consists in disabling the feature, which seems to be on by default: bazel build //your/target --spawn_strategy=local --features=-layering_check |
Debugging this a bit, it appears the issue is that when sandboxing is disabled the target's |
This is trivially reproducible outside of a bazel as well. It appears clang includes any transitive modulemaps in the dotd file when they are readable (hence the sandboxing requirement here), even if there is no direct dependency on them. |
submitted a fix here #21832, please leave any feedback there! |
I noticed that this case is actually super hard to get out of as well I think. Unsurprising since it's theoretically non-hermetic but I think you have to clean expunge in some cases. |
When clang generates dotd files when using `-fmodule-map-file` any `extern module` directives in the modulemap are included in the dotd file if they exist. The result of this was that with sandboxing disabled the dotd file included transitive cppmap files that weren't in its input set, resulting in build failures. This change excludes those instead since they're not required as evidence by the fact that with sandboxing enabled they are not part of the input set. Fixes bazelbuild#21592 Closes bazelbuild#21832. PiperOrigin-RevId: 656382428 Change-Id: I4bc9802884ce1bc66ceda65a602db8dffbd1d9ea
When clang generates dotd files when using `-fmodule-map-file` any `extern module` directives in the modulemap are included in the dotd file if they exist. The result of this was that with sandboxing disabled the dotd file included transitive cppmap files that weren't in its input set, resulting in build failures. This change excludes those instead since they're not required as evidence by the fact that with sandboxing enabled they are not part of the input set. Fixes #21592 Closes #21832. PiperOrigin-RevId: 656382428 Change-Id: I4bc9802884ce1bc66ceda65a602db8dffbd1d9ea Commit ad53147 Co-authored-by: Keith Smiley <[email protected]>
A fix for this issue has been included in Bazel 7.3.0 RC1. Please test out the release candidate and report any issues as soon as possible. |
CodeQL is running into issues with the layering_check feature with absl. ``` .../external/com_google_absl/absl/strings/BUILD.bazel:34:11: Compiling absl/strings/string_view.cc failed: undeclared inclusion(s) in rule '@com_google_absl//absl/strings:string_view': this rule is missing dependency declarations for the following files included by 'absl/strings/string_view.cc': 'bazel-out/k8-fastbuild/bin/external/com_google_absl/absl/meta/type_traits.cppmap' 'bazel-out/k8-fastbuild/bin/external/com_google_absl/absl/base/raw_logging_internal.cppmap' ``` Turning off the layering check seems to help. Bazel 7.3+ might help, but we're not there yet: bazelbuild/bazel#21592 bazelbuild/bazel#23122 Signed-off-by: Alejandro R. Sedeño <[email protected]>
It doesn't work without sandboxing, and this build uses `--spawn_strategy=local`. bazelbuild/bazel#21592 Signed-off-by: Alejandro R. Sedeño <[email protected]>
It doesn't work without sandboxing, and this build uses `--spawn_strategy=local`. bazelbuild/bazel#21592 Once we upgrade to a bazel 7.3.0+, this should no longer be needed. Risk Level: Low; only affects CI CodeQL build Signed-off-by: Alejandro R. Sedeño <[email protected]>
…xy#36500) It doesn't work without sandboxing, and this build uses `--spawn_strategy=local`. bazelbuild/bazel#21592 Once we upgrade to a bazel 7.3.0+, this should no longer be needed. Risk Level: Low; only affects CI CodeQL build Signed-off-by: Alejandro R. Sedeño <[email protected]> Signed-off-by: Steven Jin Xuan <[email protected]>
Description of the bug:
When compiling C++ targets with the
layering_check
feature, Bazel only stages the clang module maps of direct dependencies of a target as inputs, not all transitive module maps:bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationContext.java
Lines 578 to 582 in f5c8deb
As clang doesn't seem to fail if it can't find a module map file referenced by another module map, this works fine as long as sandboxing is enabled. However, if the compilation action doesn't run sandboxed, clang may load the referenced transitive module maps files, resulting in a "missing dependency declaration" error.
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.
Which operating system are you running Bazel on?
Linux
What is the output of
bazel info release
?7.0.2
If
bazel info release
returnsdevelopment 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
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 response
Any other information, logs, or outputs that you want to share?
This was originally discovered in bazel-contrib/rules_fuzzing#242 (comment).
The text was updated successfully, but these errors were encountered: