Re: cmake: get rid of -fno-fat-lto-objects
Hi Timo, thanks a lot for the hint. Cheers, Jerome On 16/03/2022 23:21, Timo Röhling wrote: Hi Jerome, * Jerome BENOIT [2022-03-16 22:37]: Hello, One of my package builds with cmake. All is fine except that the built static library gets the no-code-sections error complaint from lintian. It appears [1,2] that /usr/share/cmake-3.22/Modules/Compiler/GNU.cmake enforces -fno-fat-lto-objects unconditionally for GCC + IPO What is the easiest way to revert the -fno-fat-lto-objects flags ? I recommend you explicitly disable LTO for the static library with: set_target_properties(staticlib PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF) LTO does not really achieve anything for static libraries: They are merely an archive of object files, so the linker is never invoked on them. You might think that LTO is useful when the static library is linked with an executable eventually. Alas, the LTO intermediate code is very compiler-specific, so it will not work with a different compiler and most likely not even with a different version of the same compiler. Alternatively, you could add a snippet such as if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") target_compile_options(staticlib PRIVATE -ffat-lto-objects) endif() This will work because the target-specific compile options happen to end up after the LTO compile options on the command line right now. However, dh_strip will remove the intermediate code anyway, for the reasons outlined above. Cheers Timo -- Jerome BENOIT | calculus+at-rezozer^dot*net https://qa.debian.org/developer.php?login=calcu...@rezozer.net AE28 AE15 710D FF1D 87E5 A762 3F92 19A6 7F36 C68B OpenPGP_signature Description: OpenPGP digital signature
Re: cmake: get rid of -fno-fat-lto-objects
Hi Jerome, * Jerome BENOIT [2022-03-16 22:37]: Hello, One of my package builds with cmake. All is fine except that the built static library gets the no-code-sections error complaint from lintian. It appears [1,2] that /usr/share/cmake-3.22/Modules/Compiler/GNU.cmake enforces -fno-fat-lto-objects unconditionally for GCC + IPO What is the easiest way to revert the -fno-fat-lto-objects flags ? I recommend you explicitly disable LTO for the static library with: set_target_properties(staticlib PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF) LTO does not really achieve anything for static libraries: They are merely an archive of object files, so the linker is never invoked on them. You might think that LTO is useful when the static library is linked with an executable eventually. Alas, the LTO intermediate code is very compiler-specific, so it will not work with a different compiler and most likely not even with a different version of the same compiler. Alternatively, you could add a snippet such as if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") target_compile_options(staticlib PRIVATE -ffat-lto-objects) endif() This will work because the target-specific compile options happen to end up after the LTO compile options on the command line right now. However, dh_strip will remove the intermediate code anyway, for the reasons outlined above. Cheers Timo -- ⢀⣴⠾⠻⢶⣦⠀ ╭╮ ⣾⠁⢠⠒⠀⣿⡁ │ Timo Röhling │ ⢿⡄⠘⠷⠚⠋⠀ │ 9B03 EBB9 8300 DF97 C2B1 23BF CC8C 6BDD 1403 F4CA │ ⠈⠳⣄ ╰╯ signature.asc Description: PGP signature
cmake: get rid of -fno-fat-lto-objects
Hello, One of my package builds with cmake. All is fine except that the built static library gets the no-code-sections error complaint from lintian. It appears [1,2] that /usr/share/cmake-3.22/Modules/Compiler/GNU.cmake enforces -fno-fat-lto-objects unconditionally for GCC + IPO What is the easiest way to revert the -fno-fat-lto-objects flags ? Thanks in advance, Jerome [1] https://gitlab.kitware.com/cmake/cmake/-/issues/21696 [2] https://stackoverflow.com/questions/70806677/why-does-cmake-set-no-fat-lto-objects-when-i-enable-lto-ipo -- Jerome BENOIT | calculus+at-rezozer^dot*net https://qa.debian.org/developer.php?login=calcu...@rezozer.net AE28 AE15 710D FF1D 87E5 A762 3F92 19A6 7F36 C68B OpenPGP_signature Description: OpenPGP digital signature