Subject: pkg/15138: pkgsrc/security/pgp5 does not build in NetBSD-current (i386 only)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <boquist@crt.se>
List: netbsd-bugs
Date: 01/04/2002 12:40:18
>Number:         15138
>Category:       pkg
>Synopsis:       security/pgp5 does not build with new i386 toolchain
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 04 03:41:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Urban Boquist
>Release:        NetBSD 1.5ZA
>Organization:
Carlstedt Research & Technology AB, Sweden
>Environment:
System: NetBSD iller 1.5ZA NetBSD 1.5ZA (ILLER-$Revision: 1.42 $) #0: Wed Jan 2 23:17:59 CET 2002 root@iller:/usr/src/sys/arch/i386/compile/ILLER i386
Architecture: i386
Machine: i386
>Description:
Compilation stops for me with:

cc -O2 -DUNIX=1   -DHAVE_CONFIG_H -DPGPTRUSTMODEL=0 -DDEBUG=1 -DUNFINISHED_CODE_ALLOWED=0      -I../../../. -I../../.././include -I../include -I.     -c pgpRndPool.c
pgpRndPool.c: In function `pgpRandPoolAddEntropy':
pgpRndPool.c:339: Invalid `asm' statement:
pgpRndPool.c:339: fixed or forbidden register 0 (ax) was spilled for class AREG.
*** Error code 1

The asm is:

	__asm__("mull %2" : "=d"(r) : "%a"(a), "mr"(b) : "ax")

The problem is that an input operand is specified as clobbered, this
is no longer allowed in our new GCC. From GCC info:

	"It is an error for a clobber description to overlap an input
	 or output operand (for example, an operand describing a
	 register class with one member, mentioned in the clobber
	 list).  Most notably, it is invalid to describe that an input
	 operand is modified, but unused as output.  It has to be
	 specified as an input and output operand anyway."

The fix is to change the asm statement as shown below. I have tested
this on NetBSD-current and it makes pgp5 compile, and it seems to work
also for the compiler in NetBSD-1.5.2. The change is also identical to
a patch in the FreeBSD ports tree.

Unfortunately pgp5 with this patch applied and compiled on
NetBSD-current still doesn't seem to work quite right, it cannot
decrypt. Pgp5 with this patch applied but compiled on NetBSD-1.5.2
works as it should. So maybe there is another toolchain problem in
there somewhere...

Does pgp5 work OK on some non-i386 architecture with the new toolchain???

>How-To-Repeat:
	[on i386/-current]
	cd /usr/pkgsrc/security/pgp5
	make
>Fix:
--- lib/pgp/random/pgpRndPool.c.orig	Sat Aug  9 23:45:13 1997
+++ lib/pgp/random/pgpRndPool.c	Fri Jan  4 11:19:50 2002
@@ -298,7 +298,7 @@
 #ifndef UMULH_32
 #if defined(__GNUC__) && defined(__i386__)
 /* Inline asm goodies */
-#define UMULH_32(r,a,b) __asm__("mull %2" : "=d"(r) : "%a"(a), "mr"(b) : "ax")
+#define UMULH_32(r,a,b) __asm__("mull %2" : "=d"(r), "=a"(a) : "%1"(a), "mr"(b))
 #elif HAVE64
 #define UMULH_32(r,a,b) ((r) = (word32)((word64)(a) * (b) >> 32))
 #else
>Release-Note:
>Audit-Trail:
>Unformatted: