Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Not using my CFLAGS when compiling
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
thecookie
n00b
n00b


Joined: 07 Jan 2005
Posts: 10
Location: Sweden

PostPosted: Fri Jan 14, 2005 10:48 am    Post subject: Not using my CFLAGS when compiling Reply with quote

I am having problems with portage not using my set CFLAGS in make.conf.

A snippet from my make.conf:
Code:

CFLAGS="-O3 -march=pentium3 -fforce-addr -momit-leaf-frame-pointer -fomit-frame-pointer -frename-registers -fweb -ftracer -pipe -ffast-math"
CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden -fvisibility=hidden"
LDFLAGS="-Wl,-O1"


My "emerge info" shows:
Code:

Portage 2.0.51-r2 (default-linux/x86/2004.3, gcc-3.4.3, glibc-2.3.4.20041102-r0, 2.6.8-nitro5-livecd i686)
=================================================================
System uname: 2.6.8-nitro5-livecd i686 Mobile Pentium II
Gentoo Base System version 1.4.16
Autoconf: sys-devel/autoconf-2.59-r5
Automake: sys-devel/automake-1.8.5-r1
Binutils: sys-devel/binutils-2.15.92.0.2-r2
Headers:  sys-kernel/linux26-headers-2.6.8.1-r2
Libtools: sys-devel/libtool-1.5.2-r5
ACCEPT_KEYWORDS="~x86"
AUTOCLEAN="yes"
CFLAGS="-O3 -march=pentium3 -fforce-addr -momit-leaf-frame-pointer -fomit-frame-pointer -frename-registers -fweb -ftracer -pipe -ffast-math"
CHOST="i686-pc-linux-gnu"
...


Everything seems fine there. But when I emerge something portage dosn't use those flags.

Example from compiling binutils:
Code:
checking whether the C compiler (gcc -O2 -march=pentium3 -pipe -Wl,-O1) works...


That isn't the flags I have set! But it seems to party be. When I remove -march=pentium3 from make.conf it seems to disappear from that line too.

Another example, compiling glibc, cut from the emerge output:

Code:

gcc version.c -c -std=gnu99 -O2 -O3 -Wall -Winline -Wstrict-prototypes -Wwrite-strings -freorder-blocks -march=pentium3 -pipe -mpreferred-stack-boundary=4
...


Have I missuderstood how it works? Maybe all frags aren't runt with gcc? But something is still wrong, the -O2/-O3 example.

Thanks for any help clearing this up!
Back to top
View user's profile Send private message
agne
n00b
n00b


Joined: 03 Nov 2004
Posts: 61

PostPosted: Fri Jan 14, 2005 10:50 am    Post subject: Reply with quote

Are you sure you edited /mnt/gentoo/etc/make.conf ? and not /etc/make.conf ?

When you chroot check your make.conf in etc and see if you edited the correct file.
Back to top
View user's profile Send private message
thecookie
n00b
n00b


Joined: 07 Jan 2005
Posts: 10
Location: Sweden

PostPosted: Fri Jan 14, 2005 11:04 am    Post subject: Reply with quote

agne wrote:
Are you sure you edited /mnt/gentoo/etc/make.conf ? and not /etc/make.conf ?

When you chroot check your make.conf in etc and see if you edited the correct file.


Yes I am sure I edited the right one. I edited it after chrooting. I wouldn't be able to write to /etc/make.conf on the livecd would I?

As I said, when removing -march=pentium3 from make.conf the binutils compiler check line removes that too.

It seems to be using flags from somewhere else?

In /etc/make.globals it says:
Code:

#            *****************************
#            **  DO NOT EDIT THIS FILE  **
# ***************************************************
# **** CHANGES TO make.conf *OVERRIDE* THIS FILE ****
# ***************************************************
...
CFLAGS="-O2 -mcpu=i686 -pipe"
...


I haven't edited that file, just checking it. -O2 is set there, dosn't seem to override that? But the -march/-mcpu seems to be overridden by my make.conf?

:?
Back to top
View user's profile Send private message
Maedhros
Bodhisattva
Bodhisattva


Joined: 14 Apr 2004
Posts: 5511
Location: Durham, UK

PostPosted: Fri Jan 14, 2005 11:05 am    Post subject: Reply with quote

A lot of ebuilds strip flags that are known not to work. In the case of glibc and binutils, that's most of them. :)
_________________
No-one's more important than the earthworm.
Back to top
View user's profile Send private message
kimchi_sg
Advocate
Advocate


Joined: 26 Nov 2004
Posts: 2969

PostPosted: Fri Jan 14, 2005 11:47 am    Post subject: Reply with quote

The reason not all of your CFLAGS are showing up in the compiler check is that Portage and the program's ebuild (the script called by Portage to compile and install the program) know better than you do, what CFLAGS are safe and will definitely work. Hence the emerge script will automatically filter out some or all of the CFLAGS you have set, before proceeding to the actual compilation.

