Mailinglist Archive: opensuse (3666 mails)

< Previous Next >
Re: [SLE] Re: What is the proper way to optimize compilations?
  • From: "Carlos E. R." <robin1.listas@xxxxxxxxxx>
  • Date: Wed, 23 Mar 2005 22:19:45 +0100 (CET)
  • Message-id: <Pine.LNX.4.58.0503232140450.10344@xxxxxxxxxxxxxxxx>

The Monday 2005-03-14 at 13:33 +0100, Philipp Thomas wrote:

(It took some time for me to digest this information, thus my delay

> * Carlos E. R. [20050313 13:58]:
> > I have a P-IV, and when I compile something I like to have it optimized
> > for my cpu.
> > System types:
> > --build=BUILD configure for building on BUILD [guessed]
> > --host=HOST cross-compile to build programs to run on HOST [BUILD]
> > --target=TARGET configure for building compilers for TARGET [HOST]
> > I'm not sure which one should I use, to get output compiled for the
> > pentium4.
> See
> info '(autoconf)Canonicalizing'
> for an explanation.

Ah. That's a good place. More things to study...

Perhaps I can find around there a good explanation of what BUILD, TARGET,
and HOST really means in plain language.


More or less...

| the type of system on which the package is being configured and
| compiled. It defaults to the result of running `config.guess'.

So, giving "pentium4" as I did is not correct. I could perhaps try
"--build=i786-pc-linux-gnu --host=i786-pc-linux-gnu". I understand I have
to give both, because I compile on a pentium4, and want to produce code
for the same.

info excerpt (File:, Node: Hosts and Cross-Compilation):

The relationship between build, host, and target have been cleaned
up: the chain of default is now simply: target defaults to host, host
to build, and build to the result of `config.guess'. Nevertheless, in
order to ease the transition from 2.13 to 2.50, the following
transition scheme is implemented. _Do not rely on it_, as it will be
completely disabled in a couple of releases (we cannot keep it, as it
proves to cause more problems than it cures).

They all default to the result of running `config.guess', unless you
specify either `--build' or `--host'. In this case, the default
becomes the system type you specified. If you specify both, and
they're different, `configure' will enter cross compilation mode, so
it won't run any tests that require execution.

I understand then that giving the same value for both will not trigger
cross compilation mode.

Hint: if you mean to override the result of `config.guess', prefer
`--build' over `--host'. In the future, `--host' will not override the
name of the build system type. Whenever you specify `--host', be sure
to specify `--build' too.

Humm. Then perhaps I only need to give "--build"? Ah, I'm getting a

> But that won't get you anywhere unless the configure script has support for
> setting compiler options based on processor. BTW, run config.guess to see
> what configure will use as target tripple if you don't pass one explicitly.

Ah. It says "i686-pc-linux-gnu", more or less as I expected.

> > CFLAGS = -mcpu=pentium4 -O3 -march=pentium4 -pipe -fomit-frame-pointer ...
> >
> > It is a hack, and I have to remember it is there the next time I download
> > a new version. I don't like it, although it produces the expected result.
> >
> > Can you suggest a better, and general, method?
> There isn't a general method as most software do not provide a means other
> then CFLAGS/CXXFLAGS. But if the package doesn't provide a way to add your
> own CFLAGS/CXXFLAGS, you'll have to hack and/or to
> get what you want.

Yeap, that is what I always did (although I hack configure itself, not the
files you mention), as I wasn't sure how to get what I wanted. I can live
with hacks as I don't distribute my compilations O:-)

> BTW, if a package doesn't ignore passed in values and adds its own
> optimization flags via a different make variable, this should work:
> export CFLAGS="-march=pentium4 -mcpu=pentium4"
> ./configure

Yes, I thought of doing that, but I have not used it because I thought
that my "CFLAGS" would completely replace what the configure script was
going to use, and I only want my setting to be added to their default, not
replace it.

Ok, I see there is not a common way for all compilations, it depends on
each case. Thanks for your input.

Carlos Robinson

< Previous Next >
Follow Ups