0

I am trying to use LTO in my code base. I used -flto flag during compile and link time both. It created fat objects but the binary generated after linking remained same as was without using LTO (No difference is size or performance).

Then I decided to use fno-fat-lto-objects flag, so that only LTO compatible object file is generated. But during compilation it threw error :

cc1plus: error: -fno-fat-lto-objects are supported only with linker plugin

I think I am not able to use LTO at link time and hence no difference in binaries.

Can anyone help in overcoming the above error?

  • What command line, options and compiler path are you using to compile? Try adding `-fuse-linker-plugin` or maybe `-Wl,-fuse-ld=gold`/ – KamilCuk Oct 24 '18 at 07:40
  • I am using GCC 5.4.0. Also, I am using -O2 -flto -fno-fat-lto-objects , along with some other flags for compilation. Trying `-fuse-linker-plugin` didn't worked. – Anmol Kumar Oct 24 '18 at 07:44
  • "Try adding -fuse-linker-plugin or maybe -Wl,-fuse-ld=gold" , for Linker flags or compiler flags? – Anmol Kumar Oct 24 '18 at 07:47
  • Is there any specific linker that can use LTO? – Anmol Kumar Oct 24 '18 at 07:54
  • Well, then read about LTO and read documentation. Yes, you need to use linker which supports LTO, I think GOLD linker, i'm not sure if I remember correctly. `-Wl` specifies linker flags and is ignored for compilation stage. Do you call linker directly not allowing gcc to call it? I think you should use those flags everywhere and see if it works. And you still haven't posted the command line which you use to compile and/or link your sources, which makes helping you impossible. – KamilCuk Oct 24 '18 at 09:15

0 Answers0