-
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
incompatible_disallow_unsound_directory_outputs #18646
Comments
The downstream pipeline didn't detect any breakage. A few tests need to explicitly set the flag to false, or be rewritten to not rely on directory-producing genrules. Progress on #18646. PiperOrigin-RevId: 568852835 Change-Id: Ib7508be7f9c6c9448435145a11149c70fbbfa854
... instead of `dir`. In general Bazel discourages using directories as inputs and outputs, which will result in unsound dependency checks. In Bazel 7 such usage will result in build errors by default [0]. In `assembly_bundle`, the `dir` field is necessary to locate the assembly bundle directory. The same can be achieved by pointing to an actual file in the root of the directory (assembly_config.json should always exist in AIBs), and get the path to its parent directory. Also removed `platform_aib.bzl`, this rule currently can only output a directory, and it's non-trivial to make it list all files from the directory in outputs. One common alternative is to create an archive from this directory and use that as the output. This rule is not needed until we are ready to start migrating AIB definitions from GN to Bazel, and we can revisit when we are ready to do that. [0] bazelbuild/bazel#18646 Bug: 319069000 Change-Id: I783dc5a2d2a3ee69ec0b97e670ad4f105ae07b4d Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/973216 Commit-Queue: Jay Zhuang <jayzhuang@google.com> Reviewed-by: David Turner <digit@google.com>
@allsey87 Use the path to a file as the |
That would work for a cython.BUILD
numpy.BUILD
I have admitted most fields for brevity, but the above code currently works but results in the "dependency checking of directories is unsound" warning. Is there an alternative solution to this problem? |
What happens if you add two labels to |
What @fmeum said is a valid workaround; another is to set the But more importantly: I've just realized that your example is a source directory, not an output directory, so it's unaffected by this flag flip, which only affects the latter. |
@fmeum do you mean something like: cython.BUILD # this file always exists
exports_files(["BUILD.bazel"]) numpy.BUILD meson(
name = "numpy",
build_data = [
"@cython//:BUILD.bazel",
],
env = {
"PYTHONPATH": "$(execpath @cython//:BUILD.bazel)/.."
},
) This would assign
Which is not a valid path under Linux and results in the Python module not being found. I also tried placing the
However, this gives errors such as: invalid label '@cython//:BUILD.bazel/..' in element 0 of attribute 'build_data' in 'meson' rule: invalid target name 'BUILD.bazel/..': target names may not contain up-level references '..' Perhaps I have misunderstood your workaround/suggestion? |
@tjgq setting Sample of these warnings:
I think the blank artifact name is the same item being referenced in the
|
You are right, this only works if the tool consuming the variable cleans the path before interpreting it (although that's arguably not correct). An alternative would be to extract |
This flag, which I'm planning to flip for Bazel 7, forbids an action from creating a directory where a file is expected (which is unsound, as Bazel will not accurately track the directory contents). Such an action will produce the following error message:
The only native rule for which this is likely to be a problem is
genrule
through itsouts
attribute. For Starlark rules, thectx.actions.declare_file
,attr.output
andattr.output_list
APIs, as well as the deprecatedoutputs
parameter to therule
constructor, all declare output files. An output directory must instead be declared through thectx.actions.declare_directory
API, which offending rules will have to migrate to.The text was updated successfully, but these errors were encountered: