On 2/22/23 09:28, Florian Weimer via Gcc wrote: > * Richard Biener: > >> On Wed, Feb 22, 2023 at 9:19 AM Florian Weimer via Gcc wrote: >>> >>> Can we use the COMMON symbol __gnu_lto_slim to detect >>> -fno-fat-lto-objects on contemporary GNU/Linux (with the LTO linker >>> plugin)? >> >> Yes. > > Great, thanks. > >>> We currently build the distribution with -ffat-lto-objects, and I want >>> to switch away from that. Packages will need to opt in to >>> -ffat-lto-objects if static objects they build escape the buildroot. Hello. We use the same approach where only a selected packages enable FAT lto objects. You can take a look at our META bug where such packages are linked (in most cases): https://bugzilla.opensuse.org/show_bug.cgi?id=1133084 Or one can easily grep it from here: https://github.com/bmwiedemann/openSUSE $ git grep 'fat-lto-objects' (see attachment) >>> And to make sure that this opt-in happens, I want to fail the build if >>> there would be any -fno-fat-lto-objects objects leaking. >> >> For SUSE we're checking that no LTO bytecode leaks instead, thus we check >> for __gnu_lto_v? (I think). The reason is that even for static libraries >> we do not want to ship LTO bytecode. > > We build with -ffat-lto-objects, and this means we can create perfectly > fine object files by stripping the LTO data: > > We strip this way: https://github.com/openSUSE/brp-check-suse/blob/2f7add6f0b7f5c2e9698d180a4761a10fb808482/brp-15-strip-debug#L38 > > This means that so far, we only had to fix LTO compilation problems in > the packages, but not teach individual packages about LTO and non-LTO > object files. Of course it's wasteful because few packages actually > install the object files (without a final link into a program or shared > object), and that's what I want to fix. And we integrated a rpmlint check that checks we don't ship a LTO bytecode: https://github.com/rpm-software-management/rpmlint/blob/aa1f710c1b3ff409e42068c2b067ab2eee200b1d/rpmlint/checks/BinariesCheck.py#L277-L283 and there's one related check where we look if a static library contains something: https://github.com/rpm-software-management/rpmlint/blob/aa1f710c1b3ff409e42068c2b067ab2eee200b1d/rpmlint/checks/BinariesCheck.py#L230-L255 it can happen that it only contained bytecode that was eventually striped. Cheers, Martin > > Florian >