On Thu, 22 Nov 2018, Martin Liška wrote:

> > (Multilib suffixes on include directories for C are more or less an 
> > implementation detail of how fixed headers are arranged in the case where 
> > sysroot headers suffixes are used; they aren't really expected to be a 
> > stable interface such that third-party software might install anything 
> > using them, but I'm not sure if this preinclude is meant to come from 
> > external software or be installed by GCC. 
> 
> It will come from glibc-devel package, and it's expected to be installed in:
> usr/include/finclude/ for 64-bit header
> and /usr/include/finclude/32/ for the 32-bit header.

So, to be clear, is that

<sysroot><sysroot-headers-suffix><native-system-header-dir>/finclude/$($CC 
$CFLAGS $CPPFLAGS -print-multi-directory)

?  (Where glibc would be what uses the $CC $CFLAGS $CPPFLAGS 
-print-multi-directory to determine where to install the file.)

If so, you need to make sure that all of those pieces are properly used.

* The sysroot and headers suffix in the case of a sysrooted toolchain.  
(Sysroot headers suffixes are for e.g. the case of a toolchain with both 
glibc and uClibc multilibs, so needing multiple sets of headers.  Most 
toolchains with multiple sysroots using the same libc only need a single 
set of headers and don't use sysroot headers suffixes, only sysroot 
suffixes (non-headers), with appropriate arrangements being made for all 
the per-multilib headers, such as gnu/lib-names-*.h and gnu/stubs-*.h, to 
be copied into the common include directory.)

* The native system header directory (which is /include not /usr/include 
for GNU Hurd, for example; see config.gcc).

* Then finclude with the multilib (non-OS) suffix.

And you need to consider what's right for non-sysrooted toolchains.  If 
native, the above is right, but without the sysroot-related components.  
But what about a non-sysrooted cross toolchain?  Certainly using the 
native directory would be wrong there.

Also, what's right in the multiarch directory arrangements case - should 
it be 
<sysroot><sysroot-headers-suffix><native-system-header-dir>/<multiarch>/finclude
 
instead?  Would one of the Debian / Ubuntu GCC maintainers like to 
comment?

Are there corresponding versions with /usr/local/include 
(LOCAL_INCLUDE_DIR, in general), before those with 
NATIVE_SYSTEM_HEADER_DIR?  Even in the driver, the list of directories in 
cppdefault.c should at least serve as a guide to which directories you 
want to search and which get sysroots added (of course, the C++-specific 
ones are irrelevant here).

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to