buglibffcall - foreign function call libraries - Bugs: bug #22081, FFCALL on SPARC64 fails to build

 
 

bug #22081: FFCALL on SPARC64 fails to build

Submitted by:  Sam Steingold <sds>
Submitted on:  Tue 22 Jan 2008 08:04:21 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: portStatus: Fixed
Privacy: PublicAssigned to: Sam Steingold <sds>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Sat 11 Feb 2017 02:47:20 PM UTC, comment #15:

Additional fixes for sparc64 have now been delivered:

http://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=commit;h=2aad1e1919771a2d9f43848ccebd86564ea79ae0

http://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=commit;h=f3357dcc41dd917842ff7adeb8aa1d1d892471ae

http://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=commit;h=e1e9beccee008f0914628c2bfe50685882636ccd

http://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=commit;h=1f42eb80cc44457bfb673542b1a26e73c7bdb0b7

Bruno Haible <haible>
Project Administrator
Tue 20 Jul 2010 08:52:29 PM UTC, comment #14:

committed.
thanks!

Sam Steingold <sds>
Project AdministratorIn charge of this item.
Tue 20 Jul 2010 06:57:42 PM UTC, comment #13:

And you want the same in callback/trampoline_r too. The test doesn't get SIGBUS after that, but still fails (Linux/sparc64, 64-bit). I don't have time to investigate. It work on NetBSD and Solaris.

-uwe

Anonymous
Tue 20 Jul 2010 06:53:53 PM UTC, comment #12:

I mean, if you add that snippet to trampoline.c - it works. But that was just a quick check, instead you probably want to use something like the /CPU/ block at the top of avcall.h.in and then configure will take care to define _sparc64_ for you if it's not defined.

-uwe

Anonymous
Tue 20 Jul 2010 05:58:26 PM UTC, comment #11:

I don't see the snippet you mention in comment #9 anywhere.
in fact, the only places where arch64 is mentioned
are the configure files.

Sam Steingold <sds>
Project AdministratorIn charge of this item.
Tue 20 Jul 2010 04:18:26 PM UTC, comment #10:

The following is from my old notes. Pasting it here as-is for the record.

gcc versions prior to gcc3.4 have an ABI bug that affects passing small structs with a 'float' member in registers. I've fixed the code to comply to ABI, but it fails passing 'Float' tests with gcc3.3.3 that we have in-tree. [uwe: "we" == NetBSD and the year is 2005]

retrning small structs with fp members doesn't work, as fp members are returned in fp regs and the generic avcall code doesn't know what members of the structure are, so it doesn't know if it should pick the result from fp or from integer registers [uwe: this makes two extracheck tests fail on systems that pass structs in registers, all tests work on solaris that doesn't do that]

-uwe

Anonymous
Tue 20 Jul 2010 03:24:15 PM UTC, comment #9:

Linux/sparc64 failure in trampoline is in sparc (32-bit code).

I noticed that gcc there doesn't define _sparc64_ (only _arch64_), so wrong code gets compiled even with -m64. With

#if defined(_sparc_) && defined(_arch64_) && !defined(_sparc64_)
#define _sparc64_ 1
#endif

it works.

avcall.h.in already seems to have necessary magic, that just needs to be duplicated in trampoline/config.h.in I guess.

-uwe

Anonymous
Tue 20 Jul 2010 03:14:37 PM UTC, comment #8:

could you please try to fix Linux/sparc64 trampoline?

Sam Steingold <sds>
Project AdministratorIn charge of this item.
Tue 20 Jul 2010 03:00:24 PM UTC, comment #7:

FWIW, on NetBSD/sparc64 cvs head with my patches passes make check completely, including trampoline.

-uwe

Anonymous
Tue 20 Jul 2010 01:40:24 AM UTC, comment #6:

I've tried my patches on Linux/sparc64 against the cvs snapshot they were originally created for and everything works just fine, so the trampoline problem is "recent" (and my patches don't touch trampoline anyway).

Judging by CVS/Entries timestamps that cvs snapshot corresponds to the cvs head as of early March 12, 2008.

