Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Jul 2011 15:51:32 +0200
From:      Dimitry Andric <dim@FreeBSD.org>
To:        freebsd-hackers@freebsd.org
Cc:        "Julian H. Stacey" <jhs@berklix.com>, freebsd-toolchain@freebsd.org, freebsd-i386@freebsd.org
Subject:   Re: Freebsd-7.4 + std gcc 4.2.1 fails to honour -march=i586
Message-ID:  <4E282EE4.50500@FreeBSD.org>
In-Reply-To: <201107211217.p6LCHV9p025307@fire.js.berklix.net>
References:  <201107211217.p6LCHV9p025307@fire.js.berklix.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2011-07-21 14:17, Julian H. Stacey wrote:
> Summary:
>    I found a problem with CFLAGS += -march=i586 on an i686 linking
>    a crt.o for an i686, then not running on an i586,

IMHO this is a bit of a PEBKAC issue.  If you change CPUFLAGS to target
a specific CPU, you should really rebuild all of world with it, not just
a single program.  In fact, you should rebuild all your ports too.


> I suggested
>    maybe -march could be extended to also select seperate lib sub
>    directories to at least trigger a link failure, rather than a silent
>    apparent good compile of a bad binary.

I think this would add a whole lot of complexity for very little gain,
and still not save you from potential problems.  You would really have
to use the same approach for all system libraries, otherwise you might
link in something from e.g. libc or libcrypto that was optimized for the
wrong CPU.  And I'm not even mentioning objects and/or libraries from
ports... :)

The compiler cannot automagically determine whether any object or
library file you link into your program is fit to run on the CPU you are
targeting, unless you would add information specifying the CPU type (and
other particulars) to the object files themselves.  In the end, it is up
to you to make sure you do not mix "incompatible" object code.

Having said all this, if you are worried particularly about the crt*.o
files, then we could simply always build those with 'lowest common
denominator' flags, like we do with e.g. the dynamic linker.  I doubt
very much that the startup code gains any performance by optimizing for
higher CPU types.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4E282EE4.50500>