1

I built a native compiler for aarch64. The built was successful. I'm having problems though, specifying the glibc (libc.so) library to link against. I followed the suggestion in this link, about compiling with multiple glibc, but is not working.

The environment:

  • ARM 64bit machine.

  • A toolchain in toolchain_dir/bin/aarch64-linux-g++.

  • A sysroot directory in toolchain/sysroot/lib, which contains the lib.so.6 (glibc 2.25) and libstdc++.so (6.0.22) libraries and also the ld-linux-aarch64.so.1 linker.

  • The /lib64 directory contains the libc.so.6 (glibc 2.17) and libstdc++.so (6.0.19), old versions.

What I tried:

  1. I tried to compile a simple program as:

    $aarch-64-linux-g++ file.cpp -o out \
      -L/home/user/toolchain/sysroot/lib -lc -lstdc++ \
      -Wl,--rpath=/home/user/toolchain/sysroot/lib \ 
      -Wl,--dynamic-link=/home/user/toolchain/sysroot/lib/ld-linux-aarch64.so.1
    

    But I'm getting the error "/lib64/libstdc++.so.6: version GLIBCXX_3.4.20 not found". The error discloses that the rpath is not working, as is still looking into /lib64 library, instead of toolchain/sysroot/lib which contains the GLIBCXX_3.4.20 (libstdc++.so.6).

  2. Next, I moved the toolchain/sysroot/lib/libstdc++.so.6 to /lib64, and compile again with the same command above, now getting the error: "/lib64/libstdc++.so.6 version GLIBC_2.18 not defined". The error shows the new built libstdc++.so.6 trying to find the new built glibc-2.25, but is failing as is searching in the wrong directory path in /lib64.

  3. Next, I set the LD_LIBRARY_PATH=/home/user/toolchain/sysroot/lib. But right after setting this variable I get segmentation faults.

Do you have ideas why this is happening? How could I solve this issue? Thanks!

Edit: Below more information from compiler, for g++ -v removed part of the output as is really long:

 $aarch64-unknown-linux-gnueabi-g++ -v
 Target: aarch64-unknown-linux-gnueabi
 Configured with: --build=x86_64-build_pc-linux-gnu --host=aarch64-host_unknown-linux-gnueabi --target=aarch64-unknown-linux-gnueabi --enable-gold --disable-nls --disable-multilib --with-local-prefix=/home/common/userX/x-tools/HOST-aarch64-unknown-linux-gnueabi/aarch64-unknown-linux-gnueabi/aarch64-unknown-linux-gnueabi/sysroot --enable-long-long
 gcc version 6.3.1 20170109 (crosstool-NG crosstool-ng-1.23.0)

 $file aarch64-unknown-linux-gnueabi-g++
 ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 4.10.8, stripped
AdvSphere
  • 986
  • 7
  • 15

0 Answers0