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: still can't build cross compiler --target=i686-pc-linux-gnu on so laris


David:


Ooh, ooh, ooh!!!  :^)

> $ cd /home/davidt/gnu/bin-a4/bin
> $ ./i686-pc-linux-gnu-gcc ~/tmp/x.c
> /home/davidt/gnu/bin-a4/i686-pc-linux-gnu/bin/ld: cannot find /lib/libc.so.6
> collect2: ld returned 1 exit status

Look for a file in your cross library directory called libc.so, it
will have a GROUPS statement in it that tells the linker the full path
to libc.  Take the path part out completely, and make sure that the
version number included there (libc.so.6, libc.so.6.1, etc.) matches
with what you actually have in your cross libraries.  Libc.so is a
miniature linker command file.  Add the -v option to gcc to see more
of what's going on.

You may also need to diddle with the --dynamic-linker option (or a
related option, the name of which escapes me at the moment) for
gcc/ld, to make sure that the cross application has the right path to
*its* dynamic linker, instead of the one installed with the cross
tools, the path to which is affected by the --prefix option during
configration.  If you aren't careful, you end up with the target
system looking in /usr/local/my_tools_foo/bin for the dynamic linker,
instead of /lib.  Objdump is definitely your friend here...


> Here is my last script that successfully builds a cross-compiler,

I notice that you omit mention of a runtime library (i.e. glibc)
altogether.  Depending on what kind of application you are building,
you may need that--- or at least header files for it.

Also, the --with-headers= option is kinda dangerous (I think).  Better
to build a "bootstrap" c compiler first, build libs and header files,
then build the complete compiler.

There's a build script at http://crossgcc.billgatliff.com that shows
how to do this for a few targets, and a few hosts (linux and cygwin,
although it has limited solaris2.8+sunfreeware testing).  I'm running
it on my solaris box right now, and haven't made much progress yet.

But it's a Sparcstation 10, so I'm not going *anywhere* fast...
Anyone got a faster solaris2.8 box I could borrow?

Here's the error I'm getting, during building of glibc-2.2.4:


i386-linux-gcc version.c -c -O2 -Wall -Winline -Wstrict-prototypes -Wwrite-strings -g      -I../include -I. -I/export/home/bgat/sun1/build-glibc/csu -I.. -I../libio  -I/export/home/bgat/sun1/build-glibc -I../sysdeps/i386/elf -I../sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv/i386 -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/fpu -I../sysdeps/i386 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic  -nostdinc -isystem /export/home/bgat/H-sparc-sun-solaris2.8/lib/gcc-lib/i386-linux/2.95.3/include -isystem /export/home/bgat/H-sparc-sun-solaris2.8/i386-linux/include  -include ../include/libc-symbols.h     -DHAVE_INITFINI -o /export/home/bgat/sun1/build-glibc/csu/version.o
In file included from version.c:32:
/export/home/bgat/sun1/build-glibc/csu/version-info.h:5: parse error before `GNU'
/export/home/bgat/sun1/build-glibc/csu/version-info.h:7: malformed floating constant
make[2]: *** [/export/home/bgat/sun1/build-glibc/csu/version.o] Error 1
make[2]: Leaving directory `/export/home/bgat/sun1/glibc-2.2.4/csu'
make[1]: *** [csu/subdir_lib] Error 2
make[1]: Leaving directory `/export/home/bgat/sun1/glibc-2.2.4'
make: *** [all] Error 2


I haven't looked into exactly what version-info.h does, or how it is
generated.  I'm doing this in breaks between my "real" job...

The following is the procedure I'm using.  Note that I'm using a
native gcc from sunfreeware.com, which is installed in /usr/local/bin,
along with GNU make et al.  I therefore have to put /usr/local/bin in
the path first, otherwise the configure scripts get the wrong tools.


$ export TARGET=i386-pc-linux PREFIX=<path-to-somewhere>
$ export PATH=/usr/local/bin:$PATH:${PREFIX}/bin
$ mkdir build-binutils && cd build-binutils
$ ../binutils-2.11.2/configure --target=$TARGET --prefix=$PREFIX
$ make all install
$ cd ..

$ mkdir build-core-gcc && cd build-core-gcc
$ ../gcc-2.95.3/configure --target=$TARGET --prefix=$PREFIX \
    --enable-languages=c --with-local-prefix=${PREFIX}/${TARGET} \
    --without-headers --with-newlib --disable-shared
$ make all-gcc install-gcc
$ cd ..

$ cd linux
$ make ARCH=i386 CROSS_COMIPLE=i386-linux- CONFIG_SHELL=bash oldconfig
$ cp -r include/linux ${PREFIX}/${TARGET}/include/linux
$ cp -r include/asm-i386 ${PREFIX}/${TARGET}/include/asm


$ mkdir build-glibc && cd build-glibc
$ CC=${TARGET}-gcc AR=${TARGET}-ar RANLIB=${TARGET}-ranlib bash \
    ../glibc-2.2.4/configure --host=$TARGET --prefix=${PREFIX}/${TARGET} \
    --with-headers=${PREFIX}/${TARGET}/include --disable-sanity-checks
$ make

... and that's as far as I've gotten.  In other words, I have a
working bootstrap compiler, but I can't seem to get glibc built.


Suggestions anyone?


> 1) How *exactly* should I build $linuxinc_targz and $linuxlib_targz?

Does my script help answer this?

> 2) Please explain if I need /lib or /usr/lib or both.
>    A) What files *exactly* do I need?
>       a) How could I have learned this myself?
>    B) What files *exactly* do I NOT need?
>       a) How could I have learned this myself?

First off, realize that the *only* reason the cross compiler needs
kernel header files is because the runtime library needs them to set
up system calls in its own header files.  Other than that, think of
the kernel headers as simply library header files.

You shouldn't need /lib or /usr/lib from your solaris box, because
those are libraries for the solaris OS, and don't apply at all to your
Linux target.

How could you have learned this?  Well, sometimes it's hard to keep
track of what's "native" and what's "cross" in the GNU world, because
everything is so cross-platform.  But there's no magic here, over time
you get comfortable with the notions.

Stop working as the root user, if you are.  I've found that working as
root makes it less obvious where target-specific libs, etc. are
getting written to, which obscures things sometimes.

> 3) How do I tell configure/make where these library files are?
>    A) Should I use --with-libs or not?
>       a) How do I tell configure/make about my target's /lib files?
>       b) How do I tell configure/make about my target's /usr/lib files?

Dunno, and dunno if you have to.  My procedure is to always build the
libs myself, using the same PREFIX as the compiler, so the compiler
"knows" where to find them.

> 4) Why does building a cross-compiler make me feel so dumb?

Can't answer that one.  But it makes me feel kinda dumb sometimes, too!


b.g.
-- 
Bill Gatliff
bgat@billgatliff.com

------
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]