This is an archive of the discontinued LLVM Phabricator instance.

Support generating Jom-style depfiles.
ClosedPublic

Authored by probinson on Apr 24 2015, 11:01 AM.

Details

Summary

Jom (https://wiki.qt.io/Jom) is an NMake-compatible build tool on
Windows. Dependency files for Jom need to use double-quotes to wrap
filespecs containing special characters, instead of the backslash
escapes that GNU Make wants.

Adds the -MV option, which specifies to use double-quotes as needed
instead of backslash escapes when writing the dependency file.

Diff Detail

Repository
rL LLVM

Event Timeline

probinson updated this revision to Diff 24398.Apr 24 2015, 11:01 AM
probinson retitled this revision from to Support generating Jom-style depfiles..
probinson updated this object.
probinson edited the test plan for this revision. (Show Details)
probinson added reviewers: rnk, silvas.
probinson added a subscriber: Unknown Object (MLST).

The most obvious choice for the option would have been -MQ (Q for Quote) but that's already taken.
I picked -MV because we have a proprietary compiler that uses that option for the same purpose, but that's not a hard requirement and I'm open to suggestions.

silvas edited edge metadata.Apr 24 2015, 2:36 PM

Mimicking the existing precedent from another compiler for the option name makes sense (actually wasn't this at least in one of SCE's GCC derivatives?, so the sources ought to be out there in open source somewhere...). The other alternative I can think of is -Msyntax={make,nmake}, but I'm fine with -MV.

Also, since this feature is not in GCC, it requires documentation in docs/UsersManual.rst

lib/Frontend/DependencyFile.cpp
153 ↗(On Diff #24398)

Maybe a comment explaining why you would want double quotes? Alternatively, maybe instead of "bool" it could be enum DepfileSyntax { Make, NMake } or something like that.

298 ↗(On Diff #24398)

Is there a "spec" you can link to explaining the syntax? IIRC the microsoft docs for nmake have something explaining the quoting scheme.

300 ↗(On Diff #24398)

I guess #include <foo"bar.h> is "don't do that"? I'm fine with that; I think the standard actually gives us a lot of freedom in what we can accept here; as long as we don't break use cases we care about it's all "implementation defined". We currently accept this though with no warning. If NMake doesn't have a way to quote this then maybe we should consider a "unadvisable include name" warning.

Re. origin of the -MV option, you are correct, it was a PS3 GCC option; the proprietary compiler always emitted NMake-style, it didn't have that option. My bad.

Re. UserManual.rst, it was not immediately obvious where to put this, so I invented a new section. Let me know if you have a better idea.

lib/Frontend/DependencyFile.cpp
153 ↗(On Diff #24398)

Okay, an enum would be more self-documenting, and it's true there is more to it than just double-quotes.

298 ↗(On Diff #24398)

There is online NMake documentation, but nothing explicitly saying when you do or don't need quotes. I can cite the base NMake URL.

300 ↗(On Diff #24398)

Double-quote is not a legal filespec character in Windows, so compilation would fail regardless.

That said, the purpose of quoting is to avoid the builder misinterpreting the string, and the set of characters that could cause trouble for NMake is more than what seems to be trouble for Make. I should add curly braces and caret to this list, might as well add bang too, as they are all meaningful to NMake outside of recipes.

probinson updated this revision to Diff 24422.Apr 24 2015, 5:13 PM
probinson edited edge metadata.

Revised per Sean's comments.

rnk accepted this revision.Apr 27 2015, 8:37 AM
rnk edited edge metadata.

Sounds good, lgtm.

This revision is now accepted and ready to land.Apr 27 2015, 8:37 AM
This revision was automatically updated to reflect the committed changes.

r235903, thanks!