public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Building cross / multilib gcc question
@ 2012-10-27 12:57 Steve Ellcey 
  0 siblings, 0 replies; only message in thread
From: Steve Ellcey  @ 2012-10-27 12:57 UTC (permalink / raw)
  To: gcc-help

I have a question about GCC, sysroot, and MULTILIBS.  I noticed an odd thing
when building a GCC cross compiler that uses sysroot and multilibs.

I am building the target mips-mti-linux-gnu and specifying a sysroot
option of /sysroot-mips-mti-linux-gnu.  The sysroot directory is not
in the gcc install directory and it contains a set of header files
in /usr/include and multiple libc.so files in different directories
for different versions of MIPS.  I am also building GCC for MULTILIBS,
I have:

MULTILIB_OPTIONS = mips32/mips64/mips64r2 mabi=64 EL msoft-float
MULTILIB_DIRNAMES = mips32 mips64 mips64r2 64 el sof

What I noticed is that MULTILIB_DIRNAMES is (sort of) getting appended to
the sysroot based on the options used when compiling:

mips-mti-linux-gnu-gcc -print-sysroot
/sysroot-mips-mti-linux-gnu
mips-mti-linux-gnu-gcc -print-sysroot -mips32
/sysroot-mips-mti-linux-gnu/mips32
mips-mti-linux-gnu-gcc -print-sysroot -mips32 -el -msoft-float
/sysroot-mips-mti-linux-gnu/mips32/sof
mips-mti-linux-gnu-gcc -print-sysroot -mips64r2 -el -msoft-float
/sysroot-mips-mti-linux-gnu/mips64r2/sof

This surprises me because while the different sysroots are OK for looking
for libraries, it isn't really true when looking for header files.  In my
case all the header files are in /sysroot-mips-mti-linux-gnu/usr/include
and not under any /el or /sof directories.  But this part of the compiler
still seems to work, it is finding header files and it is finding the right
libc.so (even though I don't set SYSROOT_SUFFIX_SPEC).

But my first question is, is this expected?  I would have thought that 
-print-sysroot should always print the same path and that SYSROOT_SUFFIX_SPEC
should be used to append the mips32, el, sof parts of the path to search
for libc, etc.

The current setup means that when looking for libc, I do not want to set
SYSROOT_SUFFIX_SPEC because the suffix I want added (mips32, el, etc) is
already added to the sysroot variable and it looks for usr/lib under one
of these directories depending on compiler options and finds usr/lib/libc.so.
That seems fine for libraries but it is not working for start files (crt*).

When I look for crti.o it does not seem to be using the same mechanism.
If I don't set STARTFILE_PREFIX_SPEC or set it to '/usr/lib/' then it always
looks in /sysroot-mips-mti-linux-gnu/usr/lib for the crt files and doesn't
insert the directories that got used when looking for the libraries.

I am trying to work with STARTFILE_PREFIX_SPEC to set this based on options
but it is difficult because this doesn't seem to use quite the same syntax
as other SPEC settings and it isn't documented in tm.texi.

So my second question is: should GCC already be using the 'modified' sysroot
that it uses for searching for libraries to search for crt files?  That seems
like the 'right' thing to do.  I have started digging around gcc.c but if
anyone has ideas or help on this area or a 'best practices' setup for building
a cross/multilib gcc compiler with glibc I would be interested in hearing
those ideas.

Steve Ellcey
sellcey@mips.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-10-26 22:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-27 12:57 Building cross / multilib gcc question Steve Ellcey 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).