From hg@cally.queue.to  Sat Nov  3 20:30:36 2012
Return-Path: <hg@cally.queue.to>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 9F79F81F
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  3 Nov 2012 20:30:36 +0000 (UTC)
	(envelope-from hg@cally.queue.to)
Received: from pickle.queue.to (pickle.queue.to [71.180.69.18])
	by mx1.freebsd.org (Postfix) with ESMTP id 31F478FC14
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  3 Nov 2012 20:30:35 +0000 (UTC)
Received: (qmail 57996 invoked from network); 3 Nov 2012 16:23:54 -0400
Received: from cally.queue.to (172.16.0.6)
  by pickle.queue.to with ESMTP; 3 Nov 2012 16:23:54 -0400
Received: (qmail 71555 invoked by uid 1000); 3 Nov 2012 16:23:54 -0400
Message-Id: <20121103202354.71554.qmail@cally.queue.to>
Date: 3 Nov 2012 16:23:54 -0400
From: Howard Goldstein <hg@cally.queue.to>
Reply-To: Howard Goldstein <hg@cally.queue.to>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: clang kernel cross-builds ignore CPUTYPE?= and always generate native tuned code
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         173337
>Category:       kern
>Synopsis:       clang kernel cross-builds ignore CPUTYPE?= and always generate native tuned code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    linimon
>State:          feedback
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Nov 03 20:40:00 UTC 2012
>Closed-Date:    
>Last-Modified:  Thu Apr 17 04:27:23 UTC 2014
>Originator:     Howard Goldstein
>Release:        
>Organization:
>Environment:
Oct 30 13:45:20 pickle kernel: FreeBSD 9.1-PRERELEASE #13: Thu Oct 25 22:29:56 E
DT 2012
Oct 30 13:45:20 pickle kernel: hg@pickle.queue.to:/usr/obj/usr/src/sys/PICKLE i3
86
Oct 30 13:45:20 pickle kernel: CPU: Intel(R) Core(TM)2 Duo CPU     E6750  @ 2.66
GHz (2667.76-MHz 686-class CPU)
Oct 30 13:45:20 pickle kernel: Origin = "GenuineIntel"  Id = 0x6fb  Family = 0x6
  Model = 0xf  Stepping = 11
Oct 30 13:45:20 pickle kernel: Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MC

	
>Description:
Kernel compiled on a system id'd as a core2 a/k/a nocona in i386 mode  (above)
and stock clang of 9.1 prerelease 13:

 pickle:~$ clang -v
 FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
 Target: i386-unknown-freebsd9.0
 Thread model: posix

for a i386 for a pentium4 both i386 with these set in make.conf

CPUTYPE?=pentium4
CC=clang 
CXX=clang++ 
CPP=clang-cpp 

The resulting kernel seems to actually be built for the host 
as if -march=native were set, ignoring CPUTYPE?=pentium4

This is almost surely the same problem reported on -stable by
Volodymyr Kostyrko c.kworr on Wed Oct 24 07:57:26 UTC 2012
at http://lists.freebsd.org/pipermail/freebsd-stable/2012-October/070228.html

	
>How-To-Repeat:
	

Build a kernel with clang on a host that is, for lack of a better expression
"stronger" than your handy, "lesser" target.  For ex., a core2 host targetting
a pentium-m.

Now install emulators/wine or emulator/wine-devel, built however you
like. The wine process handles its own trapping which makes this very
difficult to identify (for me, anyway) as a kernel issue:

err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x622...

and wine opens a black window and hangs up.

From gdb it's a bit more verbose and yields a map file error.

This is probably impossible to reproduce without a separate target system
real or virtual that doesn't support the instruction set of the build host.

>Fix:

	

Revert to stock gcc4.2 for crossbuilding 9.1 kernels destined for 
a specific CPUTYPE that doesn't  match the host

This PR may belong in conf or ports instead of kern, please recategorize
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: linimon 
State-Changed-When: Thu Apr 17 04:27:08 UTC 2014 
State-Changed-Why:  
to submitter: xdev has recently been reworked.  Is this PR now obsolete? 


Responsible-Changed-From-To: freebsd-bugs->linimon 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Apr 17 04:27:08 UTC 2014 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=173337 
>Unformatted:
 Release:       FreeBSD 9.1-PRERELEASE i386
