Subject: pkg/33136: multimedia/libmpeg2 build failure on NetBSD/amd64
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <njoly@pasteur.fr>
List: pkgsrc-bugs
Date: 03/23/2006 19:45:01
>Number:         33136
>Category:       pkg
>Synopsis:       multimedia/libmpeg2 build failure on NetBSD/amd64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 23 19:45:00 +0000 2006
>Originator:     Nicolas Joly
>Release:        NetBSD 3.99.17
>Organization:
Institut Pasteur, Paris.
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 3.99.17 NetBSD 3.99.17 (LANFEUST) #0: Tue Mar 21 11:38:38 CET 2006 root@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj/amd64/sys/arch/amd64/compile/LANFEUST amd64
Architecture: x86_64
Machine: amd64
>Description:
I just wanted to build multimedia/libmpeg2 0.4.0b on my -current NetBSD/amd64
workstation and noticed that it failed with assembly error messages:

 cc -DHAVE_CONFIG_H -I. -I../include -I/local/src/NetBSD/pkgsrc/multimedia/libmp
eg2/work/.buildlink/include -DGLX_GLXEXT_LEGACY -Wall -O2 -fomit-frame-pointer -
fno-common -MT libmpeg2arch_la-cpu_accel.lo -MD -MP -MF .deps/libmpeg2arch_la-cp
u_accel.Tpo -c cpu_accel.c  -fPIC -DPIC -o .libs/libmpeg2arch_la-cpu_accel.o
/var/tmp//ccCVSSOF.s: Assembler messages:
/var/tmp//ccCVSSOF.s:10: Error: suffix or operands invalid for `pop'
/var/tmp//ccCVSSOF.s:13: Error: suffix or operands invalid for `push'
/var/tmp//ccCVSSOF.s:16: Error: suffix or operands invalid for `pop'
/var/tmp//ccCVSSOF.s:24: Error: suffix or operands invalid for `push'
/var/tmp//ccCVSSOF.s:27: Error: suffix or operands invalid for `pop'
/var/tmp//ccCVSSOF.s:38: Error: suffix or operands invalid for `push'
/var/tmp//ccCVSSOF.s:41: Error: suffix or operands invalid for `pop'
/var/tmp//ccCVSSOF.s:52: Error: suffix or operands invalid for `push'
/var/tmp//ccCVSSOF.s:55: Error: suffix or operands invalid for `pop'
/var/tmp//ccCVSSOF.s:62: Error: suffix or operands invalid for `push'
/var/tmp//ccCVSSOF.s:65: Error: suffix or operands invalid for `pop'
gmake[2]: *** [libmpeg2arch_la-cpu_accel.lo] Error 1

This does not seems to be NetBSD specific as i got similar errors on
CentOS 4.2 Linux/x86_64 (RHEL clone).
>How-To-Repeat:
cd pkgsrc/multimedia/libmpeg2 && make
>Fix:
Apply the following patch derived from libmpeg2 CVS head.

Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/libmpeg2/distinfo,v
retrieving revision 1.7
diff -u -r1.7 distinfo
--- distinfo	20 Aug 2005 11:44:09 -0000	1.7
+++ distinfo	23 Mar 2006 19:29:54 -0000
@@ -4,3 +4,4 @@
 RMD160 (mpeg2dec-0.4.0b.tar.gz) = 44df6c21e88d2c3029ef418ea46e2d6796c90004
 Size (mpeg2dec-0.4.0b.tar.gz) = 473846 bytes
 SHA1 (patch-aa) = d70e401272fe1f87a1a1866248caabe8fab77193
+SHA1 (patch-ab) = 6408f33490fcdc734f7a4247a031c00399b75859
Index: patches/patch-ab
===================================================================
RCS file: patches/patch-ab
diff -N patches/patch-ab
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-ab	23 Mar 2006 19:29:54 -0000
@@ -0,0 +1,38 @@
+$NetBSD$
+
+--- libmpeg2/cpu_accel.c.orig	2006-03-23 20:07:31.000000000 +0100
++++ libmpeg2/cpu_accel.c	2006-03-23 20:08:21.000000000 +0100
+@@ -37,7 +37,7 @@
+     int AMD;
+     uint32_t caps;
+ 
+-#if !defined(PIC) && !defined(__PIC__)
++#if defined(__x86_64__) || (!defined(PIC) && !defined(__PIC__))
+ #define cpuid(op,eax,ebx,ecx,edx)	\
+     __asm__ ("cpuid"			\
+ 	     : "=a" (eax),		\
+@@ -46,7 +46,7 @@
+ 	       "=d" (edx)		\
+ 	     : "a" (op)			\
+ 	     : "cc")
+-#else	/* PIC version : save ebx */
++#else	/* PIC version : save ebx (not needed on x86_64) */
+ #define cpuid(op,eax,ebx,ecx,edx)	\
+     __asm__ ("push %%ebx\n\t"		\
+ 	     "cpuid\n\t"		\
+@@ -60,6 +60,7 @@
+ 	     : "cc")
+ #endif
+ 
++#ifndef __x86_64__ /* x86_64 supports the cpuid op */
+     __asm__ ("pushf\n\t"
+ 	     "pushf\n\t"
+ 	     "pop %0\n\t"
+@@ -77,6 +78,7 @@
+ 
+     if (eax == ebx)		/* no cpuid */
+ 	return 0;
++#endif
+ 
+     cpuid (0x00000000, eax, ebx, ecx, edx);
+     if (!eax)			/* vendor string only */