Reputation: 1137
Compiling GCC from source I'm unsure on how and what to set for optimizing the build.
I want to build two versions. One optimized and one with ggdb
support (not sure if I need the second one). I'm currently concentrating about the first. On previous builds I have usually mainly gone with the defaults.
Find it a bit hard to search the World Wide Web for this, as well as GCC build in general, as 99.9% of the hits is about optimizing code compiled with gcc
and not about the optimization and build of gcc
itself.
Reading the gcc-4.8.1/INSTALL/index.html
docs it is little on this topic.
gcc-4.8.1/INSTALL/build.html
say one can use --with-build-config=NAME...
, but this option is not present in gcc-4.8.1/INSTALL/configure.html
. Is it meant to be used elsewhere?
./configure --with-build-config=bootstrap-O3 ...
Should one use:
make BOOT_CFLAGS='-O3'
instead?
Is it normal to use e.g.:
CFLAGS="-O3" && CXXFLAGS="-O3" && ./configure
or should one stay with BOOT_CFLAGS
?
I have also crossed path with pages like this one, where they state -O3
generates bloated binaries and Using -O3 is not recommended for gcc 4.x..
If this looks messy, you are completely right. I'm rather in a confused/messed/no oversight state here.
In short question are:
O3
a good choice?Upvotes: 5
Views: 856
Reputation: 5211
I personally was never a fan of O3. I find that the third level of optimization is optimization which trades off stability for the sake of optimization.
As was mentioned in the comments, 02 is pretty common. I have also left the default set for test builds just to be sure that gcc didn't destroy anything on accident and work my way up from there.
In all honesty, unless you're developing for embedded systems, it probably won't matter too much from the user's point of view, but it may be worth trying 02 and seeing what gains you get.
Upvotes: 1