Re: What is the best way to add a target specific system header directory

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

 



Martin J. O'Riordan kirjoitti 8.5.2017 klo 21:46:
I am building GCC as a cross compiler for the Sparc Leon processor, it has
been working well for me for several years and is currently at v6.3.0.

However, a recent change I want to make is to provide an additional
non-standard system header directory to be searched when '<...>' is used,
and this directory is located relative to the 'gcc' binary; in this case
relative to:

     <wherever>/bin/triple-gcc

I have tried using '--with-native-system-header-dir' but this wants an
absolute path.  I want to avoid redefining 'INCLUDE_DEFAULTS' with my own
custom replacement.  Substituting for '/usr/include' is okay too, because
the host version is not meaningful the context of cross compilation.

Any recommendations on how to configure for this, or should I add something
(a '#define' for example) to 'gcc/gcc/config/sparc/sparc.h'?

Let's start with the defaults for a crosscompiler. First, there are TWO separate places for the "standard target headers" and for the "system specific target headers"
(custom installation specific) :

$prefix/$target/include
and :
$prefix/$target/sys-include

So when one wants to see these, the command is to use the '-v' during the compile. Or use the 'cpp' ("C Pre Processor") directly - it no resides in the 'cc1', 'cc1plus' etc.
compilers. For instance :

[root@pomi-1700MHz 4.7.1]# pwd
/opt/cross/lib/gcc/sparc-elf/4.7.1
[root@pomi-1700MHz 4.7.1]# ./cc1 -v
#include "..." search starts here:
#include <...> search starts here:
 /opt/cross/lib/gcc/sparc-elf/4.7.1/include
 /opt/cross/lib/gcc/sparc-elf/4.7.1/include-fixed
 /opt/cross/lib/gcc/sparc-elf/4.7.1/../../../../sparc-elf/sys-include
 /opt/cross/lib/gcc/sparc-elf/4.7.1/../../../../sparc-elf/include
End of search list.

The "system specific" headers will be searched first.

For me it looks like you wouldn't need anything special, just put your "installation
specific" headers into the separate 'sys-include' and be happy...

The 'gcc/cppdefault.c' in the sources is where these two are defined :

#ifdef CROSS_INCLUDE_DIR
    /* One place the target system's headers might be.  */
    { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
#endif
#ifdef TOOL_INCLUDE_DIR
    /* Another place the target system's headers might be.  */
    { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 },
#endif

The 'sys-include' is the CROSS_INCLUDE_DIR and the 'include' is the TOOL_INCLUDE_DIR. At least the current gcc-7.1.0 has still this default. If you want a "hacked custom" GCC,
feel free to add your own added directories  into 'gcc/cppdefault.c' :)


Thanks,

     MartinO








[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux