Subject: Re: pkg/30366: multimedia/mjpegtools fails to build with -march=pentium4
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Frederick Bruckman <fredb@immanent.net>
List: pkgsrc-bugs
Date: 05/29/2005 21:38:03
The following reply was made to PR pkg/30366; it has been noted by GNATS.

From: Frederick Bruckman <fredb@immanent.net>
To: Geert Hendrickx <geert.hendrickx@ua.ac.be>
Cc: gnats-bugs@netbsd.org
Subject: Re: pkg/30366: multimedia/mjpegtools fails to build with -march=pentium4
Date: Sun, 29 May 2005 16:36:52 -0500 (CDT)

 In article <20050529120001.592AB63B116@narn.netbsd.org>,
 	geert.hendrickx@ua.ac.be writes:
 > pkgsrc/multimedia/mjpegtools fails when built with -march=pentium4 in the CFLAGS.  It succeeds with any -march up to pentium3, but (!!), also succeeds with -march=pentium4 when -mcpu=pentium4 is added (however, this is automatically implied by gcc).  
 > 
 > The error comes from compiling some assembler code.  The ./configure script does some `uname -m' checking and accordingly sets a flag $have_cmov (unless $enable_cmov_extension == no).  However, on i386 (or better), NetBSD's "uname -m" _always_ returns i386 (luckily, otherwise binary packages built on a pentium2 bulk build machine wouldn't work on a lesser cpu).  
 
 My money's on the hand-tuned assembler, over the gcc flag. I agree 
 with you, that it would bad to do that automatically.  The package 
 could grow an option, ${MJPEGTOOLS_USE_CMOV}, and a note in the 
 description in "defaults/mk.conf" not to set that unless you run 
 only hosts that support it.  (I guess the simplist way to tell, on 
 NetBSD, is "grep CMOV /var/run/dmesg.boot".)
 
 >>How-To-Repeat:
 > Have CFLAGS+=-march=pentium4 without any -mcpu flag in /etc/mk.conf.  Then do make in pkgsrc/multimedia/mjpegtools: 
  
 >  cc -DHAVE_CONFIG_H -I. -I.. -I../utils -I/usr/obj/pkgsrc/multimedia/mjpegtools/work/.buildlink/include -DGLX_GLXEXT_LEGACY -I/usr/obj/pkgsrc/multimedia/mjpegtools/work/.buildlink/include/freetype2 -mcpu=i686 -march=i386 -O2 -pipe -march=pentium4 -Wall -Wunused -MT quantize_x86.lo -MD -MP -MF .deps/quantize_x86.Tpo -c quantize_x86.c  -fPIC -DPIC -o .libs/quantize_x86.o
 
 Look at that command line.  On the principle that "later options 
 override earlier ones", it has "-mcpu=i686 -march=pentium4", which 
 isn't a configuration you would ever call for deliberately. 
 
 >>Fix:
 > add -mcpu=pentium4 to the CFLAGS.  pkgsrc could copy any existing -march=$CPU flag to a -mcpu=$CPU flag to be sure, without breaking anything.  
 
 I think it's a good idea, if you set one, to set the other, if 
 not necessarily to the same thing.  What you're asking for, though, 
 would open up a big can of worms.  What if the compiler isn't gcc? 
 Or suppose it's gcc, but arm rather than i386:  should pkgsrc set 
 "-mtune"?  Should it set "-mfpe"?
 
 
 Frederick