[Pythonmac-SIG] No arbitrary precison math on Mac-tel say it ain't so!
Alex Martelli
aleaxit at gmail.com
Sun Apr 23 01:35:38 CEST 2006
On Apr 22, 2006, at 1:29 PM, Ronald Oussoren wrote:
...
> On other platforms I'd say that gmp should be compiled with -fPIC
> in the compiler flags. On OSX however this
That's one of the things I tried (adding CFLAGS=-fPIC to the ./
configure invocation), uselessly.
> should be the default. It could be a problem in an assembly file.
> Given the .asm files and configure script I'd guess that it might
> help to add '--with-pic' to the configure line.
OK, tried this - and now the assembly is failing:
/bin/sh ../libtool --mode=compile --tag=CC ../mpn/m4-ccas --m4="m4"
gcc -c -DHAVE_CONFIG_H -I. -I. -I.. -D__GMP_WITHIN_GMP -I.. -
DOPERATION_`echo dive_1 | sed 's/_$//'` -fPIC `test -f
'dive_1.asm' || echo './'`dive_1.asm
../mpn/m4-ccas --m4=m4 gcc -c -DHAVE_CONFIG_H -I. -I. -I.. -
D__GMP_WITHIN_GMP -I.. -DOPERATION_dive_1 -fPIC dive_1.asm -fno-
common -DPIC -o dive_1.o
m4 -DHAVE_CONFIG_H -D__GMP_WITHIN_GMP -DOPERATION_dive_1 -DPIC
dive_1.asm >tmp-dive_1.s
gcc -c -DHAVE_CONFIG_H -I. -I. -I.. -D__GMP_WITHIN_GMP -I.. -
DOPERATION_dive_1 -fPIC tmp-dive_1.s -fno-common -DPIC -o dive_1.o
tmp-dive_1.s:108:invalid character '@' in first operand
make[2]: *** [dive_1.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
The relevant fragment of that tmp-dive_1.s is:
106 call Lmovl_eip_ebp
107 addl $_GLOBAL_OFFSET_TABLE_, %ebp
108 movl ___gmp_modlimb_invert_table at GOT(%ebp), %ebp
109 movzbl (%eax,%ebp), %ebp
and the corresponding fragment of dive_1.s:
79 ifdef(`PIC',`
80 call L(movl_eip_ebp)
81 addl $_GLOBAL_OFFSET_TABLE_, %ebp
82 movl modlimb_invert_table at GOT(%ebp), %ebp
83 movzbl (%eax,%ebp), %ebp C
inv 8 bits
84
85 ',`
86 dnl non-PIC
87 movzbl modlimb_invert_table(%eax), %ebp C
inv 8 bits
88 ')
So, m4 is doing its job (so, your suggestion was no doubt right,
thanks!), picking the PIC version rather the non-PIC one... and
unfortunately the PIC version does hit some assembler-syntax issue,
it would seem.
One note in the Makefile in that directory may be relevant...:
# Libtool adds -DPIC when building a shared object and the .asm files
look
# for that. But it should be noted that the other PIC flags are on
occasion
# important too, in particular FreeBSD 2.2.8 gas 1.92.3 requires -k
before
# it accepts PIC constructs like @GOT, and gcc adds that flag only under
# -fPIC. (Later versions of gas are happy to accept PIC stuff any
time.)
I can't find any docs for the "@GOT" syntax (presumably of GNU as),
though I'm sure it's somehow referring to a global-offset-table --
the only occurrence of '@' I've found in GNU as's Reference manual is
about .symver (and it does appear relevant to what ld is later meant
to do), but there are no occurrences of that directive in these
source and include files anyway.
Unfortunately, no web search engine that I know of has any notion of
letting you search for special characters such as '@', and the word
'GOT' is so common that it is absolutely no use whatsoever - I've
searched for 'global offset table, 'pic' and 'position independent
code', and so on and so forth, but all to no avail.
Assuming there's some parallel between Apple assembler syntax for x86
and PPC I've pored over the Powerpc assembler parts of GMP 4.2, and
there are some very cryptic notes about assembly PIC and non-PIC for
Linux AIX and Darwin, but nothing that seems to apply or help in any
way here.
I'm rather stalled, so, for now, I've built GMP 4.2 to NOT use any
assembly on my Mac-Intel and proceeded with other work needed to make
gmpy compatible with GMP 4.2 (mostly tweaks on unittests, but one
somewhat major rework to the random-number facility, which changed
drastically in 4.2).
Anyway, thanks for the help so far -- my plans now include checking
the current gmpy (with GMP 4.2 _and_ 4.1) on PPC, measuring speed (to
guess how much I lose by having to disable assembly on Mac-Intel),
further checking and measuring on Linux and Windows, etc. I hope,
before I release gmpy 1.02 at some point, to get back to the
"assembly on Mac-Intel" issues... can anybody perchance suggest
suitable newsgroups, mailing lists, or sites, where somebody might,
upon seeing the issue with "whatever at GOT(%bx)" etc, immediately
suggest some solution?-)
Alex
More information about the Pythonmac-SIG
mailing list