[llvm] r267556 - Use gcc's rules for parsing gcc-style response files

Robinson, Paul via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 2 16:52:52 PDT 2016



> -----Original Message-----
> From: llvm-commits [mailto:llvm-commits-bounces at lists.llvm.org] On Behalf
> Of Hemant Kulkarni via llvm-commits
> Sent: Thursday, June 02, 2016 12:11 PM
> To: 'Rafael EspĂ­ndola'; 'Nico Weber'
> Cc: llvm-commits at lists.llvm.org
> Subject: RE: [llvm] r267556 - Use gcc's rules for parsing gcc-style
> response files
> 
> +llvm-commits
> 
> If the usage has to change why not also make change where %p, %t etc to
> have "\\" instead of "\" ? If not can this be not a switch?

In most cases, %t and friends are used to build command lines that are
executed directly, so they want "\" not "\\".

> 
> I have a test that generates a response file on the fly. This change fails
> that test. I do not want to use sed as it is not a standard utility on
> windows.

Can you add --rsp-quoting=windows to your clang command?
--paulr

> 
> --
> Hemant Kulkarni
> khemant at codeaurora.org
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted
> by the Linux Foundation
> 
> -----Original Message-----
> From: llvm-commits [mailto:llvm-commits-bounces at lists.llvm.org] On Behalf
> Of Rafael EspĂ­ndola via llvm-commits
> Sent: Tuesday, April 26, 2016 9:21 AM
> To: Nico Weber <nicolasweber at gmx.de>
> Cc: llvm-commits <llvm-commits at lists.llvm.org>
> Subject: Re: [llvm] r267556 - Use gcc's rules for parsing gcc-style
> response files
> 
> Hi,
> 
> Looks like this is still failing on the ps4 bot:
> 
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast/builds/4148/steps/test/logs/stdio
> 
> Cheers,
> Rafael
> 
> 
> On 26 April 2016 at 09:53, Nico Weber via llvm-commits <llvm-
> commits at lists.llvm.org> wrote:
> > Author: nico
> > Date: Tue Apr 26 08:53:56 2016
> > New Revision: 267556
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=267556&view=rev
> > Log:
> > Use gcc's rules for parsing gcc-style response files
> >
> > In gcc, \ escapes every character in response files. It is true that
> > this makes it harder to mention Windows files in rsp files, but not
> > doing this means clang disagrees with gcc, and also disagrees with the
> > shell (on non-Windows) which rsp file quoting is supposed to match.
> > clang isn't free to choose what to do here.
> >
> > In general, the idea for response files is to take bits of your
> > command line and write them to a file unchanged, and have things work
> > the same way. Since the command line would've been interpreted by the
> > shell, things in the rsp file need to be subject to the same shell
> quoting rules.
> >
> > People who want to put Windows-style paths in their response files
> > either need to do any of:
> > * escape their backslashes
> > * or use clang-cl which uses cl.exe/cmd.exe quoting rules
> > * pass --rsp-quoting=windows to clang to tell it to use
> >   cl.exe/cmd.exe quoting rules for response files.
> >
> > Fixes PR27464.
> > http://reviews.llvm.org/D19417
> >
> > Modified:
> >     llvm/trunk/lib/Support/CommandLine.cpp
> >     llvm/trunk/unittests/Support/CommandLineTest.cpp
> >
> > Modified: llvm/trunk/lib/Support/CommandLine.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine
> > .cpp?rev=267556&r1=267555&r2=267556&view=diff
> > ======================================================================
> > ========
> > --- llvm/trunk/lib/Support/CommandLine.cpp (original)
> > +++ llvm/trunk/lib/Support/CommandLine.cpp Tue Apr 26 08:53:56 2016
> > @@ -515,8 +515,6 @@ static bool isWhitespace(char C) { retur
> >
> >  static bool isQuote(char C) { return C == '\"' || C == '\''; }
> >
> > -static bool isGNUSpecial(char C) { return strchr("\\\"\' ", C); }
> > -
> >  void cl::TokenizeGNUCommandLine(StringRef Src, StringSaver &Saver,
> >                                  SmallVectorImpl<const char *> &NewArgv,
> >                                  bool MarkEOLs) { @@ -534,9 +532,8 @@
> > void cl::TokenizeGNUCommandLine(StringRe
> >          break;
> >      }
> >
> > -    // Backslashes can escape backslashes, spaces, and other quotes.
> Otherwise
> > -    // they are literal.  This makes it much easier to read Windows
> file paths.
> > -    if (I + 1 < E && Src[I] == '\\' && isGNUSpecial(Src[I + 1])) {
> > +    // Backslash escapes the next character.
> > +    if (I + 1 < E && Src[I] == '\\') {
> >        ++I; // Skip the escape.
> >        Token.push_back(Src[I]);
> >        continue;
> > @@ -546,8 +543,8 @@ void cl::TokenizeGNUCommandLine(StringRe
> >      if (isQuote(Src[I])) {
> >        char Quote = Src[I++];
> >        while (I != E && Src[I] != Quote) {
> > -        // Backslashes are literal, unless they escape a special
> character.
> > -        if (Src[I] == '\\' && I + 1 != E && isGNUSpecial(Src[I + 1]))
> > +        // Backslash escapes the next character.
> > +        if (Src[I] == '\\' && I + 1 != E)
> >            ++I;
> >          Token.push_back(Src[I]);
> >          ++I;
> >
> > Modified: llvm/trunk/unittests/Support/CommandLineTest.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Comma
> > ndLineTest.cpp?rev=267556&r1=267555&r2=267556&view=diff
> > ======================================================================
> > ========
> > --- llvm/trunk/unittests/Support/CommandLineTest.cpp (original)
> > +++ llvm/trunk/unittests/Support/CommandLineTest.cpp Tue Apr 26
> > +++ 08:53:56 2016
> > @@ -165,11 +165,12 @@ void testCommandLineTokenizer(ParserFunc
> >  }
> >
> >  TEST(CommandLineTest, TokenizeGNUCommandLine) {
> > -  const char *Input = "foo\\ bar \"foo bar\" \'foo bar\' 'foo\\\\bar' "
> > -                      "foo\"bar\"baz C:\\src\\foo.cpp
> \"C:\\src\\foo.cpp\"";
> > -  const char *const Output[] = { "foo bar", "foo bar", "foo bar",
> "foo\\bar",
> > -                                 "foobarbaz", "C:\\src\\foo.cpp",
> > -                                 "C:\\src\\foo.cpp" };
> > +  const char *Input =
> > +      "foo\\ bar \"foo bar\" \'foo bar\' 'foo\\\\bar' -DFOO=bar\\(\\) "
> > +      "foo\"bar\"baz C:\\\\src\\\\foo.cpp \"C:\\src\\foo.cpp\"";
> > + const char *const Output[] = {
> > +      "foo bar",     "foo bar",   "foo bar",          "foo\\bar",
> > +      "-DFOO=bar()", "foobarbaz", "C:\\src\\foo.cpp",
> > + "C:srcfoo.cpp"};
> >    testCommandLineTokenizer(cl::TokenizeGNUCommandLine, Input, Output,
> >                             array_lengthof(Output));  }
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list