Date: Sat, 15 Mar 2014 08:28:15 -0600 From: Ian Lepore <ian@FreeBSD.org> To: freebsd-arch <freebsd-arch@FreeBSD.org> Subject: Per-arch CFLAGS Message-ID: <1394893695.1149.553.camel@revolution.hippie.lan>
index | next in thread | raw e-mail
[-- Attachment #1 --]
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
[-- Attachment #2 --]
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
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1394893695.1149.553.camel>
