The current LTO functionality implementation has multiple issues:
- Duplicated
-fltoflags when linking. - The
secp256k1subtree code is built without LTO. - In
AX_CHECK_LINK_FLAGmacro the wrongCXXFLAG_WERRORflag is used instead of the correctLDFLAG_WERRORone.
This PR fixes all of them.
Might be verified as follows:
$ readelf -S src/secp256k1/src/libsecp256k1_la-secp256k1.o | grep .gnu.lto_ | wc -l
274
The depends build system has similar issues that will be addressed in a separated PR.
Noticed while porting this functionality to a new CMake-based build system.