When compiling a package that does not add CFLAGS when it's linking, and LTO is enabled portage generates a QA warning about the package not respecting CFLAGS. (see attached build log, one can clearly see CFLAGS are passed to compilation calls, and not linking calls, the QA warning is generated at the end). It seems likely that LTO is stripping out the CFLAGS information from the generated binaries.
Created attachment 890543 [details] build.log for sys-apps/iproute2-6.8.0 showing the issue happening
Please provide emerge --info so we know what version of gcc/binutils was being used.
$ emerge --info sys-apps/iproute2 Portage 3.0.63 (python 3.12.3-final-0, default/linux/amd64/23.0/split-usr/no-multilib/hardened, gcc-13, glibc-2.39-r2, 6.8.5 x86_64) 10:28:58 [11/25151] ================================================================= System Settings ================================================================= System uname: Linux-6.8.5-x86_64-AMD_Ryzen_7_7840U_w-_Radeon_780M_Graphics-with-glibc2.39 KiB Mem: 65012660 total, 59084612 free KiB Swap: 0 total, 0 free Timestamp of repository gentoo: Fri, 12 Apr 2024 00:00:00 +0000 Head commit of repository gentoo: be4b3c29ed773ebdf3c08836d06f3a416384586e sh bash 5.2_p26 ld GNU ld (Gentoo 2.42 p3) 2.42.0 app-misc/pax-utils: 1.3.7::gentoo app-shells/bash: 5.2_p26::gentoo dev-build/autoconf: 2.13-r8::gentoo, 2.72-r1::gentoo dev-build/automake: 1.16.5-r2::gentoo dev-build/cmake: 3.29.1::gentoo dev-build/libtool: 2.4.7-r4::gentoo dev-build/make: 4.4.1-r1::gentoo dev-build/meson: 1.4.0-r1::gentoo dev-lang/perl: 5.38.2-r2::gentoo dev-lang/python: 3.10.14_p1::gentoo, 3.11.9::gentoo, 3.12.3::gentoo dev-lang/rust: 1.77.1::gentoo sys-apps/baselayout: 2.15::gentoo sys-apps/openrc: 0.54::gentoo sys-apps/sandbox: 2.38::gentoo sys-devel/binutils: 2.42-r1::gentoo sys-devel/binutils-config: 5.5::gentoo sys-devel/clang: 17.0.6::gentoo, 18.1.3::gentoo sys-devel/gcc: 13.2.1_p20240210::gentoo sys-devel/gcc-config: 2.11::gentoo sys-devel/lld: 17.0.6::gentoo, 18.1.3::gentoo sys-devel/llvm: 17.0.6::gentoo, 18.1.3::gentoo sys-kernel/linux-headers: 6.8-r1::gentoo (virtual/os-headers) sys-libs/glibc: 2.39-r2::gentoo Repositories: gentoo location: /var/db/repos/gentoo sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 volatile: False sync-rsync-verify-jobs: 1 sync-rsync-extra-opts: sync-rsync-verify-max-age: 24 sync-rsync-verify-metamanifest: yes gentoo-local location: /var/db/repos/gentoo-local masters: gentoo volatile: False ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="*" CBUILD="x86_64-pc-linux-gnu" CC="x86_64-pc-linux-gnu-gcc" CFLAGS="-O2 -march=znver4 -frecord-gcc-switches -fcf-protection -flto=auto -pipe" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo" CXX="x86_64-pc-linux-gnu-g++" CXXFLAGS="-O2 -march=znver4 -frecord-gcc-switches -fcf-protection -flto=auto -pipe" DISTDIR="/var/cache/distfiles" ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME" FCFLAGS="-O2 -march=znver4 -frecord-gcc-switches -fcf-protection -flto=auto -pipe" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fakeroot fixlafiles ipc-sandbox merge-sync merge-wait multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms sign strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-O2 -march=znver4 -frecord-gcc-switches -fcf-protection -flto=auto -pipe" GENTOO_MIRRORS="http://distfiles.gentoo.org" INSTALL_MASK=" /usr/share/fish /usr/share/locale/* -/usr/share/locale/en -/usr/share/locale/uk -/usr/share/locale/en_CA -/usr/share/locale/en_GB -/usr/share/locale/locale.alias " LANG="en_CA.utf8" LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=auto" LEX="flex" LINGUAS="en_CA en_GB en_US en" MAKEOPTS="-j18 -l16" PKGDIR="/var/cache/binpkgs" PORTAGE_COMPRESS="zstd" PORTAGE_COMPRESS_FLAGS="--rm -15 --threads=0 --quiet" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" PORTAGE_TMPDIR="/var/tmp" RUSTFLAGS="-C target-cpu=znver4 -C opt-level=3 -v" SHELL="/bin/zsh" USE="X acl amd64 apparmor appindicator bash-completion bluetooth bpf branding brotli bzip2 caps cet crypt cups curl dbus debuginfod device-mapper elogind ffmpeg gif git gmp gnome-keyring gpm gtk hardened iconv icu ipv6 jit jpeg keyring lcms libinput libnotify libtirpc lm-sensors lto lzma modules-compress mp3 ncurses networkmanager opengl openmp openssl pam pcre p go pic pie pipewire png policykit pulseaudio python readline seccomp split-usr sqlite ssl ssp startup-notification svg test-rust threads tiff truetype udev unicode usb verify-sig vim vim-syntax vulkan wayland webp wifi xattr xorg xtpax zeroconf zlib zsh-completion zstd" ABI_X86="64" ADA_TARGET="gcc_12" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd ac tions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEAT URES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 avx512f avx512dq avx512cd avx512bw avx512vl avx512vbmi f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" CURL_SSL="openssl" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmin txt gpsclock greis isync itrax mtk3301 ntrip navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en-CA en-GB en-US en" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LLVM_TARGETS="AMDGPU BPF X86" LUA_SINGLE_TARGET="lua5-1" LUA_TARGET S="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_12" PYTHON_TARGETS="python3_10 python3_11 python3_12 pypy3" RUBY_TARGETS="ruby31" VIDEO_CARDS="amdgpu" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpma c delude chaos account" Unset: ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, LC_ALL, LD, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, SIZE, STRINGS, STRIP, YACC, YFLA GS ================================================================= Package Settings ================================================================= sys-apps/iproute2-6.8.0::gentoo was built with the following: USE="bpf caps elf (split-usr) -atm -berkdb -iptables -minimal -nfs (-selinux)" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fakeroot fixlafiles ipc-sandbox merge-sync merge-wait multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms sign strict test unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=auto -O2 -march=znver4 -frecord-gcc-switches -fcf-protection -flto=auto -pipe"
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b9442bb7d4da6f324a2830b20269f930b4fb8ccb commit b9442bb7d4da6f324a2830b20269f930b4fb8ccb Author: Patrick McLean <chutzpah@gentoo.org> AuthorDate: 2024-04-12 17:40:05 +0000 Commit: Patrick McLean <chutzpah@gentoo.org> CommitDate: 2024-04-12 17:41:55 +0000 sys-apps/iproute2: Make sure that CFLAGS is in LDFLAGS Upstream build system does not automatically add it, and GCC recommends that CFLAGS always be in LDFLAGS. Upstream GCC recommendation is here: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-flto Bug: https://bugs.gentoo.org/929233 Signed-off-by: Patrick McLean <chutzpah@gentoo.org> .../iproute2/{iproute2-6.8.0.ebuild => iproute2-6.8.0-r1.ebuild} | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
*** This bug has been marked as a duplicate of bug 502950 ***