Bug#882328: [Pkg-gauche-devel] Bug#882328: gauche-c-wrapper FTBFS with glibc 2.25

2018-02-09 Thread Jens Thiele
another idea would be to allow to skip macros via some keyword :skip-macro
example patch:

--- gauche-c-wrapper-0.6.1/lib/c-wrapper/c-parser.scm   2009-08-08 
16:44:52.0 +0200
+++ gauche-c-wrapper-0.6.1.new/lib/c-wrapper/c-parser.scm   2018-02-09 
16:56:03.390344967 +0100
@@ -1099,7 +1099,7 @@
 ;;:show-define? #f))
 ;;(start-macro-reset!)))
 
-(define (parse-macro include-dirs headers options)
+(define (parse-macro include-dirs headers options skip-macro)
   (unwind-protect
(guard (e (( e)
   (let ((errmsg (make-error-message (condition-ref e 'message
@@ -1115,7 +1115,10 @@
 (raise e
  (call-with-gcc-io include-dirs headers options
(lambda (in out)
- (let ((macro-list (queue->list (macro-queue
+ (let ((macro-list (filter
+   (lambda(m)
+ (not (skip-macro (car m
+   (queue->list (macro-queue)
(for-each (lambda (macro-def)
(display (car macro-def) out)
(newline out))
@@ -1152,11 +1155,11 @@
  (else
   (errorf "~s can't be used for :import argument." import-cond)
 
-(define (c-parse include-dirs headers options import-arg export? sandbox hides)
+(define (c-parse include-dirs headers options import-arg export? sandbox hides 
skip-macro)
   (with-parse-context
(lambda ()
  (parse-source include-dirs headers options)
- (parse-macro include-dirs headers options)
+ (parse-macro include-dirs headers options skip-macro)
 
  (let ((export-syms
 (if import-arg
--- gauche-c-wrapper-0.6.1/lib/c-wrapper.scm2009-08-08 16:44:52.0 
+0200
+++ gauche-c-wrapper-0.6.1.new/lib/c-wrapper.scm2018-02-09 
16:45:26.045654080 +0100
@@ -91,7 +91,8 @@
(module #t)
(export? #f)
(output #f)
-   (hide-symbols '()))
+   (hide-symbols '())
+  (skip-macro (lambda(m) #f)))
 (when (eq? module #t)
   (set! export? #t))
 (parameterize ((sandbox-module (make-sandbox curmod module)))
@@ -117,7 +118,8 @@
(lambda (expr)
  (push! output-list expr))
(sandbox-module))
-   hide-symbols)
+   hide-symbols
+  skip-macro)
   (if output
   (call-with-output-file output
 (lambda (out)
@@ -154,7 +156,8 @@
(module #t)
(export? #f)
(output #f)
-   (hide-symbols '()))
+   (hide-symbols '())
+  (skip-macro (lambda(m) #f)))
 (cond
  ((compiled-lib-exist? compiled-lib)
   `(begin
@@ -171,7 +174,7 @@
  " ")))
 `(begin
(c-ld ,ld-option)
-   (c-include ,headers :option ,cpp-option :import ,import-arg :output 
,output :module ,module :export? ,export? :hide-symbols ,hide-symbols)))
+   (c-include ,headers :option ,cpp-option :import ,import-arg :output 
,output :module ,module :export? ,export? :hide-symbols ,hide-symbols 
:skip-macro ,skip-macro)))
 
 (define-syntax define-enum
   (syntax-rules ()
--- gauche-c-wrapper-0.6.1/testsuite/cwrappertest.scm   2009-08-08 
16:44:51.0 +0200
+++ gauche-c-wrapper-0.6.1.new/testsuite/cwrappertest.scm   2018-02-09 
16:49:49.349893969 +0100
@@ -10,7 +10,7 @@
 (test-module 'c-wrapper)
 
 (c-load-library "./ffitest")
-(c-include "./ffitest.h")
+(c-include "./ffitest.h" :skip-macro (lambda(m) (#/^__glibc_macro_warning/ m)))
 
 (define-syntax test-cfunc
   (syntax-rules ()



Bug#882328: [Pkg-gauche-devel] Bug#882328: gauche-c-wrapper FTBFS with glibc 2.25

2017-11-25 Thread Jens Thiele
Adrian Bunk  writes:

> Testing c-wrapper ...
> :444:13: error: invalid "#pragma GCC warning" directive

[...]

> ././ffitest.h:828: GCC exitted abnormally (at token: *eoi*)
> ././ffitest.h:828: #f
> ././ffitest.h:828: process 44299 exitted abnormally with exit code 256 (at 
> token: *eoi*)
> *** ERROR: process 44299 exitted abnormally with exit code 256
> While loading "./cwrappertest.scm" at line 13
> Stack Trace:
> ___
>   0  (with-error-handler (lambda (e) (let ((e e)) (%guard-rec e e  ...
> expanded from (guard (e (( e) (let ((errmsg 
> (make-error
> at "../lib/c-wrapper/c-parser.scm":1104
>   1  (parse-macro include-dirs headers options)
> at "../lib/c-wrapper/c-parser.scm":1159
>   2  (trunk)
> at "../lib/c-wrapper/c-parser.scm":67
>   3  (c-parse (if (list? include-dirs) include-dirs (list include- ...
> at "../lib/c-wrapper.scm":105
> Makefile:69: recipe for target 'check-c' failed
> make[2]: *** [check-c] Error 70

gauche-c-wrapper fails to handle the "__glibc_macro_warning" macro
included by stdio.h -> libio.h -> cdefs.h

/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE.  This is
   intended for use in preprocessor macros.

   Note: MESSAGE must be a _single_ string; concatenation of string
   literals is not supported.  */
#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
# define __glibc_macro_warning1(message) _Pragma (#message)
# define __glibc_macro_warning(message) \
  __glibc_macro_warning1 (GCC warning message)
#else
# define __glibc_macro_warning(msg)
#endif

an ugly workaround would be to skip that macro by name with something
like:

diff -Nur gauche-c-wrapper-0.6.1.orig/lib/c-wrapper/c-parser.scm 
gauche-c-wrapper-0.6.1/lib/c-wrapper/c-parser.scm
--- gauche-c-wrapper-0.6.1.orig/lib/c-wrapper/c-parser.scm  2009-08-08 
16:44:52.0 +0200
+++ gauche-c-wrapper-0.6.1/lib/c-wrapper/c-parser.scm   2017-11-24 
21:57:47.071382470 +0100
@@ -1115,7 +1115,10 @@
 (raise e
  (call-with-gcc-io include-dirs headers options
(lambda (in out)
- (let ((macro-list (queue->list (macro-queue
+ (let ((macro-list (filter (lambda(x)
+(not (string=? (car x)
+   
"__glibc_macro_warning(message)")))
+  (queue->list 
(macro-queue)
(for-each (lambda (macro-def)
(display (car macro-def) out)
(newline out))