This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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

Re: Trying to build a cross compiler from linux to netbsd...


Alexandre Oliva wrote:
> 
> On Jan  3, 2001, Kai Ruottu <kai.ruottu@luukku.com> wrote:
> 
> >  But why they must now be preinstalled into the 'sys-include', not into
> > the 'include' as done during the last ten or so years?
> 
> Because GCC's include directory contains GCC's own files, and possibly
> fixincluded versions of files in sys-include, and we don't want to
> overwrite them.

 I didn't really ask about the '.../gcc/include', but about the $prefix/$target/include
versus the $prefix/$target/sys-include... Here are the related instructions from a quite
recent GCC manual (for 2.96 snapshots):

------------------------------- clip -------------------------------------------------- 
  Cross-Compilers and Header Files

  If you are cross-compiling a standalone program or a program for an embedded system,
  then you may not need any header files except the few that are part of GNU CC (and
  those of your program).  However, if you intend to link your program with a standard
  C library such as libc.a, then you probably need to compile with the header files
  that go with the library you use.

  The GNU C compiler does not come with these files, because (1) they are system-specific,
  and (2) they belong in a C library, not in a compiler.

  If the GNU C library supports your target machine, then you can get the header files
  from there (assuming you actually use the GNU library when you link your program).

  If your target machine comes with a C compiler, it probably comes with suitable header
  files also.  If you make these files accessible from the host machine, the cross-compiler
  can use them also.

  Otherwise, you're on your own in finding header files to use when cross-compiling.

  When you have found suitable header files, put them in the directory
  /usr/local/target/include, before building the cross compiler.  Then installation will
  run fixincludes properly and install the corrected versions of the header files where
  the compiler will use them.

  Provide the header files before you build the cross-compiler, because the build stage
  actually runs the cross-compiler to produce parts of libgcc.a.  (These are the parts
  that can be compiled with GNU CC.)  Some of them need suitable header files.
----------------------------- clip -------------------------------------------------- 

 As seen, no mention about 'sys-include'. But when one uses the '--with-headers=',
the standard C headers will be copied into the '$prefix/$target/sys-include' and
left there.

 More about this headers-mess, the 'sys-include' is carried with the name
CROSS_INCLUDE_DIR and the 'include' with the name TOOL_INCLUDE_DIR, and the GCC
manual says about these: 

----------------- clip -------------------------------------------------- 
  Standard Header File Directories

 <snip>

  CROSS_INCLUDE_DIR is used only for a cross compiler.  GNU CC doesn't install
  anything there.

  TOOL_INCLUDE_DIR is used for both native and cross compilers.  It is the place
  for other packages to install header files that GNU CC will use.  For a cross-
  compiler, this is the equivalent of /usr/include.  When you build a cross-compiler,
  fixincludes processes any header files in this directory.
----------------- clip -------------------------------------------------- 

 So nothing should be installed by GCC into the 'sys-include' while the 'include'
is "the equivalent of /usr/include" for a cross-compiler... And the words "For a
native compiler" seem to be missing before the words "It is the place for other
packages..." (meaning that a native compiler may have 3rd-party headers there).

 A cross-compiler cannot put both the standard C headers and the 3rd party headers
in the same directory, at least mixing all the headers into the same soup shouldn't
be recommended... Of course using those '-I' etc. options for gcc and cpp:

E:\usr\local\lib\gcc-lib\i486-linux-gnu\2_95.1>cpp --help
Usage: cpp [switches] input output
Switches:
  -include <file>           Include the contents of <file> before other files
  -imacros <file>           Accept definition of marcos in <file>
  -iprefix <path>           Specify <path> as a prefix for next two options
  -iwithprefix <dir>        Add <dir> to the end of the system include paths
  -iwithprefixbefore <dir>  Add <dir> to the end of the main include paths
  -isystem <dir>            Add <dir> to the start of the system include paths
  -idirafter <dir>          Add <dir> to the end of the system include paths
  -I <dir>                  Add <dir> to the end of the main include paths

may help, but someone may want to put the 3rd party ones into a nice package...

 And the words about fixincludes processing files in TOOL_INCLUDE_DIR aren't valid
any more (since 2.95.2? 2.96 ?), because it is now the CROSS_INCLUDE_DIR in GCC
Makefiles.

 My humble wish is that these things could be told a little more clearer in the
GCC documentation. But who has the courage to correct the RMS words... I'm quite
sure that after reading the previous description about the CROSS_INCLUDE_DIR
(the 'sys-include'), nobody can say what is the purpose for it with a cross-
compiler... My interpretation between the lines is that it was aimed for the 3rd
party headers for a cross-compiler, for the simple reason that where else they
could be put?

 I haven't mentioned the CrossGCC-FAQ, because the instructions should be as
clear as possible in the GCC docs first, when describing the generic case. The
FAQ could then elaborate some specific cases and the workarounds for them. Not
as it done now that the FAQ is taken as describing the generic case and the
workarounds there taken as generic instructions for building a cross-compiler.
 
Cheers, Kai


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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