Is there a way to detect if the code is compiled with -flto?
Example: classic library or Linux executable compiled with GCC (4.9.1), no debugging.
Given that LTO information is stored in multiple ELF sections inside object files (see sections of the LTO file ), you can try and see what it readelf
returns (as used in, for example, this answer ).
Find records .gnu.lto_.xxx