Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

autoconf recipe to use gcc-ar and gcc-ranlib

I'm using link-time optimisation (LTO) in a project that compiles under both GCC and Clang and builds a static library. It's working with GCC 4.8, but GCC 5.4 makes thin LTO objects and when automake tries to build the static library with ar it fails, because it needs the wrapper script gcc-ar.

Is there a good example I can look at for how to make automake use gcc-ar instead of ar (and similarly for gcc-ranlib)? I can probably hack something in, but ideally it should:

  • Use the appropriate tools for the compiler (Clang has its own instructions).
  • Work even if the user overrides the compiler to one that isn't the system default.
  • Work when cross compiling
like image 990
Bruce Merry Avatar asked Oct 30 '22 17:10

Bruce Merry


1 Answers

You can override the default tools used by calling

./configure AR=gcc-ar RANLIB=gcc-ranlib

I'm afraid for ./configure to pick them up by default, autoconf/automake will have to be fixed to know about those in the default set of checks.

like image 53
Diego Elio Pettenò Avatar answered Nov 11 '22 17:11

Diego Elio Pettenò