-
Couldn't load subscription status.
- Fork 4.3k
Description
Description of the feature request:
Thread on bazelbuild slack: https://bazelbuild.slack.com/archives/CA31HN1T3/p1761023024622639
I was surprised to learn today that source files and output files are allowed to have the same name. I discovered this while trying to understand why a target was depending on another target, despite only depending on source files via glob([...]). This was happening because the package had a source file and a generated file that shared the same name. When this happens, the generated file is preferred.
Simple repro:
$ echo source file > hello.txt
$ cat > BUILD.bazel
genrule(
name = "gen_hello",
outs = ["hello.txt"],
cmd = "echo 'generated file' > $@"
)
genrule(
name = "cat",
srcs = glob(["*.txt"]),
outs = ["cat.txt"],
cmd = "cat $(SRCS) > $@",
)
$ bazel build :cat &> /dev/null && cat bazel-bin/cat.txt
generated file
This also happens if you have a target named :hello.txt.
This is confusing because the user definitely meant to pass the source file as an input to the :cat target, not the generated file.
Should this be an error? Perhaps this could be introduced with One More Flag, e.g. --[no]incompatible_disallow_source_file_masking
Which category does this issue belong to?
Core