bug#13342: [PARTIALLY SOLVED] bug#13342: Errors trying to build Guile 2.0.7

2013-01-28 Thread Ludovic Courtès
retitle 13342 Clang, the FFI, and 8-bit signed integers
merge 13342 13386
thanks

Hello!

Mark H Weaver  skribis:

> l...@gnu.org (Ludovic Courtès) writes:

[...]

>> I looked at Section 3.2.3 (“Parameter Passing”) of the SysV ABI x86_64
>> PS but couldn’t find any evidence as to what the correct behavior is.
>
> I read the same section, and although it is not as clear as I'd prefer,
> my interpretation is that the caller is responsible for sign-extending
> signed chars to ints.

What exactly in that section makes you think so?

> Clang strictly requires callers to sign-extend, whereas GCC is tolerant
> of callers who fail to do so.  IMO, both behaviors are permitted by the
> ABI.
>
> The problem is that libffi does *not* sign-extend arguments passed in
> registers when making calls, which is IMO a bug that has gone (mostly)
> unnoticed because of the tolerance and ubiquity of GCC.

Oh, I see.

>> However, on the caller side, both compilers emit the same code.  This
>> program:
>>
>> #include 
>>
>> extern int64_t test_sum (int8_t a, int64_t b);
>>
>> int64_t
>> foo (void)
>> {
>>   return test_sum (-1, 123132);
>> }
>>
>> leads to the following assembly with both compilers:
>>
>> foo:# @foo
>>  .cfi_startproc
>>  movl$-1, %edi
>>  movl$123132, %esi   # imm = 0x1E0FC
>>  jmp test_sum# TAILCALL
>>
>> (And as we’ve seen, libffi does the same.)
>
> No, libffi does *not* do the same.  Take a look at the relevant code:
>
>   https://github.com/atgreen/libffi/blob/master/src/x86/ffi64.c#L488

Indeed!

[...]

> In summary, I think this is a bug in libffi.
>
> Note that it has already been reported that the libffi testsuite shows
> many failures on OS X Lion, and the failures appear to be related to
> this precise issue:

Note that it’s not just Darwin: I tested with Clang on GNU/Linux.

>   http://sourceware.org/ml/libffi-discuss/2012/msg00162.html
>
> The libffi maintainer wrote "I'm going to chalk this up to compiler
> bugs", based on his observation that the tests worked properly when
> compiled with -O0.  I think it's time to raise this issue again on the
> libffi-discuss mailing list.

Would you like to email them?

Anyway, thanks for the thorough investigation!

Ludo’.





bug#13485: wrong warning for format ~!

2013-01-28 Thread Ian Price
l...@gnu.org (Ludovic Courtès) writes:

>> Ludovic,
>> are there test cases for this? I'm not sure where to look
>
> Yes, in tree-il.test.  Can you add them?

Attached a patch that squashes the previous two and adds tests. I still
may want to add an additional patch to get some better errors for
sequence parameters.

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"

>From 90baf8cdfe8ce356ee4720a012e0deb5a2cb5818 Mon Sep 17 00:00:00 2001
From: Ian Price 
Date: Sat, 19 Jan 2013 17:05:27 +
Subject: [PATCH] Fix argument count for various format string escape
 sequences.

* module/language/tree-il/analyze.scm (format-string-argument-count):
  Handle ~t and ~k options case-insensitively.
  ~! ~| ~/ ~q and ~Q should not update the min-count or max-count.
  ~^ returns the min-count and 'any
  + - # and ' should not increase the argument count.
