Hi,

Hopefully the commit message explains it all. I ran into this problem when
I had an egg file containing this:

 (components
  (extension nanomsg
     (source "nanomsg-module.scm")
     (link-options "-L -lnanomsg")))

Which should look like this:

 (components
  (extension nanomsg
     (source "nanomsg-module.scm")
     (link-options "-L" "-lnanomsg")))

It was not fun to debug why my egg wouldn't link against nanomsg.so, so I
though it might be useful to add this check in csc.
K.
From cb6176cffb96e728c31b1bea082908a188be00ad Mon Sep 17 00:00:00 2001
From: Kristian Lein-Mathisen <krist...@adellica.com>
Date: Sun, 29 Apr 2018 12:57:44 +0200
Subject: [PATCH 4/4] Check -L and -I for valid <DIR>

In csc, you can pass -L<DIR> and -I<DIR> which will get passed on to
the C compiler with the -L prefix, like this:

    csc -L/tmp/lib

This is handy. However, -L and -I are overloaded to pass options to
the C compiler that do not include the prefix, like this:

    csc -L -lpng

In the first example, the compiler sees "-L/tmp/lib" and in the
seconds it sees only "-lpng". This causes problems if second version
is accidentally quoted, like this:

    csc "-L -lpng"

Now C compiler will see "-L -lpng" which isn't an error but it should
be. We rarely have library directories that are called " -lpng". This
patch addresses that. If you actually have a library path that starts
with space, you will have to do something like `csc "-L./ madness"`.
---
 csc.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/csc.scm b/csc.scm
index 8b68b8fb..0fd3ea8e 100644
--- a/csc.scm
+++ b/csc.scm
@@ -773,8 +773,12 @@ EOF
 		      [(and (> (string-length arg) 1)
 			    (char=? #\- (string-ref arg 0)) )
 		       (cond [(char=? #\L (string-ref arg 1))
+			      (when (char-whitespace? (string-ref arg 2))
+				    (error "bad -L argument, <DIR> starts with whitespace" arg))
  			      (set! link-options (append link-options (list arg))) ]
  			     [(char=? #\I (string-ref arg 1))
+			      (when (char-whitespace? (string-ref arg 2))
+				    (error "bad -I argument: <DIR> starts with whitespace" arg))
  			      (set! compile-options (append compile-options (list arg))) ]
 			     [(char=? #\D (string-ref arg 1))
 			      (t-options "-feature" (substring arg 2)) ]
-- 
2.17.0

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to