Gentoo Archives: gentoo-dev

From: Paul de Vrieze <pauldv@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Automatically replace -mtune= with -mcpu= if not supported by gcc?!
Date: Tue, 19 Apr 2005 19:42:08
Message-Id: 200504192142.17877.pauldv@gentoo.org
In Reply to: [gentoo-dev] Automatically replace -mtune= with -mcpu= if not supported by gcc?! by Philipp Hasse
1 On Sunday 17 April 2005 15:50, Philipp Hasse wrote:
2 > Hi,
3 >
4 > I recently noticed that portage executes the file bashrc located in
5 > /etc/portage before every ebuild.
6 > This way it can be used to set the -mcpu and -mtune flags correctly.
7 > If you add the following to this file everything goes automatically:
8 >
9 > <--- SNIP --->
10 > # Automatically replace -mtune= with -mcpu if not supported by gcc
11 > # and vice versa.
12 > echo "" | gcc -mtune=i386 -E - > /dev/null 2> /dev/null
13 > if [ $? == 0 ]; then
14 > export CFLAGS=`echo $CFLAGS | /bin/sed 's/-mcpu=/-mtune=/'`
15 > export CXXFLAGS=`echo $CXXFLAGS | /bin/sed 's/-mcpu=/-mtune=/'`
16 > else
17 > export CFLAGS=`echo $CFLAGS | /bin/sed 's/-mtune=/-mcpu=/'`
18 > export CXXFLAGS=`echo $CXXFLAGS | /bin/sed 's/-mtune=/-mcpu=/'`
19 > fi
20 > <--- SNIP --->
21 >
22 > Maybe someone can give me a feedback if this is good idea or if I missed
23 > something for some exotic situation this will fail.
24 >
25 > Why doesn't portage do this automatically by itself? If it encounters an
26 > -mtuneĀ“= option in make.conf and gcc doesn't support it it replaces it
27 > with -mcpu=?!
28
29 It actually does (or did) the -mcpu to -mtune for newer gcc versions. This
30 creates all kinds of havoc if you want to compile a 3.3 gcc by a 3.4 gcc
31 (this works when not specifying -mcpu). It is so agressive that if you do try
32 to reverse this in your bashrc, it gets reversed again to -mtune. As it's
33 only necessary for compiling \<gcc-3.3 I just let it strip out -mtune
34 completely.
35
36 Paul
37
38 --
39 Paul de Vrieze
40 Gentoo Developer
41 Mail: pauldv@g.o
42 Homepage: http://www.devrieze.net