* test-suite/tests/tree-il.test (*): Tests for new parameters.
---
 module/language/tree-il/analyze.scm |   13 ++---
 test-suite/tests/tree-il.test   |   29 +++--
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/module/language/tree-il/analyze.scm b/module/language/tree-il/analyze.scm
index 88f81f3..badce9f 100644
--- a/module/language/tree-il/analyze.scm
+++ b/module/language/tree-il/analyze.scm
@@ -1259,11 +1259,11 @@ accurate information is missing from a given `tree-il' element."
 (case state
   ((tilde)
(case (car chars)
- ((#\~ #\% #\& #\t #\_ #\newline #\( #\))
+ ((#\~ #\% #\& #\t #\T #\_ #\newline #\( #\) #\! #\| #\/ #\q #\Q)
 (loop (cdr chars) 'literal '()
   conditions end-group
   min-count max-count))
- ((#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\, #\: #\@)
+ ((#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\, #\: #\@ #\+ #\- #\#)
 (loop (cdr chars)
   'tilde (cons (car chars) params)
   conditions end-group
@@ -1330,16 +1330,23 @@ accurate information is missing from a given `tree-il' element."
  min-count)
   (+ (or (previous-number params) 1)
  max-count
- ((#\? #\k)
+ ((#\? #\k #\K)
   ;; We don't have enough info to determine the exact number
   ;; of args, but we could determine a lower bound (TODO).
   (values 'any 'any))
+ ((#\^)
+  (values min-count 'any))
  ((#\h #\H)
 (let ((argc (if (memq #\: params) 2 1)))
   (loop (cdr chars) 'literal '()
 conditions end-group
 (+ argc min-count)
 (+ argc max-count
+ ((#\')
+  (if (null? (cdr chars))
+  (throw &syntax-error 'unexpected-termination)
+  (loop (cddr chars) 'tilde (cons (cadr chars) params)
+conditions end-group min-count max-count)))
  (else  (loop (cdr chars) 'literal '()
   conditions end-group
   (+ 1 min-count) (+ 1 max-count)
diff --git a/test-suite/tests/tree-il.test b/test-suite/tests/tree-il.test
index 68dfc32..2217ffc 100644
--- a/test-suite/tests/tree-il.test
+++ b/test-suite/tests/tree-il.test
@@ -1415,11 +1415,11 @@
   (number? (string-contains (car w)
 "wrong number of arguments")
 
- (pass-if "~%, ~~, ~&, ~t, ~_, and ~\\n"
+ (pass-if "~%, ~~, ~&, ~t, ~_, ~!, ~|, ~/, ~q and ~\\n"
(null? (call-with-warnings
(lambda ()
  (compile '((@ (ice-9 format) format) some-port
-"~&~3_~~ ~\n~12they~%")
+"~&~3_~~ ~\n~12they~% ~!~|~/~q")
   #:opts %opts-w-format
   #:to 'assembly)
 
@@ -1687,6 +1687,31 @@
   #:opts %opts-w-format
   #:to 'assembly)
 
+ (pass-if "~^"
+   (null? (call-with-warnings
+   (lambda ()
+ (compile '((@ (ice-9 format) format) #f "~a ~^ ~a" 0 1)
+  #:opts %opts-w-format
+  #:to 'assembly)
+
+ (pass-if "~^, too few args"
+   (let ((w (call-with-warnings
+ (lambda ()
+   (compile '((@ (ice-9 format) format) #f "~a ~^ ~a")
+#:opts %opts-w-format
+#:to 'assembly)
+ (and (= (length w) 1)
+  (number? (string-contains (car w)
+ 

bug#13485: wrong warning for format ~!

2013-01-28 Thread Ludovic Courtès
Ian Price  skribis:

> Attached a patch that squashes the previous two and adds tests.

Looks good to me, feel free to push.

> I still may want to add an additional patch to get some better errors
> for sequence parameters.

That can be done in a separate patch.

Thanks!

Ludo’.





bug#13342: [PARTIALLY SOLVED] bug#13342: Errors trying to build Guile 2.0.7

2013-01-28 Thread Peter Teeson
Hi:
Do you also need to retitle and merge 10015 and 10681?

These were the similar bugs you mentioned when I first reported the issue.

Peter

On 2013-01-28, at 7:56 AM, Ludovic Courtès wrote:
> retitle 13342 Clang, the FFI, and 8-bit signed integers
> merge 13342 13386
> thanks






bug#13342: [PARTIALLY SOLVED] bug#13342: Errors trying to build Guile 2.0.7

2013-01-28 Thread Ludovic Courtès
merge 13342 10015 10681
thanks

Peter Teeson  skribis:

> Do you also need to retitle and merge 10015 and 10681?

Indeed, thanks!

Ludo’.





bug#13558: guile 2.0.7 issues with automake1.13?

2013-01-28 Thread Ludovic Courtès
DNS  skribis:

> Please check this build log:
> https://launchpadlibrarian.net/128901141/buildlog_ubuntu-precise-i386.guile-2.0_2.0.7-0gnu3~12.04_FAILEDTOBUILD.txt.gz
>
> It seems to me that the build error / test-error was caused by problems
> with automake 1.13 (was 1.12 before), but i'm not 100% sure...

Indeed.  Fixed by commit ac28db6.

Thanks!

Ludo’.