This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Generate /usr/libexec/getconf files when cross-compiling


> 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.

I can buy that.  Avoiding duplication is good when it's not extremely
awkward, but survivable when it is what's actually more maintainable.
My main point was that we should avoid compiling and running
build-host programs when we can.

> Preprocessing to get this information means including <unistd.h>, so the 
> preprocessor output includes all the content of unistd.h.

You can use:

	#define _UNISTD_H
	#include <bits/environment.h>

to avoid getting all 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.

The -dM trick is cute.  The traditional method (which I guess dates
from before we had -dM) was to use -E with input like:

@@@ foo=MACRO @@@

and use sed to extract based on the @@@ patterns.

> 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.

I'd be more inclined toward:

	#if _POSIX_V7_ILP32_OFF32 > 0
	KNOWN_ENVIRONMENT (V7_ILP32_OFF32)
	#else
	UNKNOWN_ENVIRONMENT (V7_ILP32_OFF32)
	#endif

or something like that.  Then the definitions of the macros can be
just magic marker strings for grepping in the build-time case, and
can be code fragments in the other cases.


Thanks,
Roland


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]