From owner-freebsd-current@FreeBSD.ORG Wed May 25 16:28:34 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 791F1106564A; Wed, 25 May 2011 16:28:34 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 4D8D38FC08; Wed, 25 May 2011 16:28:34 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id D857446B03; Wed, 25 May 2011 12:28:33 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 759B28A050; Wed, 25 May 2011 12:28:33 -0400 (EDT) From: John Baldwin To: Arnaud Lacombe Date: Wed, 25 May 2011 12:28:32 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <1306267772-31084-1-git-send-email-lacombar@gmail.com> <201105250943.15362.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201105251228.32399.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 25 May 2011 12:28:33 -0400 (EDT) Cc: freebsd-current@freebsd.org, Dimitry Andric Subject: Re: [PATCH] Fix CFLAGS overwrite by Makefile X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 May 2011 16:28:34 -0000 On Wednesday, May 25, 2011 11:34:29 am Arnaud Lacombe wrote: > Hi, > > On Wed, May 25, 2011 at 9:43 AM, John Baldwin wrote: > >> The original trouble I met, is that building for an i586 target in a > >> 32bits jail, on top of an amd64 system[0] (I do not have control over > >> that setup) produces incorrect binaries. The current fix I've got is > >> to define MACHINE_ARCH=i386 and CPUTYPE=i586. This enforces > >> `-march=i586' to be passed to the compiler, for all except the > >> bootloader (because it overwrites CFLAGS). With this, binaries > >> produced works fine (ie. /bin/sh no longer SIGILL when bringing up the > >> system). So I suspect that gcc default to i686 in this setup and > >> corrupt all the binaries, thus the attached patch. > > > > Wait. You must have something wrong in your jail if you can't do a buildworld > > with CPUTYPE set to none and have it do the right thing. You need to find > > your root problem. Forcing CPUCFLAGS for the boot code is a band-aid, it's > > not the right solution to your problem. > > > Unless error of my part, I never mentioned it was using `buildworld', > which it is not. The system uses bare calls to make(1) in the > sys/boot/ directory. As the jail is 32bits, it was expected not to be > an issue, but the jail compiler uses /lib/libstand.a to link the > loader, and it obviously contains i686-only instructions, which > trigger a reset of an i586-only CPU. > > The more broad issue with the setup is that gcc within that > environment, without being told -march=i586, produces i686 > instructions which are incompatible with the target CPU. Huh? GCC does not generate i686 instructions by default on FreeBSD/i386. It generates i486 instructions but that is all. Are you sure you aren't running the 64-bit gcc (which will generate i686 instructions by default)? -- John Baldwin