From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kai Ruottu To: egcs@cygnus.com Cc: crossgcc@sourceware.cygnus.com Subject: Re: Trying to build a cross compiler from linux to netbsd... Date: Thu, 04 Jan 2001 02:55:00 -0000 Message-id: <3A54564E.B1B84D7B@luukku.com> References: <3A5293AF.CC95CA6E@csworks.com> <3A53085C.4C2F192@luukku.com> <3A53A68E.AE42C58B@luukku.com> X-SW-Source: 2001-01/msg00020.html Alexandre Oliva wrote: > > On Jan 3, 2001, Kai Ruottu 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 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 Include the contents of before other files -imacros Accept definition of marcos in -iprefix Specify as a prefix for next two options -iwithprefix Add to the end of the system include paths -iwithprefixbefore Add to the end of the main include paths -isystem Add to the start of the system include paths -idirafter Add to the end of the system include paths -I Add 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kai Ruottu To: egcs@cygnus.com Cc: crossgcc@sourceware.cygnus.com Subject: Re: Trying to build a cross compiler from linux to netbsd... Date: Sun, 01 Apr 2001 00:00:00 -0000 Message-ID: <3A54564E.B1B84D7B@luukku.com> References: <3A5293AF.CC95CA6E@csworks.com> <3A53085C.4C2F192@luukku.com> <3A53A68E.AE42C58B@luukku.com> X-SW-Source: 2001-q1/msg00020.html Message-ID: <20010401000000.c4YKKiH2VaowqxzahjrmOFSz2UHNJO9ON8sE59_9gds@z> Alexandre Oliva wrote: > > On Jan 3, 2001, Kai Ruottu 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 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 Include the contents of before other files -imacros Accept definition of marcos in -iprefix Specify as a prefix for next two options -iwithprefix Add to the end of the system include paths -iwithprefixbefore Add to the end of the main include paths -isystem Add to the start of the system include paths -idirafter Add to the end of the system include paths -I Add 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