x11-base/xorg-x11 is one program that will never compile with the CFLAGS you set, because there is a call in the ebuild script to filter out all user-defined CFLAGS before the actual compile.

If you know enough about editing ebuild scripts, you can remove the CFLAGS filtering code, but don't file any bug reports if you do so.

In short, it is better for your sanity that some / all CFLAGS get filtered out during emerges. :-)

You do value a system that runs without very optimized CFLAGS, over a system using optimized CFLAGS but is very unstable / doesn't boot at all, right?
Back to top
View user's profile Send private message
agne
n00b
n00b


Joined: 03 Nov 2004
Posts: 61

PostPosted: Fri Jan 14, 2005 12:20 pm    Post subject: Reply with quote

thecookie wrote:
agne wrote:
Are you sure you edited /mnt/gentoo/etc/make.conf ? and not /etc/make.conf ?

When you chroot check your make.conf in etc and see if you edited the correct file.


Yes I am sure I edited the right one. I edited it after chrooting. I wouldn't be able to write to /etc/make.conf on the livecd would I?

As I said, when removing -march=pentium3 from make.conf the binutils compiler check line removes that too.

It seems to be using flags from somewhere else?

In /etc/make.globals it says:
Code:

#            *****************************
#            **  DO NOT EDIT THIS FILE  **
# ***************************************************
# **** CHANGES TO make.conf *OVERRIDE* THIS FILE ****
# ***************************************************
...
CFLAGS="-O2 -mcpu=i686 -pipe"
...


I haven't edited that file, just checking it. -O2 is set there, dosn't seem to override that? But the -march/-mcpu seems to be overridden by my make.conf?

:?


Well you would not see the difference anyway.
Back to top
View user's profile Send private message
LordBug
Tux's lil' helper
Tux's lil' helper


Joined: 25 Jan 2003
Posts: 88

PostPosted: Fri Jan 14, 2005 2:04 pm    Post subject: Reply with quote

Quote:
Yes I am sure I edited the right one. I edited it after chrooting. I wouldn't be able to write to /etc/make.conf on the livecd would I?


Actually, yes. The LiveCD creates / in a RAM drive. You can write to it, but nothing is saved after reboot.

Removing -march=Pentium3 causes it to disappear from the GCC line tells me you edited the right file. The ebuild is just choosing to ignore some of your CFLAGS. It is a tad frustrating, but Portage is trying to save you from a broken compile.
Back to top
View user's profile Send private message
Bob P
Advocate
Advocate


Joined: 20 Oct 2004
Posts: 3355
Location: Jackass! Development Labs

PostPosted: Fri Jan 14, 2005 7:02 pm    Post subject: Re: Not using my CFLAGS when compiling Reply with quote

thecookie wrote:
Code:

CFLAGS="-O3 -march=pentium3 -fforce-addr -momit-leaf-frame-pointer -fomit-frame-pointer -frename-registers -fweb -ftracer -pipe -ffast-math"
CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden -fvisibility=hidden"
LDFLAGS="-Wl,-O1"


My "emerge info" shows:
Code:

Portage 2.0.51-r2 (default-linux/x86/2004.3, gcc-3.4.3, glibc-2.3.4.20041102-r0, 2.6.8-nitro5-livecd i686)
=================================================================
System uname: 2.6.8-nitro5-livecd i686 Mobile Pentium II
Gentoo Base System version 1.4.16
Autoconf: sys-devel/autoconf-2.59-r5


i'm not sure that i follow why your architecture is set tp pentium3 while your actual cpu is pentium2. is that the best choice for your hardware?
_________________
.
Stage 1/3 | Jackass! | Rockhopper! | Thanks | Google Sucks
Back to top
View user's profile Send private message
racoontje
Veteran
Veteran


Joined: 19 Jul 2004
Posts: 1290

PostPosted: Fri Jan 14, 2005 10:52 pm    Post subject: Reply with quote

Not all packages use the CFLAGS you provide. For a lot of them, it doesn't matter all that much (-momit-frame-pointer or -ffast-math is just rice on cp, ln, rm, ls...) plus they are known to break under agressiveness.

You CAN use these flags though, by editting the ebuild.
Back to top
View user's profile Send private message
thechris
Veteran
Veteran


Joined: 12 Oct 2003
Posts: 1203

PostPosted: Sun Jan 16, 2005 9:28 am    Post subject: Reply with quote

its one of the issues out there now with 2 sides:
1.) its annoying when the flags are ignored blindly.
2.) its annoying when one ebuild doesn't filter a bad flag.

once on a stage1 install, the best optimization that could be used was -O2 -pipe. -march broke a package as did -O3 and a list of others. so at that point i decided to just do the stage3 install. obviously here you want some flag filtering.

this is one reason for a package.cflags, a feature not yet in existance.
_________________
HW problems. It's a VIA thing.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum