-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
the first line of .d files is ambiguous due to clang's output format #2046
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
Comments
Technically dep file must be a valid Makefile. In practice, compilers support a few different forms. Ninja build has a comprehensive parser for the format: https://github.com/ninja-build/ninja/blob/master/src/depfile_parser.in.cc The supported constructs end up being:
out: in1 in2 in3
out: in1 \
in2 \
in3
out: in1
out: in2
out: in3
out: in1 in2 in3
in1:
in2:
in3: |
file Here is output from both styles, using 2 source files NMake/Jom format
|
On Windows, the Let's have a chat with the clang developers and make sure that this isn't a bug, both the ambiguous case for make/compatible format, and the case where the target name does not respect |
is this to mean that in the following zig-cache/tmp/h6XndQRnlXKV-source.o: source.c foo.h bar.h |
Yep I think you have the correct understanding. Stated another way, it means that in this case |
hold off a bit. i've got what I think is a really good implementation that i'm fuzz-testing using default make/compatible .d format. as it relates to make/compatible format emitted by clang, It took me a bit to get these nuggets and here is what my prwip is doing:
|
So that answers a question. clang was re-writing But -MV is still ambiguous too because (at least on macOS) it does this:
target does not obey -MV syntax. it's prereqs do. I understand that it's less likely a target will need quotation. Right now it sounds the like the best way to go is indeed to switch prereq tokens (RHS of colon) to -MV format for my incoming pr. And leave make/compatible tokenization for target tokens (LHS of colon). Just be aware we still have that ambiguity with target. |
I think it's definitely worth filing a bug report with clang. I can help with that. |
|
Is that actually ambiguous? Isn't the |
Upstream bug report: https://bugs.llvm.org/show_bug.cgi?id=41379 |
Yes, This is probably where it could be fixed upstream: |
Goodness. Did you see this comment? What a mess. |
For posterity: Windows clang does the following with target pathnames; note that drive letter
|
- wip for ziglang#2046 - clang .d output must be created with `clang -MV` switch - implemented in Zig - hybridized for zig stage0 and stage1 - zig test src-self-hosted/dep_tokenizer.zig
Now that @mikdusan's new parser is merged, Zig looks at the first line of dep file parsing but this issue remains, because clang outputs ambiguous .d files. So this issue is open to follow up with the upstream bug report and get the issue fixed in clang. One more item to solve, once the first line files is solved, is making sure that zig does not redundantly add the target file to the cache. This would be harmless, but a small waste of time. |
Upstream bug report has moved to GitHub: llvm/llvm-project#40724 This does not appear to be a high priority for the LLVM team so will likely require us to send a patch in order to get addressed. |
zig/src/cache_hash.cpp
Lines 431 to 432 in fec4555
But here's an example file:
In this example there are 2 files on the first line. The dep file parsing probably needs to gain a real tokenizer, and support any number of items on any line. For example it also doesn't look for multiple files on the same line if there are double quotes.
I also haven't managed to find documentation for this file format. It would be nice to find a reference. Supposedly it's "NMake or Jom" format.
Finally, audit the places that call
cache_add_dep_file
and make sure they don't redundantly add the main source file, since it's contained in the dep file as well.The text was updated successfully, but these errors were encountered: