proposed fixes for cffi-libffi on Windows7+MSYS
Mirko Vukovic
mirko.vukovic at gmail.com
Thu Apr 7 03:13:29 UTC 2016
So, after a long hiatus I updated CFFI, only to see dreaded compilation
errors pop-up. Nothing better to keep me awake for an extra hour.
The two patches (in the attached file) fix the error that I see and improve
the code slightly.
One patch removes ^M that CCL sees at the end of output of pkg-config.
The need for the second patch arises in the case when the package loading
fails, and I try to load it again. In that case *cc-flags* gets loaded
with duplicate entries.
This patch removes the duplicates.
I generated the patches with the command:
git format-patch master --stdout > mv-mods.txt
If there is a better way to submit patches, let me know how and I will
resend.
Thanks,
Mirko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20160406/a5a01a73/attachment.html>
-------------- next part --------------
From 2d4408e394edba0741972d46225d13b14a6f237f Mon Sep 17 00:00:00 2001
From: Mirko Vukovic <mirko.vukovic at gmail.com>
Date: Wed, 6 Apr 2016 22:40:30 -0400
Subject: [PATCH 1/2] parse-command-flags: Added #\Return to separators
On Windows7+MSYS, the output of pkg-config as read by CCL included
\#RETURN.
I added #\Return the bag of separators. I also reformatted the code a
bit, to make it a bit more readable (fewer long lines or ackward line
splits).
---
toolchain/c-toolchain.lisp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/toolchain/c-toolchain.lisp b/toolchain/c-toolchain.lisp
index 8645c3b..9c6758c 100644
--- a/toolchain/c-toolchain.lisp
+++ b/toolchain/c-toolchain.lisp
@@ -33,7 +33,8 @@
;;; Utils
(defun parse-command-flags (flags)
- (remove-if 'emptyp (split-string flags :separator '(#\Space #\Tab #\Newline))))
+ (let ((separators '(#\Space #\Tab #\Newline #\Return)))
+ (remove-if 'emptyp (split-string flags :separator separators))))
(defun parse-command-flags-list (strings)
(loop for flags in strings append (parse-command-flags flags)))
--
2.6.3
From e687880d3ac5238dff7d9b78d70490265079a4a1 Mon Sep 17 00:00:00 2001
From: Mirko Vukovic <mirko.vukovic at gmail.com>
Date: Wed, 6 Apr 2016 22:57:40 -0400
Subject: [PATCH 2/2] Remove duplicates in *cc-flags*
`define-grovel-syntax pkg-config-cflags' would add the same paths even
if they were already in *cc-flags*.
The modified code appends the new flags, and then removes the
duplicates. The new flags are placed at the end of *cc-flags*
---
grovel/grovel.lisp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/grovel/grovel.lisp b/grovel/grovel.lisp
index 9240685..2b73c72 100644
--- a/grovel/grovel.lisp
+++ b/grovel/grovel.lisp
@@ -281,8 +281,13 @@ int main(int argc, char**argv) {
(run-program program+args
:output (make-broadcast-stream output-stream *debug-io*)
:error-output output-stream)
- (appendf *cc-flags*
- (parse-command-flags (get-output-stream-string output-stream))))
+ (setf *cc-flags*
+ (nreverse
+ (remove-duplicates
+ (append (parse-command-flags
+ (get-output-stream-string output-stream))
+ (nreverse *cc-flags*))
+ :test #'string=))))
(error (e)
(let ((message (format nil "~a~&~%~a~&"
e (get-output-stream-string output-stream))))
--
2.6.3
More information about the cffi-devel
mailing list