This is the mail archive of the
mailing list for the glibc project.
Re: Per-machine additions to CFLAGS-rtld.c being overridden.
- From: Roland McGrath <roland at hack dot frob dot com>
- To: "Carlos O'Donell" <codonell at redhat dot com>
- Cc: Siddhesh Poyarekar <siddhesh at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>, Guy Martin <gmsoft at tuxicoman dot be>
- Date: Wed, 9 Jan 2013 18:03:16 -0800 (PST)
- Subject: Re: Per-machine additions to CFLAGS-rtld.c being overridden.
- References: <50EC4D90.firstname.lastname@example.org>
There are several layers here.
* Using per-file (or per-directory) *FLAGS settings is always the worst
option. Not only is it obscure and easily overlooked, it doesn't get
tracked as a dependency to recompile things as needed. We should avoid
it whenever possible.
If it's used for things like -D switches there is just no excuse.
That can be done with wrapper source files in sysdeps instead.
When it's used for code-generation options, it can't really be avoided at
the moment. One day the GCC pragma/attribute features for embedding such
options directly in the sources will be complete and we'll require
building libc with a GCC new enough to support all that. But that will
be a long time off.
* The reason subdir Makefiles do 'include ../Rules' earlyish rather than
last is so that the Makefile's own targets can use variables defined by
the infrastructure code. In addition to $(objpfx) and the like, some
places need to use make conditionals based on variables set by the common
stuff. It probably doesn't occur that such conditionals are used to
decide about setting CFLAGS-* variables. But it's just an overly tweaky
requirement that all variables be set before the include when pretty much
all targets/rules need to come after it.
* The real problem here is that both sysdeps makefile fragments and main
makefiles are both setting the same variables. It just makes confusion
and subtle errors like this far too likely. Originally that never
happened. That's why we have things like sysdep-CFLAGS. I think we
should fix the general problem by establishing a new rule that sysdeps
makefiles shall not touch such variables. Without any generic changes,
they could already do:
sysdeps-CFLAGS += $(sysdep-CFLAGS-$(<F))
sysdeps-CFLAGS-foo.c = -mblah
But since there already numerous examples, we might as well just change
CFLAGS in Makeconfig to use $(sysdep-CFLAGS-$(<F)) after the existing
generic per-file variables.