Date: Sun, 16 Dec 2007 10:47:56 -0600 From: "Scot Hetzel" <swhetzel@gmail.com> To: "Pete French" <petefrench@ticketswitch.com> Cc: freebsd-stable@freebsd.org Subject: Re: Is it safe to use CPUTYPE?=native on 7.0 ? Message-ID: <790a9fff0712160847m4c25cf31t756f0a7988e2e1f8@mail.gmail.com> In-Reply-To: <E1J3w3B-000Iuy-Aw@dilbert.ticketswitch.com> References: <E1J3w3B-000Iuy-Aw@dilbert.ticketswitch.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On 12/16/07, Pete French <petefrench@ticketswitch.com> wrote:
> fairly simple question really - on machines where I never use the compiled
> binaries anywhere else, is it O.K. to set the CPU type to 'native' in
> make.conf ? According to gcc this should detect the processor type and
> set the various flas as approrpiate, which is nice, as we have a mix of P3,
> P4 and AMD processors around the place, and having one make.conf which will
> do the right thing on all of them would be nice.
>
> I've been trying it out on a couple of machines, and it seems to work fine,
> but I have a feeling that various bits of the kerenel complie are
> sensetive to the cpu type, so am just asking to check if it's O.K.
>
While setting CPUTYPE=native in /etc/make.conf may work, it fails to
set MACHINE_CPU to the correct values for your processor type.
The problem is that bsd.cpu.mk doesn't know how to handle CPU type 'native'.
There is a simple fix for this problem by applying the attached patch
which uses:
gcc -v -x c -E -mtune=native /dev/null -o /dev/null 2>&1 | grep mtune
| sed -e 's/.*mtune=//'
to reset CPUTYPE to the processor type of your system when CPUTYPE=native.
Scot
[-- Attachment #2 --]
Index: bsd.cpu.mk
===================================================================
RCS file: /home/ncvs/src/share/mk/bsd.cpu.mk,v
retrieving revision 1.63
diff -u -r1.63 bsd.cpu.mk
--- bsd.cpu.mk 16 Oct 2007 18:32:37 -0000 1.63
+++ bsd.cpu.mk 17 Oct 2007 22:28:32 -0000
@@ -18,6 +18,14 @@
. endif
.else
+# Handle 'native' by converting it to the appropriate CPUTYPE
+
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64"
+. if ${CPUTYPE} == "native"
+CPUTYPE != gcc -v -x c -E -mtune=native /dev/null -o /dev/null 2>&1 | grep mtune | sed -e 's/.*mtune=//'
+. endif
+.endif
+
# Handle aliases (not documented in make.conf to avoid user confusion
# between e.g. i586 and pentium)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?790a9fff0712160847m4c25cf31t756f0a7988e2e1f8>
