Building a Cross GCC Against a Prebuilt Target Glibc

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

 



Hello,

I'm attempting to cross compile the GNU toolchain and for the sake of
simplicity, I'm targeting my current machine just with a different vendor
(so x86_64-kyle-linux-gnu instead of x86_64-pc-inux-gnu). I'll perform the
actual cross compilation once I can get this process down.

Now I've successfully built a freestanding GCC with the sole purpose of
compiling glibc for my target and I've gotten all of this completed
successfully. I can create C programs and compile and link them for my
target and its glibc. I've verified that they are correctly linking to my
new glibc using readelf.

I'm now trying to build a hosted GCC using the glibc that was just built
but no matter what I try, I can't seem to get xgcc to find my new libc.so.
For reference, here is my configuration:

../gcc-7.2.0/configure --build=$LINUX_BUILD\
                       --host=$LINUX_HOST\
                       --target=$LINUX_TARGET\
                       --prefix=$LINUX_TOOLS\
                       --with-local-prefix=$LINUX_TOOLS\
                       --with-sysroot=$LINUX_CROSS\
                       --with-build-sysroot=$LINUX_CROSS\
                       --enable-languages=c,c++\
                       --with-native-system-header-dir=/include\
                       --disable-multilib

I intend to install this new compiler in $LINUX_TOOLS on the host machine
hence the --prefix flag and I added the --with-sysroot and
--with-build-sysroot flags so that the compiler can find the correct
headers and libraries for the target.

After some time compiling, it reaches the point when it tries to create
libgcc_s.so and errors out with the following:

************************************************************************************
/mnt/linux/builds/build/./gcc/xgcc -B/mnt/linux/builds/build/./gcc/
-B/mnt/linux/cross/x86_64-kyle-linux-gnu/bin/
-B/mnt/linux/cross/x86_64-kyle-linux-gnu/lib/ -isystem
/mnt/linux/cross/x86_64-kyle-linux-gnu/include -isystem
/mnt/linux/cross/x86_64-kyle-linux-gnu/sys-include
--sysroot=/mnt/linux/cross
...
... (many many object files)
...
 unwind-c_s.o emutls_s.o libgcc.a -lc && rm -f ./libgcc_s.so && if [ -f
./libgcc_s.so.1 ]; then mv -f ./libgcc_s.so.1 ./libgcc_s.so.1.backup; else
true; fi && mv ./libgcc_s.so.1.tmp ./libgcc_s.so.1 && (echo "/* GNU ld
script"; echo "   Use the shared library, but some functions are only in";
echo "   the static library.  */"; echo "GROUP ( libgcc_s.so.1 -lgcc )" ) >
./libgcc_s.so
/mnt/linux/cross/x86_64-kyle-linux-gnu/bin/ld: cannot find
/mnt/linux/cross/lib/libc.so.6 inside /mnt/linux/cross
/mnt/linux/cross/x86_64-kyle-linux-gnu/bin/ld: cannot find
/mnt/linux/cross/lib/libc_nonshared.a inside /mnt/linux/cross
/mnt/linux/cross/x86_64-kyle-linux-gnu/bin/ld: cannot find
/mnt/linux/cross/lib/ld-linux-x86-64.so.2 inside /mnt/linux/cross
************************************************************************************

I've tried numerous solutions to this problem including different
configurations, setting LD_LIBRARY_PATH and changing the default specs by
editing the source to point directly to
/mnt/linux/cross/lib/ld-linux-x86-64.so.

Curiously, when I change the default specs to point to the correct linker
and library directory, a test compilation using xgcc of a small "int main()
{}" program instead complains about not finding the crt start files. These
files are clearly present in the same directory ld-linux-x86-64.so is in
but ld fails to find them as well.

To make things even stranger, an strace on that test compilation using xgcc
shows that the crt0.o, crt1.o, crti.o files are actually found (the access
system call returns 0) but ld still complains it can't find them anyway.

So how should I go about building this hosted cross compiler using the
glibc library present in /mnt/linux/cross/lib? Am I fundamentally
misunderstanding some build requirement or something? From what I can tell,
libgcc should have everything it needs to build but it's simply not finding
the libraries.



[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