0

I am trying to build a gcc cross/native toolchain for aarch64 (build=x86_64,host=aarch64,target=aarch64) and am getting stumped on libmpc (version 1.2.1). The build fails with the following error:

../libtool  --tag=CC   --mode=link aarch64-linux-gnu-gcc  -g -O2  -version-info 5:1:2 -L/home/chris/local/aarch64-linux-gnu/usr/lib -L/home/chris/local/aarch64-linux-gnu/usr/lib  -o libmpc.la -rpath /usr/lib abs.lo acos.lo acosh.lo add.lo add_fr.lo add_si.lo add_ui.lo arg.lo asin.lo asinh.lo atan.lo atanh.lo clear.lo cmp.lo cmp_abs.lo cmp_si_si.lo conj.lo cos.lo cosh.lo div_2si.lo div_2ui.lo div.lo div_fr.lo div_ui.lo dot.lo exp.lo fma.lo fr_div.lo fr_sub.lo get_prec2.lo get_prec.lo get_version.lo get_x.lo imag.lo init2.lo init3.lo inp_str.lo log.lo log10.lo mem.lo mul_2si.lo mul_2ui.lo mul.lo mul_fr.lo mul_i.lo mul_si.lo mul_ui.lo neg.lo norm.lo out_str.lo pow.lo pow_fr.lo pow_ld.lo pow_d.lo pow_si.lo pow_ui.lo pow_z.lo proj.lo real.lo rootofunity.lo urandom.lo set.lo set_prec.lo set_str.lo set_x.lo set_x_x.lo sin.lo sin_cos.lo sinh.lo sqr.lo sqrt.lo strtoc.lo sub.lo sub_fr.lo sub_ui.lo sum.lo swap.lo tan.lo tanh.lo uceil_log2.lo ui_div.lo ui_ui_sub.lo  -lmpfr -lgmp -lm
libtool: warning: library '/home/chris/local/aarch64-linux-gnu/usr/lib/libmpfr.la' was moved.
/bin/grep: /usr/lib/libgmp.la: No such file or directory
/bin/sed: can't read /usr/lib/libgmp.la: No such file or directory
libtool:   error: '/usr/lib/libgmp.la' is not a valid libtool archive

This is the problem. The file in question, libgmp.a, is NOT in "/usr/lib" right now. It is in the staging area for my cross/native chain "/home/chris/local/aarch64-linux-gnu/usr/lib/". I configured mpc using --with-mpfr=/home/chris/local/aarch64-linux-gnu/usr --with-gmp=/home/chris/local/aarch64-linux-gnu/usr so it would find the correct version of libmpfr.la libgmp.la (which it does), but the problem is the ../libtool script (from mpc-1.2.1) runs the command

    # Read the .la file
    func_source "$lib"

At or near line 8360 in the libtool shell script. The libmpfr.la file, which it reads in the func_source statement above, correctly states that it has a dependency on /usr/lib/libgmp.la (depedency_libs=' /usr/lib/libgmp.la'), because that is where it belongs on the aarch64 system. But it is NOT there on the x86_64 build platform where this compile is taking place. The compile then fails with the grep error above.

I have tried to read every resource I can on cross compiling. Unfortunately, while cross compilers are fairly well explained, how to do a "Canadian cross" for a native compiler using a foreign build platform has very limited information.

Can anyone give me instructions on how I am supposed to get around this problem? I need to build libmpc when the mpfr and gmp libraries are not in their correct runtime locations, and are not the same architecture as the build node. Ultimately, I need to build a cross/native gcc, but sadly I can't attempt that without an aarch64 build of libmpc.

Can I simply manually remove the dependency_libs statements in the mpfr.la and gmp.la files, or will that cause a bigger issue later on? Have I missed a step in the build process which is the root cause of this problem? Any help is appreciated.

Chris Z
  • 3
  • 3
  • The easiest route is `./contrib/download_prerequisites`, which will cause gcc to build and link a static version of gmp+mpfr+mpc. You could also remove the .la files, they are not necessary. – Marc Glisse Feb 09 '22 at 20:50
  • Did you try `--with-sysroot=`? – Marc Glisse Feb 09 '22 at 20:58
  • --with-sysroot had no effect on the problem. In order to get past this problem I manually edited the libmpfr.la file to remove the dependency line. The compile completed without incident after this. I am still not sure what was the correct resolution to this problem. If anyone knows definitively what I should have done or where I went wrong, please comment. – Chris Z Feb 10 '22 at 08:17

0 Answers0