Per-arch CFLAGS
Warner Losh
imp at bsdimp.com
Sat Mar 15 16:59:32 UTC 2014
On Mar 15, 2014, at 8:28 AM, Ian Lepore <ian at 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.
>
> 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?
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
>
> 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
> _______________________________________________
> freebsd-arch at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-arch
> To unsubscribe, send any mail to "freebsd-arch-unsubscribe at freebsd.org"
More information about the freebsd-arch
mailing list