Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Aug 2007 01:54:58 -0500
From:      "Scot Hetzel" <swhetzel@gmail.com>
To:        FreeBSD-CURRENT <freebsd-current@freebsd.org>
Subject:   Setting CPUTYPE=native, fails to set MACHINE_CPU correctly.
Message-ID:  <790a9fff0708272354q31afca4fx1e787f9592a6a4e0@mail.gmail.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Gcc 4.2 has a new cpu_type (native) for x86 and amd64 systems.  This
cpu_type is to allow gcc to automatically detect the processor type
that gcc is running on.

The problem is that setting CPUTYPE?=native in either src.conf or
make.conf will cause MACHINE_CPU to be set to the wrong value for the
native cpu.

For example on a system where the processor is a k8, setting CPUTYPE
to k8, shows that MACHINE_CPU is set as follows:

hp010# make -V MACHINE_CPU -DCPUTYPE=k8
k8 3dnow amd64 sse2 sse mmx

But setting CPUTYPE to native on a k8 system sets MACHINE_CPU to this value:

hp010# make -V MACHINE_CPU -DCPUTYPE=native
unknown amd64 sse2 sse mmx

After patching share/mk/bsd.cpu.mk (see attachment) or the last patch
to PR 112997:

  http://www.freebsd.org/cgi/query-pr.cgi?pr=112997

setting CPUTYPE to native now works correctly when setting the value
for MACHINE_CPU:

hp010# make -V MACHINE_CPU -V CPUTYPE -DCPUTYPE=native
k8 3dnow amd64 sse2 sse mmx
k8

Could this get committed before -CURRENT is branched.

Thanks,

Scot

-- 
DISCLAIMER:
No electrons were mamed while sending this message. Only slightly bruised.

[-- Attachment #2 --]
Index: share/mk/bsd.cpu.mk
===================================================================
RCS file: /home/ncvs/src/share/mk/bsd.cpu.mk,v
retrieving revision 1.62
diff -u -r1.62 bsd.cpu.mk
--- share/mk/bsd.cpu.mk	21 May 2007 08:39:44 -0000	1.62
+++ share/mk/bsd.cpu.mk	28 Aug 2007 05:50:09 -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?790a9fff0708272354q31afca4fx1e787f9592a6a4e0>