integer-gmp2 issues on Solaris/SPARC
Karel Gardas
karel.gardas at centrum.cz
Mon Jan 19 09:25:59 UTC 2015
On 01/18/15 04:05 PM, Herbert Valerio Riedel wrote:
> On 2015-01-18 at 15:42:05 +0100, Karel Gardas wrote:
>> Hello Herbert,
>>
>> I'm sorry to bother you, but recent GHC HEAD does have issue on
>> Solaris/SPARC platform which shows as undefined symbols during the
>> linkage of stage2 binaries. For example ghc-stage2 link step fails
>> with:
>
> Btw, what GMP version is that exactly? "GMP 3.5.2" doesn't seem to be an
> official GMP release?
This is version 4.3.2 in both cases.
> ...does the<gmp.h> header differ?
Unfortunately not. The only difference is in CFLAGS:
$ gdiff -u /usr/include/gmp/gmp.h /tmp/gmp.h
--- /usr/include/gmp/gmp.h 2014-02-05 14:40:13.405522327 +0100
+++ /tmp/gmp.h 2015-01-19 08:35:38.146637514 +0100
@@ -2231,7 +2231,7 @@
/* Define CC and CFLAGS which were used to build this version of GMP */
#define __GMP_CC "/ws/on11update-tools/SUNWspro/sunstudio12.1/bin/cc"
-#define __GMP_CFLAGS "-m64 -xO4 -xchip=generic -Ui386 -U__i386
-xregs=no%frameptr -mt -features=extinl,extensions
-xustr=ascii_utf16_ushort -xcsi -xthreadvar=%all -D_STDC_99 -xc99=all
-D_XOPEN_SOURCE=600 -D__EXTENSIONS__=1 -D_XPG6 -KPIC -DPIC"
+#define __GMP_CFLAGS "-m64 -xO4 -xtarget=ultra2 -xarch=sparcvis
-xchip=ultra2 -Qoption cg -xregs=no%appl -W2,-xwrap_int -xmemalign=16s
-mt -features=extinl,extensions -xustr=ascii_utf16_ushort -xcsi
-xthreadvar=%all -D_STDC_99 -xc99=all -D_XOPEN_SOURCE=600
-D__EXTENSIONS__=1 -D_XPG6 -KPIC -DPIC"
/* Major version number is the value of __GNU_MP__ too, above and in
mp.h. */
#define __GNU_MP_VERSION 4
Let me also add that the gmp.h file does not define mpn_andn_n symbol at
all neither it declare __gmpn_andn_n function! Since both i386 and sparc
gmp.h are the same this applies to both.
> can you create a simple C program
> that calls the mpn_andn operation and compare how linkage differs?
No, I'm not able to use "mpn_andn" nor "mpn_andn_n". What I'm able to
use is "__gmpn_andn_n". On i386 this pass with implicitly declared
symbol warning:
gmp_test.c: In function ‘main’:
gmp_test.c:10:5: warning: implicit declaration of function ‘__gmpn_andn_n’
on sparc fails on linkage:
$ gcc -Wall gmp_test.c -lgmp
gmp_test.c: In function ‘main’:
gmp_test.c:10:5: warning: implicit declaration of function ‘__gmpn_andn_n’
Undefined first referenced
symbol in file
__gmpn_andn_n /var/tmp//ccSHaGtf.o
ld: fatal: symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
My testing program is:
$ cat gmp_test.c
#include <gmp/gmp.h>
#include <stdlib.h>
int
main()
{
__gmpn_andn_n((mp_limb_t*)NULL, (const mp_limb_t*)NULL, (const
mp_limb_t*)NULL, (mp_size_t)1);
return 0;
}
The big issue here is that i386/solaris gmp library so file provides
this __gmpn_andn_n symbol but have not declared it in gmp.h at all in a
form of mpn_andn_n define. So basically your:
-- void mpn_andn_n (mp_limb_t *rp, const mp_limb_t *s1p, const mp_limb_t
*s2p,
-- mp_size_t n)
foreign import ccall unsafe "gmp.h __gmpn_andn_n"
c_mpn_andn_n :: MutableByteArray# s -> ByteArray# -> ByteArray# ->
GmpSize#
-> IO ()
works on i386, but not on sparc.
Is it possible for you to test for those mpn_ symbols in integrer-gmp2
configure and if they are presented then you can use your __gmpn_andn_n
foreigner call?
Thanks!
Karel
More information about the ghc-devs
mailing list