[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patches] Cross-getconf



On Tue, 27 May 2008, Maxim Kuvyrkov wrote:

> Hello,
> 
> The attached patch adds installation of <sysroot>/usr/libexec/posix/*
> files when cross-compiling EGLIBC, thus moving result of cross-build one
> step closer to that of native build.
> 
> The patch adds a new utility cross-getconf that is a stripped down
> version of native getconf.  Cross-getconf only handles cases that occur
> during cross-compilation of EGLIBC, when invoked with any other
> arguments it will fail with an error message.
> 
> Any comments?

(It would have been very helpful if this patch submission had included a 
detailed explanation of what the usr/libexec/getconf files are used for 
and what controls how the set differs between targets and multilibs, to 
save me needing to work this out and write it all up as part of the 
review.)

What targets did you test this for?  What targets did you compare to the 
results of a native build for?

You require all the values to be defined when you preprocess confstr.c:

+#ifndef _POSIX_V6_ILP32_OFF32
+# error "_POSIX_V6_ILP32_OFF32 is undefined"
+#endif
+#ifndef _POSIX_V6_ILP32_OFFBIG
+# error "_POSIX_V6_ILP32_OFFBIG is undefined"
+#endif
+#ifndef _POSIX_V6_LP64_OFF64
+# error "_POSIX_V6_LP64_OFF64 is undefined"
+#endif
+#ifndef _POSIX_V6_LPBIG_OFFBIG
+# error "_POSIX_V6_LPBIG_OFFBIG is undefined"
+#endif

But for some targets - any biarch target, I think (other than MIPS, but 
only because of the bug that MIPS doesn't have a bits/environments.h file) 
- some of these values will be left undefined at compile time, precisely 
so that getconf / sysconf can check at runtime the libexec/getconf 
directory.  When glibc is built for a particular multilib, the list of 
environments for that particular multilib is generated (the 
GETCONF_DIR=/dev/null setting ensures that the libexec/getconf directory 
doesn't get checked, so it is just environments for this multilib), and 
executables installed in that directory.  When getconf (the program) or 
sysconf (the C function) is used at runtime, without GETCONF_DIR defined, 
it will check that directory to determine whether one of the installed 
multilibs supports that environment - so the results will depend on which 
multilibs were in the end installed on that system.

Thus, I think your preprocessing step needs to be more complicated.  You 
should start by putting #undef of all the macros in cross-getconf.h (in 
case they are defined in the build system's headers included in 
cross-getconf).  Then for each macro, if it's defined in the results of 
preprocessing you should copy that definition to cross-getconf.h, but if 
not defined you should define it to -1.  The effects of a definition to -1 
should be equivalent to the effects of calling __sysconf with GETCONF_DIR 
defined to /dev/null, but the cross utility should never call an internal 
glibc function that returns results for the host such as __sysconf.

This needs testing and comparing to the results of a native build for at 
least one biarch target; preferably more.  It should be possible to 
include i686-pc-linux-gnu and x86_64-unknown-linux-gnu as both native and 
cross cases on the same system by appropriate manipulation of --build to 
control whether configure decides it's cross-compiling or not.

-- 
Joseph S. Myers
joseph@xxxxxxxxxxxxxxxx