Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 684880 - flag-o-matic.eclass: strip-unsupported-flags does not verify flags broken at link-time (e.g. -flto with missing plugin support)
Summary: flag-o-matic.eclass: strip-unsupported-flags does not verify flags broken at ...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
Depends on:
Blocks: 684872
  Show dependency tree
Reported: 2019-05-01 13:28 UTC by Michał Górny
Modified: 2019-12-28 13:03 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-05-01 13:28:56 UTC
This is somewhat similar to bug #333763, except that it affects C*FLAGS.

The reporter has:


and the ebuild needs to be built using sys-devel/clang, so it calls strip-unsupported-flags.  However, this function does not verify whether the flags work at link time, so '-flto' is not stripped.  As a result, the build fails due to '-flto' failing at link time.
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2019-12-24 11:48:37 UTC
I'm not sure strip-unsupported-flags() should fix misconfigured systems. It's main purpose is to remove unrecognised/individual non-working flags. Flag interactions are always complex (like -m32/-m64 misconfiguration across CFLAGS/LDFLAGS).

If lto is consistently broken I would expect every package merge to fail with CFLAGS=-flto. Whether package calls strip-unsupported-flags() or not.

We could add a special case for -flto similar to below:

--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -618,6 +618,9 @@ test_version_info() {
 # Strip {C,CXX,F,FC}FLAGS of any flags not supported by the active toolchain.
 strip-unsupported-flags() {
+       if ! test-flag-CCLD -flto; then
+               filter-flags '-flto*'
+       fi
        export CFLAGS=$(test-flags-CC ${CFLAGS})
        export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS})
        export FFLAGS=$(test-flags-F77 ${FFLAGS})

But it will be too conservative for cases like CFLAGS=-ffat-lto-objects where -flto linker support should not matter as much.

Individual ebuild might be a better place for such workarounds.