Subject: pkg/37564: devel/gmp-4.4.2 clashes with pkgsrc ABI variable
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <srxshelton@gmail.com>
List: pkgsrc-bugs
Date: 12/18/2007 16:30:00
>Number:         37564
>Category:       pkg
>Synopsis:       devel/gmp-4.4.2 clashes with pkgsrc ABI variable
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 18 16:30:00 +0000 2007
>Originator:     Stuart Shelton
>Release:        n/a - pkgsrc lastest from CVS
>Organization:
>Environment:
IRIX64 octane 6.5 07202013 IP30; IRIX 6.5.30f; MIPSpro 7.4.4m
>Description:

When ABI is set to '32' in /etc/mk.conf, transform_mipspro_cc adds "-n32" to CFLAGS.

However, in the gmp-4.2.2 package's Makefile is the conditional:

.if ${OPSYS} == "IRIX" && !empty(ABI)
ABI= o32
.endif

... which results in the compiler being passed "-n32" (from my default CFLAGS) and "-o32" (from transform_mipspro_cc) - which causes the compiler to abort with an error.

Surely, the check should be for 'empty(ABI)' rather than '!empty(ABI)' - why redefine the ABI to be different to every other package on the system (something which the bootstrap README expressly forbades), but only if it *is* already set?
>How-To-Repeat:

gmp's config.log contains:

User:
ABI=o32
CC=cc
CFLAGS=-c99 -O2 -n32 -mips4 -r14000 -apo -float_const -use_readonly_const -TARG:isa=mips4:platform=ip30:processor=r14000 -TENV:zeroinit_in_bss=ON -OPT:fast_io=ON:Olimit=8192:reorg_common=ON:swp=ON -LNO:auto_dist=ON:fusion_peeling_limit=8:gather_scatter=2 -woff 1174,1183,1185,1552,3970,3968 -o32
CPPFLAGS=-I/usr/bsd/include -D__inline__=inline
MPN_PATH=
GMP:
abilist=n32 64 o32
cclist=gcc cc
configure:4288: cc -c conftest.c >&5
cc-1020 cc: ERROR File = conftest.c, Line = 2
  The identifier "choke" is undefined.

    choke me
    ^

cc-1065 cc: ERROR at end of source
  A semicolon is expected at this point.


2 errors detected in the compilation of "conftest.c".
configure:4291: $? = 2
configure:4310: cc 2>&1 | grep xlc >/dev/null
configure:4313: $? = 1
configure:4367: checking compiler cc -c99 -O2 -n32 -mips4 -r14000 -apo -float_const -use_readonly_const -TARG:isa=mips4:platform=ip30:processor=r14000 -TENV:zeroinit_in_bss=ON -OPT:fast_io=ON:Olimit=8192:reorg_common=ON:swp=ON -LNO:auto_dist=ON:fusion_peeling_limit=8:gather_scatter=2 -woff 1174,1183,1185,1552,3970,3968 -o32 -I/usr/bsd/include -D__inline__=inline
Test compile:
configure:4381: cc -c99 -O2 -n32 -mips4 -r14000 -apo -float_const -use_readonly_const -TARG:isa=mips4:platform=ip30:processor=r14000 -TENV:zeroinit_in_bss=ON -OPT:fast_io=ON:Olimit=8192:reorg_common=ON:swp=ON -LNO:auto_dist=ON:fusion_peeling_limit=8:gather_scatter=2 -woff 1174,1183,1185,1552,3970,3968 -o32 -I/usr/bsd/include -D__inline__=inline conftest.c >&5
ERROR: [transform-mipspro-cc] Wrong ABI argument -n32 for ABI o32.
configure:4384: $? = 1
failed program was:

int main () { return 0; }
configure:5390: result: no
configure:5628: error: could not find a working compiler, see config.log for details

>Fix:

Changing the sense of the conditional actually results in:

configure: error: ABI=32 is not among the following valid choices: n32 64 o32
*** Error code 1

... so gmp's configure's use of the variable ABI is at odds with the pkgsrc convention of using '32' as the ABI value for 'n32' binaries.

This should be patched and fixed - because this package is actually impossible to compile: If the value of ABI is changed to 'n32' (as the package expects) then transform-mipspro-cc rejects it.

I have got gmp to compile successfully with the following patches:

--- configure.in        2007-12-17 11:49:07.703764040 +0000
+++ configure.in        2007-12-17 11:53:25.932823000 +0000
@@ -1542,6 +1542,7 @@
 # $abilist is restricted to just that choice.
 #
 if test -n "$ABI"; then
+  if test "$ABI" = "32"; then ABI=n32; fi
   found=no
   for abi in $abilist; do
     if test $abi = "$ABI"; then found=yes; break; fi
--- gmp-impl.h  2007-08-30 19:31:40.000000000 +0100
+++ /usr/bsd/src/devel/gmp/irix-fixes/gmp-impl.h        2007-12-17 18:42:57.675916520 +0000
@@ -189,6 +189,7 @@
 
 /* gmp_uint_least32_t is an unsigned integer type with at least 32 bits. */
 #if HAVE_UINT_LEAST32_T
+typedef unsigned int            uint_least32_t;
 typedef uint_least32_t      gmp_uint_least32_t;
 #else
 #if SIZEOF_UNSIGNED_SHORT >= 4
--- gmp.h       2007-12-17 18:57:17.066264600 +0000
+++ /usr/bsd/src/devel/gmp/irix-fixes/gmp.h     2007-12-17 18:42:57.674573960 +0000
@@ -348,6 +348,7 @@
    application uses for gmp_vprintf etc will almost certainly require the
    whole <stdarg.h> or <varargs.h> anyway.  */
 
+typedef char *va_list;
 #ifdef va_start
 #define _GMP_H_HAVE_VA_LIST 1
 #endif
@@ -516,10 +517,12 @@
 
 #if defined (__cplusplus)
 extern "C" {
+#if 0
 #ifdef _GMP_H_HAVE_FILE
 using std::FILE;
 #endif
 #endif
+#endif
 
 #define mp_set_memory_functions __gmp_set_memory_functions
 __GMP_DECLSPEC void mp_set_memory_functions __GMP_PROTO ((void *(*) (size_t),

... I'm not sure why the last two should be required, and someone with more skill than me should probably take a look in order to fix these properly... in both cases (va_list and uint_least32_t), the code won't compile without the extra definitions but complain about them being multiply defined if included as above!