Bug 43750 - -march unconditionally added to COLLECT_GCC_OPTIONS
Summary: -march unconditionally added to COLLECT_GCC_OPTIONS
Status: RESOLVED MOVED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-14 08:56 UTC by Juergen Daubert
Modified: 2016-10-26 06:09 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux
Target: i686-pc-linux
Build: i686-pc-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juergen Daubert 2010-04-14 08:56:03 UTC
As of 4.5.0 -march is always added to COLLECT_GCC_OPTIONS if gcc is not called with that option.

$> echo '' | gcc -v -E - 2>&1 | grep -E '^(COLLECT_GCC_OPTIONS|gcc)'
gcc version 4.5.0 20100406 (prerelease) (CRUX) (GCC)
COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=generic' '-march=pentiumpro'

the same with gcc 4.4.3:

$> echo '' | gcc -v -E - 2>&1 | grep -E '^(gcc|COLLECT_GCC_OPTIONS)'
gcc version 4.4.3 (CRUX) (GCC)
COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=generic'

I run into that because I'm not able to compile glibc on i686 without explicit setting CC to something like "gcc -march=i586".
The reason is the well known _i686 problem, see [1] for a exact description of my error and [2] for a very old but recently reopen glibc bug.


[1] http://www.eglibc.org/archives/patches/msg00073.html
[2] http://sources.redhat.com/bugzilla/show_bug.cgi?id=411
Comment 1 pinskia@gmail.com 2010-04-14 17:56:58 UTC
Subject: Re:   New: -march unconditionally added to COLLECT_GCC_OPTIONS



Sent from my iPhone

On Apr 14, 2010, at 1:56 AM, "jue at jue dot li" <gcc-bugzilla@gcc.gnu.org 
 > wrote:

> As of 4.5.0 -march is always added to COLLECT_GCC_OPTIONS if gcc is  
> not called
> with that option.

Well this was on purpose as before configuring for i686-linux-gnu was  
really for i386 arch. Now it is correctly i686. If you don't want  
__i686 defined, configure gcc for i586-linux-gnu instead which  
defaults to i586.


>
> $> echo '' | gcc -v -E - 2>&1 | grep -E '^(COLLECT_GCC_OPTIONS|gcc)'
> gcc version 4.5.0 20100406 (prerelease) (CRUX) (GCC)
> COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=generic' '-march=pentiumpro'
>
> the same with gcc 4.4.3:
>
> $> echo '' | gcc -v -E - 2>&1 | grep -E '^(gcc|COLLECT_GCC_OPTIONS)'
> gcc version 4.4.3 (CRUX) (GCC)
> COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=generic'
>
> I run into that because I'm not able to compile glibc on i686  
> without explicit
> setting CC to something like "gcc -march=i586".
> The reason is the well known _i686 problem, see [1] for a exact  
> description of
> my error and [2] for a very old but recently reopen glibc bug.
>
>
> [1] http://www.eglibc.org/archives/patches/msg00073.html
> [2] http://sources.redhat.com/bugzilla/show_bug.cgi?id=411
>
>
> -- 
>           Summary: -march unconditionally added to COLLECT_GCC_OPTIONS
>           Product: gcc
>           Version: 4.5.0
>            Status: UNCONFIRMED
>          Severity: normal
>          Priority: P3
>         Component: debug
>        AssignedTo: unassigned at gcc dot gnu dot org
>        ReportedBy: jue at jue dot li
> GCC build triplet: i686-pc-linux
>  GCC host triplet: i686-pc-linux
> GCC target triplet: i686-pc-linux
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43750
>
Comment 2 Juergen Daubert 2010-04-14 19:15:19 UTC
Actually I want a i686 configured gcc and gcc should be able to compile glibc without setting -march to something different, that's how it works with any older gcc 4.x.

As you can see in my supplied examples, gcc 4.5.0 sets -march to pentiumpro whereas gcc 4.4.3 doesn't set -march at all, which is IMO the preferable behaviour. Adding optimization options should be the task of the calling application via CFLAGS.
Comment 3 Andrew Pinski 2010-04-14 19:19:06 UTC
This is a bug in glibc, __i686 is in the implementation namespace.  And this change was done on purpose to correct how GCC was not really configuring for a i686 compiler.
Comment 4 Juergen Daubert 2010-04-15 07:05:16 UTC
Ok, thanks, I feared that you would say that. Will try to move the issue to glibc.

But for now we have the unpleasant situation, that current gcc fails to compile current glibc if host is set to i686. 
Comment 5 Juergen Daubert 2010-04-16 11:20:35 UTC
Reopened the bug, because I'm still not convinced that the new behaviour of gcc 4.5 is correct.

With gcc 4.4 you have to explicit set arch optimization, usually done via CFLAGS. If not set there's no optimization. That's the reason why you can build glibc without problems, because glibc calls gcc without setting CFLAGS if appropriate. 

With gcc 4.5 arch is always set to the host arch and the caller has no possibility to unset arch, only to change it to something different. 

To build glibc it's therefor not sufficient to set CFLAGS to something like -march=i585 but you have to do a 'make CC="gcc -march=i586"'. That's ugly and not what you want at all on a i686 host.

Comment 6 Steven Bosscher 2010-07-20 22:56:17 UTC
Uros, what do you think of this bug, as i386 arch maintainer?
Comment 7 Andrew Pinski 2016-10-26 06:09:22 UTC
Fixed in glibc a long time ago.