How to detect GCC using CMakeFiles? (avogadrolibs dev ask this)

So I have been trying to build avogadrolibs.

But it encounter an error E: lto-no-text-in-archive which make the build failed.
The dev suggest that it might be openSUSE issue.

Which dev suggest that, quote,

There seems to be a similar openSUSE patch for a different package:

If there’s a way to detect your particular version of GCC, we can try to handle in our CMakeFiles.

What does this mean? What do I tell them?


Add the following to the beginning of %build;

%global _lto_cflags %{_lto_cflags} -ffat-lto-objects

I would surmise your building static libs as well…



I did that before, however the science repo maintainer won’t accept that as a fix., did you mean that I should put devel-static into devel package?

Is the static library needed? If not, use cmake to disable the static build. If you do need the static lib then upstream will need to tweak the code for the lto flag…

The static lib is needed for the software to work properly. I will tell them that they need to add the flag.


AFAIK it may also need code tweaks…

The dev are asking this, I don’t know the answer…

I’m okay with that - but presumably that’s needed for particular versions of GCC?

This seems very distro specific, it would be great to get some explanation, along with why I can’t reproduce it here using a very recent GCC - are you adding other compiler flags we aren’t using by default?

Show the dev the log file as will see all the flags passed;


   57s] -- Performing Test HAS_FLTO
   57s] -- Performing Test HAS_FLTO - Success
   57s] -- LTO enabled

AFAIK it all has to do with reproducible builds.


Update on the situation, the dev could not figured out how or why they should change their cmake file.
Quote from Avogadro dev:

I spent some time looking into this, but IMHO, the package maintainer is wrong. As you said, the openSUSE docs recommend exactly that:
the easiest to achieve this is by adding, somewhere near the top of the .spec file:

%global _lto_cflags %{?_lto_cflags} -ffat-lto-objects

If the package maintainer has another solution, patch, I’m happy to consider it. But I can’t find any way to detect that the compiler is using LTO, so I don’t see how our cmake files should change.
I just merged patches from Fedora and other downstream maintainers - and would be happy to merge any changes the openSUSE maintainer suggests.

Any suggestion on this? Thanks.