This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Generate /usr/libexec/getconf files when cross-compiling
On Wed, 14 Nov 2012, Roland McGrath wrote:
> I'm not clear on why it's really necessary to compile a whole build-side
> program to generate this file. Can't you just glean the information
> from a common source file used in sysconf that you also put directly
> through cpp to grovel it in a scripty way?
I think use of a common source file is inevitably awkward, given the
differences between how these macros are used in sysconf, in getconf and
to determine this list.
Preprocessing to get this information means including <unistd.h>, so the
preprocessor output includes all the content of unistd.h. For automatic
extraction of just the relevant bits of information it's certainly better
just to look at the defined macros, hence this patch using -dM to extract
macro values.
I guess the most convenient form for processing cpp output to produce the
list directly would be a source file that does things like:
#include <unistd.h>
#if _POSIX_V7_ILP32_OFF32 > 0
# define THIS_LIBC_HAS_POSIX_V7_ILP32_OFF32
#else
# undef THIS_LIBC_HAS_POSIX_V7_ILP32_OFF32
#endif
for each macro, and then look for THIS_LIBC_HAS_ macros in the -dM output
as indicating which the supported environments for this libc are.
What doesn't seem possible with the C preprocessor is having a common file
that just does
HANDLE_ENVIRONMENT (POSIX_V7_ILP32_OFF32, _SC_V7_ILP32_OFF32)
HANDLE_ENVIRONMENT (POSIX_V7_ILP32_OFFBIG, _SC_V7_ILP32_OFFBIG)
...
with three users of that file (posix/confstr.c, sysdeps/posix/sysconf.c,
and some new user to generate this list at build time) all defining
HANDLE_ENVIRONMENT differently - because the desired effects of
HANDLE_ENVIRONMENT would include #if and #define directives, which aren't
possible in a macro. (And, in confstr.c the environments are handled in
three groups, under three separate _CS_* cases, further complicating any
generic framework that would attempt to cover all the cases needing to
handle all these macros.)
--
Joseph S. Myers
joseph@codesourcery.com