From owner-freebsd-current@FreeBSD.ORG Wed May 25 15:34:31 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 2C65C106564A; Wed, 25 May 2011 15:34:31 +0000 (UTC) (envelope-from lacombar@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id C9C878FC20; Wed, 25 May 2011 15:34:30 +0000 (UTC) Received: by iyj12 with SMTP id 12so9507081iyj.13 for ; Wed, 25 May 2011 08:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=wbgV/MgmauB55ptemDej1B2n6uQi20FVl5B3QTh362g=; b=wWMyrL/pf2PTnNQecHvhJKktLprgmU+fe+BC4nwxRCQii9PZ2jURrmbLQdD/V+2mCl TTA0SN5FKK0Qr+5qU++qH7OkNl2dXPNaXtZrSH2+pCuhX7t0jVTJKUXf1Fq3Q1SKwXqp X9w23NxcPaW19XZk85oZugsSdLcVkt2wpuxrs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=NXzPC/DHlf6LbMtgqo/gRM4bS5y/Je4jjiHJQdkWFMSu0vplS1r1gaZ22NL6g8X8Hj D8Xv+sgqtVxiAAdjdiqswt9cpHBOlbwpuaJz5Cnp6D2ubIZAzMgMf7c+LsfIPupF3t2M NaUTuJhK442Noi6G6RTKvqw1PZ6L4no52i6Uk= MIME-Version: 1.0 Received: by 10.43.58.15 with SMTP id wi15mr13262325icb.411.1306337669896; Wed, 25 May 2011 08:34:29 -0700 (PDT) Received: by 10.42.177.10 with HTTP; Wed, 25 May 2011 08:34:29 -0700 (PDT) In-Reply-To: <201105250943.15362.jhb@freebsd.org> References: <1306267772-31084-1-git-send-email-lacombar@gmail.com> <4DDC17E5.2020700@FreeBSD.org> <201105250943.15362.jhb@freebsd.org> Date: Wed, 25 May 2011 11:34:29 -0400 Message-ID: From: Arnaud Lacombe To: John Baldwin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 15:34:31 -0000 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=3Di386 and CPUTYPE=3Di586. This enforces >> `-march=3Di586' 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. =A0You must have something wrong in your jail if you can't do a bui= ldworld > with CPUTYPE set to none and have it do the right thing. =A0You need to f= ind > your root problem. =A0Forcing 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=3Di586, produces i686 instructions which are incompatible with the target CPU. - Arnaud