From owner-freebsd-arch@FreeBSD.ORG Sat Mar 15 14:28:25 2014 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5ED49531 for ; Sat, 15 Mar 2014 14:28:25 +0000 (UTC) Received: from mho-02-ewr.mailhop.org (mho-02-ewr.mailhop.org [204.13.248.72]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 31A19E22 for ; Sat, 15 Mar 2014 14:28:24 +0000 (UTC) Received: from c-24-8-230-52.hsd1.co.comcast.net ([24.8.230.52] helo=damnhippie.dyndns.org) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1WOpZS-000IDm-9g for freebsd-arch@FreeBSD.org; Sat, 15 Mar 2014 14:28:18 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id s2FESFIg065291 for ; Sat, 15 Mar 2014 08:28:15 -0600 (MDT) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 24.8.230.52 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX18ZirkdTp3ZQcjrcVMPMFaN Subject: Per-arch CFLAGS From: Ian Lepore To: freebsd-arch Content-Type: multipart/mixed; boundary="=-rfFM8btMGEB7fOLA+pEa" Date: Sat, 15 Mar 2014 08:28:15 -0600 Message-ID: <1394893695.1149.553.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Mar 2014 14:28:25 -0000 --=-rfFM8btMGEB7fOLA+pEa Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I've run into a situation where I need to pass architecture specific CFLAGS to the world stage of a cross-build but not have those flags in effect for the build-tools and cross-tools that run on the build host. I tried several things based on $TARGET_ARCH and manipulating the environment in Makefile.inc1 but everything I tried either didn't work or had unhappy side effects such as overriding automatically-supplied internal flags with the user-supplied flags, usually resulting in build failure because some crucial CPUTYPE stuff would be missing. After consulting with Warner a bit I came up with the attached rather simple change that does the job perfectly. It adds support for a CFLAGS.arch variable that can be set in make.conf or the command line or environment. Any objections to this? -- Ian --=-rfFM8btMGEB7fOLA+pEa Content-Disposition: inline; filename="cflags.arch.diff" Content-Type: text/x-patch; name="cflags.arch.diff"; charset="us-ascii" Content-Transfer-Encoding: 7bit Index: share/mk/bsd.cpu.mk =================================================================== --- share/mk/bsd.cpu.mk (revision 263112) +++ share/mk/bsd.cpu.mk (working copy) @@ -260,3 +260,7 @@ CFLAGS += -G0 .if !defined(NO_CPU_CFLAGS) CFLAGS += ${_CPUCFLAGS} .endif + +# Add in any architecture-specific CFLAGS. +# These come from make.conf or the command line or the environment. +CFLAGS += ${CFLAGS.${MACHINE_ARCH}} Index: share/examples/etc/make.conf =================================================================== --- share/examples/etc/make.conf (revision 263112) +++ share/examples/etc/make.conf (working copy) @@ -60,6 +60,12 @@ # nonstandard optimization settings # before submitting bug reports without patches to the developers. # +# CFLAGS.arch provides a mechanism for applying CFLAGS only when building +# the given architecture. This is useful primarily on a system used for +# cross-building, when you have a set of flags to apply to the TARGET_ARCH +# being cross-built but don't want those settings applied to building the +# cross-tools or other components that run on the build host machine. +# # CXXFLAGS controls the compiler settings used when compiling C++ code. # Note that CXXFLAGS is initially set to the value of CFLAGS. If you wish # to add to CXXFLAGS value, "+=" must be used rather than "=". Using "=" @@ -71,6 +77,7 @@ # # CFLAGS+= -msse3 # CXXFLAGS+= -msse3 +# CFLAGS.armv6+= -mfloat-abi=softfp # # MAKE_SHELL controls the shell used internally by make(1) to process the # command scripts in makefiles. Three shells are supported, sh, ksh, and --=-rfFM8btMGEB7fOLA+pEa--