From owner-freebsd-current@FreeBSD.ORG Tue May 24 21:30:38 2011 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8D5EA106566C; Tue, 24 May 2011 21:30:38 +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 491968FC12; Tue, 24 May 2011 21:30:37 +0000 (UTC) Received: by iyj12 with SMTP id 12so8575589iyj.13 for ; Tue, 24 May 2011 14:30:37 -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; bh=4G46OLcemaXp5A7QEft/rHOI8poNSWJ4yIZrdyCvSaI=; b=womRg5XB2d5v+iIBV6+DPlIw9tdRMEslxWZIh4XB8I4T06iRWbqkUQy1V1v9SQOEgQ ykTgkMMQwm2bwAnZjPqwv9RvwIhi8fVBpwPo/oXnu4c7sUD57gaubNFw9z/n5YuTCfQN HPIXA+Nam/anR7hg6htulc1yUZfayHKBH8ceU= 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; b=VyfaZev2utxyz4l0f+kHSog36latcQ3YRHLO+U5GVXT89AUYyqB6/fSptu7mgfr98d 8KpxrL/kyJUXY10EjAvNHMWFM7YfbucsjPn72/oztGoFL1khsMYNgRHhoYVvz+Lditud tMk4LdfkoAygKsYmre9QnFdjO2WUkJ9WJ13qQ= MIME-Version: 1.0 Received: by 10.42.229.135 with SMTP id ji7mr3639023icb.143.1306272637421; Tue, 24 May 2011 14:30:37 -0700 (PDT) Received: by 10.42.177.10 with HTTP; Tue, 24 May 2011 14:30:37 -0700 (PDT) In-Reply-To: <4DDC17E5.2020700@FreeBSD.org> References: <1306267772-31084-1-git-send-email-lacombar@gmail.com> <4DDC17E5.2020700@FreeBSD.org> Date: Tue, 24 May 2011 17:30:37 -0400 Message-ID: From: Arnaud Lacombe To: Dimitry Andric Content-Type: text/plain; charset=ISO-8859-1 Cc: current@freebsd.org 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: Tue, 24 May 2011 21:30:38 -0000 Hi, On Tue, May 24, 2011 at 4:41 PM, Dimitry Andric wrote: > On 2011-05-24 22:09, Arnaud Lacombe wrote: >> >> Many Makefile (espectially under sys/boot/) overwrite the value of CFLAGS. >> This is an issue if you want to generate code for a specific CPU as before >> the >> Makefile is interpreted, CFLAGS might already have been set with CPU >> specific >> settings by, which is source from sys.mk. > > ... >> >> --- a/sys/boot/i386/boot2/Makefile >> +++ b/sys/boot/i386/boot2/Makefile > > ... > > The problem with this patch is that for some of the things you fixed, > stuff like boot-time programs, you NEVER want any CPU specific settings! > You must use the default, lowest common denominator setting instead, or > there is no guarantee the boot program will be correct. > To use your argument against you: with the default, the boot program is not correct (see below). > So that is why these Makefiles purposefully overwrite CFLAGS. it is not > by accident. You just might be right, but unless the code say the overwrite is _on_purpose_, I would not assume the state of mind of the author, one way or another. > Besides, for space-constrained things like boot2, you > might not even be able to compile it when using non-standard settings, > since the code might grow too large. > or can shrink by using more optimized instructions. 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. - Arnaud [0]: to sum up, unless error of my part, this is a canadian setup where HOST=amd64, BUILD=i386 and TARGET=i586, and all hell breaks loose because of COMPAT_FREEBSD32.