Gentoo Archives: gentoo-user

From: Florian Philipp <f.philipp@××××××.de>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: Cannot compile texinfo: Illegal instruction -> Wrong -march and -mtune flags?
Date: Fri, 03 Aug 2007 10:19:52
Message-Id: 200708031211.35085.f.philipp@addcom.de
In Reply to: Re: [gentoo-user] Re: Cannot compile texinfo: Illegal instruction -> Wrong -march and -mtune flags? by Daniel da Veiga
1 Am Freitag 03 August 2007 03:06 schrieb Daniel da Veiga:
2 > On 8/2/07, Florian Philipp <f.philipp@××××××.de> wrote:
3 > > Am Donnerstag 02 August 2007 23:36 schrieb Alexander Skwar:
4 > > > · Florian Philipp <f.philipp@××××××.de>:
5 > > > > You see, they are not compatible and even if some code works I
6 > > > > wouldn't bet multimedia apps will perform well.
7 > > > >
8 > > > > With -mtune the instruction set stays the same. It is just
9 > > > > "rearranged".
10 > > >
11 > > > Hm. Allright. When using just -mtune (ie. without -march), the
12 > > > docs at
13 > > > http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/i386-and-x86_002d64-Options
14 > > >.htm l
15 > > >
16 > > > say:
17 > > > | While picking a specific cpu-type will schedule things appropriately
18 > > > | for that particular chip, the compiler will not generate any code
19 > > > | that does not run on the i386 without the -march=cpu-type option
20 > > > | being used.
21 > > >
22 > > > If -mtune=athlon-xp is used, code is generated which may make
23 > > > use of 3dNOW!. 3dNOW! is, of course, not to be found on 386 :)
24 > > > If the instruction set stays the same, code generated with
25 > > > -mtune=athlon-xp would not be executable on 386 machines, if
26 > > > I understand you correctly.
27 > > >
28 > > > Hm. With -mtune, the set of available instructions (ie.
29 > > > stuff like 3dNOW!, I suppose?) is NOT changed from the default
30 > > > of i386, is it? Or what does "Tune to cpu-type everything applicable
31 > > > about the generated code, except for the ABI and the set of available
32 > > > instructions." mean - especially note the "except for [...] the set of
33 > > > available instructions" part.
34 > > >
35 > > > So with "-mtune=pentium-m -march=athlon-xp" I'm making the compiler
36 > > > generate code which is "ordered" the way it's best for pentium-m
37 > > > machines while allowing it to use athlon-xp instruction set? Is
38 > > > that what I'm doing?
39 > > >
40 > > > If so, then it seems you're right - code will run, but maybe not
41 > > > so well.
42 > > >
43 > > > Is that understanding correct? If so, then I really should think
44 > > > twice about using "-mtune=pentium-m -march=athlon-xp", shouldn't
45 > > > I?
46 > > >
47 > > > Curious,
48 > > >
49 > > > Alexander Skwar
50 > > > --
51 > >
52 > > At least that's how I understand the issue. At the moment I've got two
53 > > ideas to solve your problem:
54 > >
55 > > 1. set march to an inferior target (pentium-3 and pentium-3m seem okay:
56 > > mmx and sse) and mtune for one (or even both?) of them
57 > > 2. set march to one of them and disable incompatible instruction sets
58 > > with options like -mno-sse2 or -mno-3dnow
59 >
60 > Isn't the -march=i686 valid?
61 > I guess that would be the most "compatible" option for binaries that
62 > will run on AMD and Intel processors... Or simply use no "-march"
63 > setting, only "-mtune"... I did that recently to switch a whole system
64 > from an Athlon XP to a Intel Core Duo...
65 >
66 -march=i686 -mmmx -msse would be the better choice, then.
67
68 I'd still like to know what gcc does when you enable two mtune settings. Use
69 the last one? Use both?