HPUX 11 Build Problems with cc Compiler
Warren Gray
ve3wwg at gmail.com
Tue Feb 23 20:32:28 CET 2010
I was trying to build libgmp under HPUX 11 using the old cc compiler,
for +DA2.0N architecture. This (32-bits) is required because another
project (Postgres) doesn't seem to like +DA2.0W.
The libgmp build problems boil down to two things:
1. The switch() statement cannot handle values > 32 bits. This comes up in
"cc: "mod_1_3.c", line 89: error 1654: Expression type is too
large for switch
expression". This is simple to fix (the result can safely be
reduced to 32-bits).
2. The other problem that comes up in "cc: "sqrtrem.c", line 124: warning 602:
Integer constant exceeds its storage", which is a bit trickier.
Also the value
MAGIC is a problem in line 131.
If the attachment doesn't make the list, email me and I'll be glad to
fwd it to you.
In the 2nd case, it was necessary for me to declare a temp of type
mp_limb_signed_t and use smaller constants and shifting to compensate
for the compiler deficiency.
Thanks, Warren
-------------- next part --------------
/bin/sh ../libtool --tag=CC --mode=compile cc -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_`echo mod_1_3 | sed 's/_$//'` +uc +DA2.0N -c -o mod_1_3.lo mod_1_3.c
libtool: compile: cc -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_mod_1_3 +uc +DA2.0N -c mod_1_3.c +Z -DPIC -o .libs/mod_1_3.o
cc: "mod_1_3.c", line 89: error 1654: Expression type is too large for switch expression.
cc: "mod_1_3.c", line 91: error 1653: Case label too big for the type of the switch expression
cc: "mod_1_3.c", line 98: error 1653: Case label too big for the type of the switch expression
cc: "mod_1_3.c", line 103: error 1653: Case label too big for the type of the switch expression
make[2]: *** [mod_1_3.lo] Error 1
make[2]: Leaving directory `/home/proghome/wgay/work/feb23/gmp-5.0.1/mpn'
Orignal code:
=============
switch ((mp_limb_t) n * MODLIMB_INVERSE_3 >> (GMP_NUMB_BITS - 2))
{
case 0:
umul_ppmm (ph, pl, ap[n - 2], B1modb);
add_ssaaaa (ph, pl, ph, pl, 0, ap[n - 3]);
umul_ppmm (rh, rl, ap[n - 1], B2modb);
add_ssaaaa (rh, rl, rh, rl, ph, pl);
n -= 3;
break;
case 2: /* n mod 3 = 1 */
rh = 0;
rl = ap[n - 1];
n -= 1;
break;
case 1: /* n mod 3 = 2 */
Problem Description:
====================
The switch() statement can only handle 32-bit values in the old
HP cc compiler. This expression need not stay > 32 bits, as
all "case" constants are small values.
Changed to:
===========
switch ((unsigned)((mp_limb_t) n * MODLIMB_INVERSE_3 >> (GMP_NUMB_BITS - 2)))
^^^^^^^^^^^ ^
/bin/sh ../libtool --tag=CC --mode=compile cc -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_`echo sqrtrem | sed 's/_$//'` +uc +DA2.0N -c -o sqrtrem.lo sqrtrem.c
libtool: compile: cc -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_sqrtrem +uc +DA2.0N -c sqrtrem.c +Z -DPIC -o .libs/sqrtrem.o
cc: "sqrtrem.c", line 124: warning 602: Integer constant exceeds its storage.
cc: "sqrtrem.c", line 131: warning 602: Integer constant exceeds its storage.
libtool: compile: cc -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_sqrtrem +uc +DA2.0N -c sqrtrem.c -o sqrtrem.o >/dev/null 2>&1
...
make[2]: Leaving directory `/home/proghome/wgay/work/feb23/gmp-5.0.1/mpn'
cc: "sqrtrem.c", line 124: warning 602: Integer constant exceeds its storage.
==========================
#if GMP_NUMB_BITS > 32
a1 = a0 >> (GMP_LIMB_BITS - 1 - 32);
t = (mp_limb_signed_t) (0x2000000000000l - 0x30000 - a1 * x0 * x0) >> 16;
^^^^^^^^^^^^^^^^
Problem Description:
====================
The old HP cc compiler doesn't support constants > 32 bits.
Revised as:
===========
mp_limb_signed_t tc;
tc = 2;
tc <<= (13 * 4);
tc |= 1;
...
#if GMP_NUMB_BITS > 32
a1 = a0 >> (GMP_LIMB_BITS - 1 - 32);
/* t = (mp_limb_signed_t) (0x2000000000000l - 0x30000 - a1 * x0 * x0) >> 16; */
t = (mp_limb_signed_t) (tc - 0x30000 - a1 * x0 * x0) >> 16;
cc: "sqrtrem.c", line 131: warning 602: Integer constant exceeds its storage.
==========================
t = ((mp_limb_signed_t) ((a0 << 14) - t * t - MAGIC) >> (32-8));
^^^^^
Revised As:
===========
mp_limb_signed_t tmagic = 1;
#if GMP_NUMB_BITS > 32
tmagic <<= (10*4); /* 0xffe7debbfc < MAGIC < 0x232b1850f410 */
#else
tmagic <<= (5*4); /* 0xfee6f < MAGIC < 0x29cbc8 */
#endif
...
t = ((mp_limb_signed_t) ((a0 << 14) - t * t - tmagic) >> (32-8));
^^^^^^
More information about the gmp-bugs
mailing list