This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to optimize my binutils compilation


Amine Chelghaf wrote:

> I am not sure if it is the correct place to ask this,
> so I apologize if it is off-topic.

This is more an autoconf question than a binutils question, because the
answer is not binutils-specific in any way.

> Then I run :
> configure --prefix=/tools --disable-nls
> make
> make install

If you do not set CFLAGS then you get the default, which is chosen by
autoconf.  If autoconf detects that you are using gcc, then it chooses
"-g -O2".  Thus you get optimization by default, so you need do nothing.

If you want to override autoconf's choice then you need to set CFLAGS
yourself.  To do this just add it to the end of the configure line, e.g.

./configure --foo=bar --blah CFLAGS="-O2"

Note that this is the modern form, but if you are using a tarball
package that was generated with the old autoconf 2.13 (which I believe
is still the case of the toplevel binutils configure script) then you
have to use the old form where you set it in the environment:

CFLAGS="-O2" ./configure --whatever

Note also that this only applies to the C language options; there are
many other *FLAGS variables that can be adjusted.  This is all
documented somewhere in the autoconf manual, which you should be able to
find online in HTML or by "info autoconf".

> It creates a huge library file :
> -rw-r--r-- 1 lfs lfs  4717022 Jan 21 15:08 libbfd.a

The size is large because the "-g" option which was part of CFLAGS means
to include debug information in the object files.  Without debug
information it is difficult (or impossible) to debug the application
with gdb or another debugger, so this is why it is enabled by default. 
The debug information just takes up disk space, it is not loaded into
memory at runtime so there should be zero performance effect due to
including it.  But if you really can't stand the extra size then set
CFLAGS to just "-O2" (or whatever you want, as long as it doesn't
include -g).

> When I look at config.log, I get those errors :
> configure:2192: checking whether compiler driver
> understands Ada
> configure:2224: checking how to compare bootstrapped
> objects
> configure:2344: checking for correct version of gmp.h
> configure:2357: gcc -c -g -O2   conftest.c 1>&5
> configure:2347:17: error: gmp.h: No such file or
> directory
> configure: In function 'main':
> configure:2351: error: 'choke' undeclared (first use
> in this function)
> configure:2351: error: (Each undeclared identifier is
> reported only once
> configure:2351: error: for each function it appears
> in.)
> configure:2351: error: expected ';' before 'me'
> configure: failed program was:
> #line 2346 "configure"
> #include "confdefs.h"

Here the configure script was checking for the GMP library on your
system, and the error is because it was not found, which is OK.  The
toplevel configure script is shared between several projects, one of
which is gcc which uses this library.  But for building binutils this is
completely irrelevant.

> My aim is to have optimized compilation for the
> target. And I am not sure if I applied correct
> options...

You already have it.  And also note that whether or not you build
binutils with optimization has no effect on the things that binutils
generates, i.e. the output code generated by gas and ld does not depend
on how they were compiled.  That will depend on the CFLAGS used for the
package being built, not binutils.

Brian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]