GNU bug report logs -
#13386
Fwd: bug#13342: Errors trying to build Guile 2.0.7
Previous Next
Reported by: Peter Teeson <peter.teeson <at> me.com>
Date: Tue, 8 Jan 2013 16:10:01 UTC
Severity: normal
Tags: notabug
Merged with 13342
Done: ludo <at> gnu.org (Ludovic Courtès)
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13386 in the body.
You can then email your comments to 13386 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guile <at> gnu.org
:
bug#13386
; Package
guile
.
(Tue, 08 Jan 2013 16:10:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Peter Teeson <peter.teeson <at> me.com>
:
New bug report received and forwarded. Copy sent to
bug-guile <at> gnu.org
.
(Tue, 08 Jan 2013 16:10:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Begin forwarded message:
> From: Peter Teeson <pteeson <at> me.com>
> Subject: Re: bug#13342: Errors trying to build Guile 2.0.7
> Date: 7 January, 2013 8:21:59 PM EST
> To: Ludovic Courtès <ludo <at> gnu.org>
>
> Hi Ludo:
>
> On 2013-01-04, at 12:23 PM, Ludovic Courtès wrote:
>>>>> bad return from expression `(f-sum -1 2000 -30000 40000000000)': expected 39999971999; got 39999972255
>>>>> FAIL: test-ffi
>>>>
>>>> This is a known issue when building Guile with LLVM/Clang:
>>>>
>>>> http://bugs.gnu.org/10015
>>>> http://bugs.gnu.org/10681
>>>>
>>>> It would be great if you could investigate.
>
> Here is the result of my investigation - do you agree?
> My hypothesis is that the scheme interpreter is not calculating the sum correctly based on the following:
>
> (0) First observe this
> "In Apple's version of GCC, both cc and gcc are actually symbolic links to the llvm-gcc compiler. Similarly, c++ and g++ are links to llvm-g++."
>
> (1) Also we note that 39999972255 - 39999971999 = 256!
>
> (2) This program
> //
> // main.c
> // testffi
> //
> // Created by Peter Teeson on 13-01-07.
> // Copyright (c) 2013 PHT Software. All rights reserved.
> //
>
> #include <stdio.h>
> #include <inttypes.h>
>
> int64_t test_ffi_sum (int8_t a, int16_t b,
> int32_t c, int64_t d);
> int64_t test_ffi_sum (int8_t a, int16_t b,
> int32_t c, int64_t d)
> {
> printf("int64 d %" PRId64 " %#llX \n", d,d);
> printf("int32 c %" PRId32 " %#X \n", c,c);
> printf("int16 b %" PRId16 " %#X \n", b,b);
> printf("int08 a %" PRId8 " %#X \n", a,a);
>
> int64_t sum = d + c + b + a;
> printf("int64 sum %" PRId64 " %#llX \n", sum,sum);
>
> return sum;
> }
> int main(int argc, const char * argv[])
> {
> test_ffi_sum(-1, 2000, -30000, 40000000000);
> return 0;
> }
>
> (3) produces this output
>
> int64 d 40000000000 0X9502F9000
> int32 c -30000 0XFFFF8AD0
> int16 b 2000 0X7D0
> int08 a -1 0XFFFFFFFF
> int64 sum 39999971999 0X9502F229F
>
> (4) This function in /guile-2.0.7/test-suite/standalone/test-ffi
> ;;
> ;; Multiple int args of differing types
> ;;
> (define f-sum
> (pointer->procedure int64 (dynamic-func "test_ffi_sum" lib)
> (list int8 int16 int32 int64)))
> (test (f-sum -1 2000 -30000 40000000000)
> (+ -1 2000 -30000 40000000000))
>
> might be the culprit and I am guessing that it is this expression
>
> (+ -1 2000 -30000 40000000000)
>
> which the scheme interpreter is calculating incorrectly. Probably related to -1;
>
> Since I am not familiar with the scheme/guile language I can't go any further than this without help.
> Let me know if I can do more.
>
> respect…..
>
> Peter
[Message part 2 (text/html, inline)]
Merged 13342 13386.
Request was from
ludo <at> gnu.org (Ludovic Courtès)
to
control <at> debbugs.gnu.org
.
(Mon, 28 Jan 2013 12:58:02 GMT)
Full text and
rfc822 format available.
Added tag(s) notabug.
Request was from
ludo <at> gnu.org (Ludovic Courtès)
to
control <at> debbugs.gnu.org
.
(Wed, 30 Jan 2013 21:38:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-guile <at> gnu.org
:
bug#13386
; Package
guile
.
(Wed, 30 Jan 2013 22:14:02 GMT)
Full text and
rfc822 format available.
Message #12 received at 13386 <at> debbugs.gnu.org (full text, mbox):
Hi guys:
Thanks for closing off those bugs.
I have read all the emails you linked in your close emails and
completely understand the conversation.
Specially the comment by Michael Matz.
That clearly confirms that it is an LLVM compiler bug.
Good job both of you for digging down deeper and making things so clear.
At least now we know.
Would you please report this over at LLVM since you did the work to discover it.
Thanks again for your great patience and kindness in helping my fumbling efforts.
respect…..
Peter
Information forwarded
to
bug-guile <at> gnu.org
:
bug#13386
; Package
guile
.
(Thu, 31 Jan 2013 20:22:02 GMT)
Full text and
rfc822 format available.
Message #15 received at 13386 <at> debbugs.gnu.org (full text, mbox):
Hi Peter,
Peter Teeson <pteeson <at> me.com> writes:
> Would you please report this over at LLVM since you did the work to
> discover it.
Okay, I'll take care of it.
I'm also working with the libffi folks to work around this problem in
the interim. The next libffi release (due out fairly soon) will
interface properly with the existing LLVM-compiled code on your system.
Thanks again for helping us track this down.
Regards,
Mark
Information forwarded
to
bug-guile <at> gnu.org
:
bug#13386
; Package
guile
.
(Fri, 01 Feb 2013 02:07:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 13386 <at> debbugs.gnu.org (full text, mbox):
Hi Mark:
I read the thread on libffi-discuss.
When you think things are ready to test I'll be glad to do so on my Mac setup.
At present my boot system is MacOS 10.7.5 Lion.
But I can boot into previous versions (Leopard 10.5, Snow Leopard 10.6)
Just so you know….
Peter
On 2013-01-31, at 3:20 PM, Mark H Weaver wrote:
> I'm also working with the libffi folks to work around this problem in
> the interim. The next libffi release (due out fairly soon) will
> interface properly with the existing LLVM-compiled code on your system.
Information forwarded
to
bug-guile <at> gnu.org
:
bug#13386
; Package
guile
.
(Sat, 02 Feb 2013 13:13:02 GMT)
Full text and
rfc822 format available.
Message #21 received at 13386 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Peter,
Peter Teeson <pteeson <at> me.com> wrote:
> When you think things are ready to test I'll be glad to do so on my
> Mac setup.
I believe that this libffi patch will fix the problem. Would you like
to test it? It would also be helpful if you could run "make check" on
both libffi and Guile and let us know of any failures. There's no need
to test on older versions of the OS.
Thanks again!
Mark
[SIGN_EXTEND_SINT_ARGS.patch (text/x-diff, inline)]
diff --git a/src/x86/ffi64.c b/src/x86/ffi64.c
index b8a823d..2014af2 100644
--- a/src/x86/ffi64.c
+++ b/src/x86/ffi64.c
@@ -484,8 +484,25 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
case X86_64_INTEGER_CLASS:
case X86_64_INTEGERSI_CLASS:
- reg_args->gpr[gprcount] = 0;
- memcpy (®_args->gpr[gprcount], a, size < 8 ? size : 8);
+ /* Sign-extend integer arguments passed in general
+ purpose registers, to cope with the fact that
+ LLVM incorrectly assumes that this will be done
+ (the x86-64 PS ABI does not specify this). */
+ switch (arg_types[i]->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(SINT64 *)®_args->gpr[gprcount] = (SINT64) *((SINT8 *) a);
+ break;
+ case FFI_TYPE_SINT16:
+ *(SINT64 *)®_args->gpr[gprcount] = (SINT64) *((SINT16 *) a);
+ break;
+ case FFI_TYPE_SINT32:
+ *(SINT64 *)®_args->gpr[gprcount] = (SINT64) *((SINT32 *) a);
+ break;
+ default:
+ reg_args->gpr[gprcount] = 0;
+ memcpy (®_args->gpr[gprcount], a, size < 8 ? size : 8);
+ }
gprcount++;
break;
case X86_64_SSE_CLASS:
Information forwarded
to
bug-guile <at> gnu.org
:
bug#13386
; Package
guile
.
(Sun, 03 Feb 2013 00:07:02 GMT)
Full text and
rfc822 format available.
Message #24 received at 13386 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Mark:
The short answer is:
make check-am
…...
make check-TESTS
PASS: test-system-cmds
…...
PASS: test-asmobs
PASS: test-ffi
PASS: test-list
……
===================
All 29 tests passed
===================
In more detail the following steps:
Unzipped libffi-3.0.11.tar.gz
Downloaded libffi-3.0.11-includedir-1.patch
Applied that patch
Had to manually apply your diff file patch
(I'll explain in more detail if you wish)
Built and installed libffi in the usual manner.
Then did the same process for guile-2.0.7.tar.gz
did ./configure && make && make check
got the above results.
Here's the summary
Totals for this test run:
passes: 35268
failures: 0
unexpected passes: 0
expected failures: 6
unresolved test cases: 34
untested test cases: 1
unsupported test cases: 9
errors: 0
PASS: check-guile
Anything else I can do to help?
Peter
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-guile <at> gnu.org
:
bug#13386
; Package
guile
.
(Sun, 03 Feb 2013 03:24:02 GMT)
Full text and
rfc822 format available.
Message #27 received at 13386 <at> debbugs.gnu.org (full text, mbox):
Peter Teeson <pteeson <at> me.com> writes:
> …...
> PASS: test-asmobs
> PASS: test-ffi
> PASS: test-list
> ……
> ===================
> All 29 tests passed
> ===================
Excellent! We can now submit the libffi patch upstream.
Thanks,
Mark
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 03 Mar 2013 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 109 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.