[cooker] LTO and static libraries

Hi,

looks like static libraries that are build with LTO causes errors when
something else is linking to that static libraries. See here

Currently optflags passes -flto to LLVM/clang which means clang emits Fat
LTO symbols so ar should handle it. According to this
b_lto=true does not work with static libraries · Issue #1646 · mesonbuild/meson · GitHub it seems like binutils's ar
is broken and does not handle LTO.

There are three options:
- ar wrapper script does not work well, so it still uses ar from binutils
instead of llvm-ar or gcc-ar

- autofoo scripts from build package prefers/hardcodes usage of ar from
binutils

- issue is outdated because ar wrapper got fixed (

)

Hi,

looks like static libraries that are build with LTO causes errors when something else is linking to that static libraries. See here Disable LTO for static libraries · OpenMandrivaAssociation/util-linux@85926d8 · GitHub

Currently optflags passes -flto to LLVM/clang which means clang emits Fat LTO symbols so ar should handle it. According to this b_lto=true does not work with static libraries · Issue #1646 · mesonbuild/meson · GitHub it seems like binutils's ar is broken and does not handle LTO.

There are three options:
- ar wrapper script does not work well, so it still uses ar from binutils instead of llvm-ar or gcc-ar

- autofoo scripts from build package prefers/hardcodes usage of ar from binutils

Don't know this one. If true that need fixing.

- issue is outdated because ar wrapper got fixed (Add crazy's wrapper script fixes · OpenMandrivaAssociation/binutils@70e0b69 · GitHub)

The real issue is:

Mixed static-libs won't work. Eg: lib1 build with GCC LTO and lib2
build with Clang LTO.
In this case, one has to be built without LTO to be able to link without errors.

I didn't test the latest Clang static LTO libs but I doubt something
changed there.