cil-project / cil

C Intermediate Language
Other
348 stars 86 forks source link

cilly over-quotes compiler argument strings #7

Closed stephenrkell closed 10 years ago

stephenrkell commented 10 years ago

To deal with a build system that wants to run the compiler with "-DSHA1_HEADER=<path/to/blah>" I had to apply the following patch to cilly.

diff --git a/lib/Cilly.pm.in b/lib/Cilly.pm.in
index 3ec40a8..8d1943b 100644
--- a/lib/Cilly.pm.in
+++ b/lib/Cilly.pm.in
@@ -1219,9 +1219,6 @@ sub compilerArgument {
               &{$action->{'RUN'}}($self, @fullarg, $onemore, $pargs);
               $argument_done = 1;
           }
-          # Quote special SHELL caracters 
-          @fullarg = map { $_ =~ s%([<>;&|])%'$1'%g; $_ } @fullarg;
-          # print "fullarg = ", @fullarg, "\n";
           if(defined $action->{'TYPE'}) {
               &classifyArgDebug("  type=$action->{TYPE}\n");
               if($action->{TYPE} eq 'EARLY_PREPROC') {

Without this, the compiler was getting a string in its argv that contained literal quotes. To me, it doesn't look like the quoting is necessary at all, but I might be missing something.

kerneis commented 10 years ago

I'm unsure about that one. I've used many variants of -DFOO="bar" in the past with CIL without any issue. And the quoting seems necessary because the compiler is invoked using system. I'm leaving this as wont-fix, unless you can provide a small shell script (or makefile) which exhibits the bug.

stephenrkell commented 10 years ago

I've attached a test case. -DFOO="bar" is not a problem, but -DFOO= is: the angle brackets get over-quoted.

(Notice that unlike angle brackets, double-quotes are not touched by the code that I removed. So it's not a surprise that this works in either case.)

stephenrkell commented 10 years ago

Oh, it doesn't seem to have included the e-mail attachment, and this UI doesn't seem to let me attach anything that isn't an image. How annoying. Anyway, the test case is simply a GNU Makefile

INCLUDE_DEF := -DSTDIO=<stdio.h>
CFLAGS += "$(INCLUDE_DEF)"
CC ?= cilly

default: hello-define

and a C source file

#include STDIO

int main(void)
{
        printf("Hello, world!\n");
        return 0;
}
kerneis commented 10 years ago

Fixed, thanks.