LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 15642 - clang -MMD doesn't escape dollar signs in output
Summary: clang -MMD doesn't escape dollar signs in output
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: 3.2
Hardware: All All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-01 16:43 PDT by James Abbatiello
Modified: 2013-04-02 08:44 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Abbatiello 2013-04-01 16:43:26 PDT
When using "clang -MMD" with filenames that contain dollar signs, the dollar signs are not escaped.  If this output is used with make it won't be able to find the prerequisites.  For example:

$ /bin/ls -l
-rw-r--r-- 1 abbeyj users 75 Apr  1 17:36 Makefile
-rw-r--r-- 1 abbeyj users  0 Apr  1 17:35 dollar$sign.h
-rw-r--r-- 1 abbeyj users 25 Apr  1 17:32 main.c

$ cat Makefile
main.o: main.c
        $(CC) -MMD -c main.c
-include main.d
clean:
        $(RM) *.o *.d

$ cat main.c
#include "dollar$sign.h"

# works fine with gcc
$ make CC=gcc
gcc -MMD -c main.c
$ cat main.d
main.o: main.c dollar$$sign.h
$ make CC=gcc
make: `main.o' is up to date.

$ make clean

# fails with clang (once .d file has been created)
$ make CC=clang
clang -MMD -c main.c
$ cat main.d
main.o: main.c dollar$sign.h
$ make CC=clang
make: *** No rule to make target `dollarign.h', needed by `main.o'.  Stop.



Since the dollar sign is not doubled, make tries to expand "$s" and gets an empty string making it think the desired filename is "dollarign.h".  Since that file doesn't exist, the make then fails.
Comment 1 Benjamin Kramer 2013-04-02 08:44:17 PDT
Fixed in r178540.