public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/65820] New: escape backslashes in .d file
@ 2015-04-20 21:55 paul_robinson at playstation dot sony.com
  2015-04-21 19:44 ` [Bug other/65820] " paul_robinson at playstation dot sony.com
  0 siblings, 1 reply; 2+ messages in thread
From: paul_robinson at playstation dot sony.com @ 2015-04-20 21:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65820

            Bug ID: 65820
           Summary: escape backslashes in .d file
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: paul_robinson at playstation dot sony.com

gcc should escape backslashes when writing a .d file, because that's
what GNU make expects.

(Yes, I know special characters in filenames are a bad idea...)

There are various scenarios, this one seems to be the easiest to
demonstrate.

$ gcc --version
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu
$ cat quote.c
#include "a\\b.h"
$ # BTW that's two backslashes, not one escaped backslash; C11 6.4.7.
$ touch a\\\\b.h
$ gcc -c -MMD quote.c
$ # But the .d file just copies the string literally.
$ cat quote.d
quote.o: quote.c a\\b.h

$ rm a\\\\b.h
$ # Make properly doesn't find the nonexistent file....
$ make -f quote.d quote.o
make: *** No rule to make target `a\\b.h', needed by `quote.o'.  Stop.
$ # Accidentally create the wrong number of backslashes...
$ touch a\\b.h
$ # ...make will interpret a\\b.h as a\b.h, even though gcc doesn't.
$ make -f quote.d quote.o
cc    -c -o quote.o quote.c
quote.c:1:18: fatal error: a\\b.h: No such file or directory
 #include "a\\b.h"
                  ^
compilation terminated.
make: *** [quote.o] Error 1
$ 


If I modify the .d file to escape backslashes, it works properly.

$ cat quote.d
quote.o: quote.c a\\\\b.h
$ touch a\\\\b.h
$ ls
a\\b.h  quote.c  quote.d
$ make -f quote.d quote.o
cc    -c -o quote.o quote.c
$


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug other/65820] escape backslashes in .d file
  2015-04-20 21:55 [Bug other/65820] New: escape backslashes in .d file paul_robinson at playstation dot sony.com
@ 2015-04-21 19:44 ` paul_robinson at playstation dot sony.com
  0 siblings, 0 replies; 2+ messages in thread
From: paul_robinson at playstation dot sony.com @ 2015-04-21 19:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65820

Paul Robinson <paul_robinson at playstation dot sony.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Paul Robinson <paul_robinson at playstation dot sony.com> ---
tl;dr: Never Mind.

Somebody experimented with this on FreeBSD, apparently the BSD Make
doesn't do backslash-quoting at all, so this request would break
dependency files there.

And, it seems that while GNU Make will prefer to treat multiple
backslashes as escapes, if that doesn't find a matching file, it
will fall back to the original filespec-as-written.  So as long
as you don't mix files with different numbers of backslashes in
the same directory, it should actually work out.

Sigh.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-21 19:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-20 21:55 [Bug other/65820] New: escape backslashes in .d file paul_robinson at playstation dot sony.com
2015-04-21 19:44 ` [Bug other/65820] " paul_robinson at playstation dot sony.com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).