-uwe

Anonymous
Tue 20 Jul 2010 01:15:00 AM UTC, comment #5:

Linux/sparc64 compiler compiles to 32-bit by default, so you are using sparc files not sparc64. Configure with CC="gcc -m64" and you will see the compilation errors quoted in the bug description.

With my patches it compiles and passes make check in avcall and vacall, but trampoline/test1 gets bus error (just tried it, so haven't done any investigation yet).

Program received signal SIGBUS, Bus error.
alloc_trampoline (address=0x100840 <f>, variable=0x2011c8, data=0x2011a8)
at ./trampoline.c:656
656 (long ) (function + 4) = 0x05000000 | hi(data);
(gdb) p function
$1 = 0x202020 ""

-uwe

Anonymous
Wed 14 Jul 2010 03:56:40 PM UTC, comment #4:

on Linux deluxe 2.6.26-2-sparc64-smp #1 SMP Tue Mar 9 23:01:40 UTC 2010 sparc64 GNU/Linux
(gcc63 http://gcc.gnu.org/wiki/CompileFarm)
these patches are not needed (ffcall works OOTB, passes "make check").
however, the tests are passed with the patches too.

Sam Steingold <sds>
Project AdministratorIn charge of this item.
Tue 13 Jul 2010 09:45:56 PM UTC, comment #3:

on gcc64 (http://gcc.gnu.org/wiki/CompileFarm):

$ diff -u minitests.out minitests.output.sparc64-unknown-openbsd4.6
--- minitests.out Tue Jul 13 23:44:49 2010
+++ minitests.output.sparc64-unknown-openbsd4.6 Tue Jul 13 23:44:49 2010
@@ -1,7 +1,3 @@
-void f(void):
-void f(void):
-int f(void):->99
-int f(void):->99
int f(int):(1)->2
int f(int):(1292)->1293
int f(2*int):(1,2)->3

Sam Steingold <sds>
Project AdministratorIn charge of this item.
Tue 13 Jul 2010 05:44:55 PM UTC, comment #2:

thanks for the patch.
I can build libffcall with it on
OpenBSD loulou.esiee.fr 4.6 GENERIC#43 sparc64
with gcc (GCC) 3.3.5 (propolice)
but the tests fail:

cd avcall && make check
gcc -g -O2 -I. -I../../avcall -c ../../avcall/minitests.c
/bin/sh ./libtool --mode=link gcc -g -O2 -x none minitests.o libavcall.la -o minitests
gcc -g -O2 -x none minitests.o -o minitests ./.libs/libavcall.a
./minitests > minitests.out
LC_ALL=C uniq -u < minitests.out > minitests.output.sparc64-unknown-openbsd4.6
test '!' -s minitests.output.sparc64-unknown-openbsd4.6

      • Error code 1

Stop in /home/sds/top/src/ffcall/build-OpenBSD-sparc64/avcall (line 210 of Makefile).

      • Error code 1

Stop in /home/sds/top/src/ffcall/build-OpenBSD-sparc64 (line 47 of Makefile).

does the test succeed for you?

Sam Steingold <sds>
Project AdministratorIn charge of this item.
Thu 09 Oct 2008 08:15:19 PM UTC, comment #1:

I've attached sparc64 fixes that were tested under NetBSD/sparc64 with gcc4 and under Solaris with Sun C 5.9

Summary of changes:

. avcall/asmsparc64.sh

Delete .type declaration from the .S file, if one is needed
DECLARE_FUNCTION will supply it.

The same change needs to be applied to asmsparc64.sh in other
directories (all other sparc64 .S files have that extra .type
line), but as I was not regenerating .S files in those dirs, I
haven't touched their scripts.

. avcall/avcall-sparc64.c
avcall/avcall.h.in

NetBSD now comes with gcc4 which is quite agressive at eliminating
unused stuff, so I had to modify my original patch to address
this.

Kill callee (%g2). Sparc64 doesn't need that code. Come to think
of it trampoline[] should be killed to for the same reason. but I
forgot about it. gcc optimizes it away anyway :)

Delete space[] - gcc optimizes it away anyway, and it doesn't
guarantee correct operation even if it's not removed - if compiler
allocs it below other local vars on the stack, then calling
function with enough arguments will clobber local vars.

Instead i've changed the code to use alloca, see the comment in
the code for details on why this works. It also doesn't waste 2K
of stack on each call, we only grab the space we actually need.

I nuked farg_mask. It's not necessary for float args, marking
them in darg_mask does the right thing (new av_float). And they
just hurt structure passing, where, again, marking up darg_mask
does the right thing.

. avcall/avcall-saprc64.S

Regenerated with NetBSD gcc4. Attached as a separate file to not
pollute the patch.

. vacall/vacall-sparc64.S
callback/vacall_r/vacall-sparc64.S

New binutils on sparc64 insist on having global registers properly
declared with .register. I've just added the declarations
manually w/out actually regenerating the files to demonstrate
that's the only change needed there. IF the files are regenerated
with a newer compiler you will get them automatically.

I'm not sure if there are still any assemblers in wide circulation
that don't understand .register. I wonder if anyone is crazy
enough to still actively use a.out on sparc64.

-uwe@netbsd

Anonymous
Tue 22 Jan 2008 08:04:21 PM UTC, original submission:

http://sourceforge.net/tracker/index.php?func=detail&aid=952681&group_id=1355&atid=101355
SunOS monty-burns 5.8 Generic_108528-24 sun4u sparc
SUNW,Sun-Blade-1000
gcc (GCC) 3.2.2

CC="gcc -m64" ./configure --build

gcc -m64 -E `if test false = true; then echo
'-DASM_UNDERSCORE'; fi` ../../ffcal
l/avcall/avcall-sparc64.S | grep -v '^ *#line' | grep
-v '^#' | sed -e 's,% ,%,g
' -e 's,//.*$,,' -e 's,\$,#,g' > avcall-sparc64.s
/bin/sh ./libtool --mode=compile gcc -m64 -x none -c
avcall-sparc64.s
gcc -m64 -x none -c avcall-sparc64.s -o avcall-sparc64.o
/usr/ccs/bin/as: "avcall-sparc64.s", line 2: error:
.version "01.01" greater tha
n assembler version ""
/usr/ccs/bin/as: "avcall-sparc64.s", line 13: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 15: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 15: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 15: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 15: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 17: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 17: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 19: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 19: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 19: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 19: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 21: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 21: error:
detect global register use
not covered .register pseudo-op

&c

/usr/ccs/bin/as: "avcall-sparc64.s", line 927: error:
detect global register use
not covered .register pseudo-op
/usr/ccs/bin/as: "avcall-sparc64.s", line 928: error:
detect global register use
not covered .register pseudo-op

      • Error code 1

make: Fatal error: Command failed for target
`avcall-sparc64.lo'

Sam Steingold <sds>
Project AdministratorIn charge of this item.

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #16642:  ffcall-sparc64.diff added by None (10KiB - application/octet-stream - sparc64 patches and regenerated avcall)
file #16643:  avcall-sparc64.S added by None (16KiB - application/octet-stream - sparc64 patches and regenerated avcall)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by haible (Updated the item)
  • -unavailable- added by sds (patch author)
  • -unavailable- added by sds (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 29 Dec 2016 02:53:36 AM UTChaibleAssigned tohaible=>sds
    Tue 20 Jul 2010 08:52:29 PM UTCsdsStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Tue 13 Jul 2010 05:44:55 PM UTCsdsCarbon-Copy-=>Added -unavailable-
    Tue 28 Apr 2009 05:38:35 PM UTCsdsItem GroupNone=>port
    Thu 09 Oct 2008 08:10:17 PM UTCNoneAttached File-=>Added ffcall-sparc64.diff, #16642
      Attached File-=>Added avcall-sparc64.S, #16643

    Back to the top


    Powered by Savane 3.1-cleanup1