Unfortunately after few tries of cross compiling eglibc using different source for instructions I alway end with hard to solve issues. Luckily, in the sources of eglibc I noticed instructions for cross-compiling written long time ago by Jim Blandy(I know i should start here). Lot of thanks to him for it. Below I describe my experience which I gained during eglibc cross compilation for arm-unknown-linux-gnueabi and procedure that I used. Commands below contain some constants that I used in previous works. See this post. Eglibc library and the compiler itself is built with many various parameters this post is not the place to explain their meaning, please RTFM.

  1. Checkout eglibc from svn (as alwyas I try to use a latest sources possible). Version used r17815:

  1. Link working ports to GNU/Linux on some machine architectures. They are not maintained in the official glibc source tree so we need to add it in this way:

  1. Create eglibc-headers directory:

  1. Configure eglibc and preliminary objects:

  1. Install eglibc headers:

  1. We need few object file to link shared libraries, which will be built and installed by hand:

  1. To produce libgcc_s.so we need libc.so, but only need its dummy version because we’ll never use it. It doesn’t matter what we will point as a libc.so we use /dev/null as C file.

  1. Get latest gcc sources using git repository mirror. Latest commit while writing this post was 5b9a8c3:

  1. Now, we can build gcc which can compile eglibc.

  1. Confugure and compile final version of eglibc.

  1. Install libelf library

  1. Prepare final version of gcc.

  1. Few libraries should be copied manualy

  1. Compile and install chrpath – this is useful tool to remove the rpath or runpath setting from binary.

  1. Strip debug symbols

  1. At the end simple test to find out if basic functionality works:

Try to cross compile C file:

$TARGET/arm-x-tools/bin/arm-unknown-linux-gnueabi-g++ -Wall c++-hello.cc -o c++-hello

$TARGET/arm-x-tools/bin/arm-unknown-linux-gnueabi-readelf -hl hello $TARGET/arm-x-tools/bin/arm-unknown-linux-gnueabi-readelf -hl c++-hello

ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2’s complement, little endian Version: 1 (current) OS/ABI: UNIX – System V ABI Version: 0 Type: EXEC (Executable file) Machine: ARM (…) Flags: 0x5000002, has entry point, Version5 EABI (…) Program Headers: (…) INTERP 0x000134 0x00008134 0x00008134 0x00013 0x00013 R 0x1 [Requesting program interpreter: /lib/ld-linux.so.3] LOAD 0x000000 0x00008000 0x00008000 0x004b8 0x004b8 R E 0x8000 (…) `

Result should look like that:

I hope you find above manual useful. If you need more detailed descriptions it can be found here. Also don’t bother to ask me by comment below.