This is an archive of the discontinued LLVM Phabricator instance.

ELF2: Support reponse files.
ClosedPublic

Authored by ruiu on Sep 24 2015, 3:33 PM.

Details

Summary

Replace command line arguments starting with '@' with their file contents.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 35680.Sep 24 2015, 3:33 PM
ruiu retitled this revision from to ELF2: Support reponse files..
ruiu updated this object.
ruiu added a reviewer: rafael.
ruiu added a subscriber: llvm-commits.
shankare added inline comments.
ELF/DriverUtils.cpp
58–60

Can you add the option @ to the help ?

ruiu added a subscriber: ruiu.Sep 24 2015, 8:59 PM

That's not a command line option but a meta-feature of that, so there's no
way to define an error message. Old LLD and Clang don't also print out a
help message for @, so it's probably not needed.

shankare accepted this revision.Sep 24 2015, 9:04 PM
shankare added a reviewer: shankare.

Thanks for the info, LGTM.

This revision is now accepted and ready to land.Sep 24 2015, 9:04 PM
rafael edited edge metadata.Sep 25 2015, 6:39 AM
rafael added a subscriber: rafael.

+ Creates a new command line by replacing options starting with '@'
+
character. '@<filename>' is replaced by the file's contents.
+std::vector<const char *>
+ArgParser::replaceResponseFiles(ArrayRef<const char *> Argv) {
+ SmallVector<const char *, 256> Tokens(Argv.data(), Argv.data() + Argv.size());
+ StringSaver S(Alloc);
+ llvm:🆑:ExpandResponseFiles(S, llvm:🆑:TokenizeGNUCommandLine, Tokens);
+ return std::vector<const char *>(Tokens.begin(), Tokens.end());
+}

Can you pass in a SmallVectorImpl& instead? Not much point in
collecting results in the stack just to copy them to the heap.

LGTM with that.

Cheers,
Rafael

Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in r248575.