Date: Sat, 15 Mar 2014 10:59:23 -0600 From: Warner Losh <imp@bsdimp.com> To: Ian Lepore <ian@FreeBSD.org> Cc: freebsd-arch <freebsd-arch@FreeBSD.org> Subject: Re: Per-arch CFLAGS Message-ID: <0EBF508F-6504-414A-A2A0-39C5C2EEA6D0@bsdimp.com> In-Reply-To: <1394893695.1149.553.camel@revolution.hippie.lan> References: <1394893695.1149.553.camel@revolution.hippie.lan>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mar 15, 2014, at 8:28 AM, Ian Lepore <ian@FreeBSD.org> wrote:
> 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.=20=
>=20
> 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.
>=20
> 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?
This looks good to me. I like it better than earlier patches, and =
includes
the TARGET_ARCH->MACHINE_ARCH change I was going to suggest
after thinking about our last conversation.
Warner
> -- Ian
>=20
> Index: share/mk/bsd.cpu.mk
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- share/mk/bsd.cpu.mk (revision 263112)
> +++ share/mk/bsd.cpu.mk (working copy)
> @@ -260,3 +260,7 @@ CFLAGS +=3D -G0
> .if !defined(NO_CPU_CFLAGS)
> CFLAGS +=3D ${_CPUCFLAGS}
> .endif
> +
> +# Add in any architecture-specific CFLAGS. =20
> +# These come from make.conf or the command line or the environment.
> +CFLAGS +=3D ${CFLAGS.${MACHINE_ARCH}}
> Index: share/examples/etc/make.conf
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- 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=20
> +# the given architecture. This is useful primarily on a system used =
for=20
> +# cross-building, when you have a set of flags to apply to the =
TARGET_ARCH=20
> +# being cross-built but don't want those settings applied to building =
the=20
> +# cross-tools or other components that run on the build host machine. =
=20
> +#
> # 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, "+=3D" must be used rather than "=3D". =
Using "=3D"
> @@ -71,6 +77,7 @@
> #
> # CFLAGS+=3D -msse3
> # CXXFLAGS+=3D -msse3
> +# CFLAGS.armv6+=3D -mfloat-abi=3Dsoftfp
> #
> # MAKE_SHELL controls the shell used internally by make(1) to process =
the
> # command scripts in makefiles. Three shells are supported, sh, ksh, =
and
> _______________________________________________
> freebsd-arch@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-arch
> To unsubscribe, send any mail to =
"freebsd-arch-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0EBF508F-6504-414A-A2A0-39C5C2EEA6D0>
