Bug 1044 - sys-apps/hdparm-4.6.ebuild fails with Crusoe optimizations
Bug#: 1044 Product:  Gentoo Linux Version: unspecified Platform: x86
OS/Version: Linux Status: RESOLVED Severity: critical Priority: P2
Resolution: FIXED Assigned To: g2boojum@gentoo.org Reported By: robm@flipturn.org
Component: Ebuilds
URL: 
Summary: sys-apps/hdparm-4.6.ebuild fails with Crusoe optimizations
Keywords:  
Status Whiteboard: 
Opened: 2002-03-10 08:23 0000
Description:   Opened: 2002-03-10 08:23 0000
With the optimizations I wanted to use for compiling on the Crusoe processor:

-O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe
-mpreferred-stack-boundary=2 -march=i686 -malign-functions=0 -malign-jumps=0
-malign-loops=0

the sys-apps/hdparm ebuild fails because in src_unpack(), the sed command
replaces the -mpreferred-stack-boundary with '-mpreferredtack-boundary' instead
of removing the '-s' flag from the command line as was intended.

In general, any time sed is used to place the CFLAGS in a Makefile, we ought to
do any changes/deletions to the file before we insert the CFLAGS.  In other
words, unless you really mean to potentially change the user's CFLAGS, the
CFLAGS insertion ought to come last in the sed command.

Here's a fix for hdparm.

--- hdparm-4.6.ebuild	Sun Mar 10 07:53:31 2002
+++ hdparm-4.6-r1.ebuild	Sun Mar 10 07:50:15 2002
@@ -12,7 +12,7 @@
 	unpack ${A}
 	cd ${S}
 	mv Makefile Makefile.orig
-
sed -e "s/-O2/${CFLAGS}/" -e "s:-s::" \
+
sed -e "s:-s::" -e "s/-O2/${CFLAGS}/" \
 	Makefile.orig > Makefile
 }

------- Comment #1 From Daniel Robbins (RETIRED) 2002-03-12 10:01:03 0000 -------
Grant -- I fixed this bug on CVS, but I'm reassigning it to you because we
really need to add this info to our Development HOWTO.  It's something that
never occurred to me.

------- Comment #2 From Maik Schreiber 2002-05-29 10:31:37 0000 -------
What's so different about this patch now? It still replaces things like
"-fkeep-static-consts" with "-fkeeptatic-consts" :-/

Better make that

  ... -e 's| -s||' ...

(note the space)

------- Comment #3 From Grant Goodyear 2002-07-19 10:13:14 0000 -------
Killed old version, thereby fixing the problem.
Good catch!