Pass `-Db_lto=false` globally to force-disable appending `-flto`
in projects that default to it.  In Gentoo, users enable LTO via setting
`*FLAGS` manually.

If a package really needs to pass `-Db_lto=true` because the build
system enables some custom logic based on it, `tc-is-lto` can be used
to determine whether LTO is enabled, and then `-Db_lto=true` can be
passed explicitly by the ebuild.

Signed-off-by: Michał Górny <mgo...@gentoo.org>
---
 eclass/meson.eclass | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/eclass/meson.eclass b/eclass/meson.eclass
index f7cf8a0722ba..83bbcba40302 100644
--- a/eclass/meson.eclass
+++ b/eclass/meson.eclass
@@ -334,6 +334,10 @@ meson_src_configure() {
                # It's Gentoo policy to not have builds die on blanket -Werror, 
as it's
                # an upstream development matter. bug #754279.
                -Dwerror=false
+
+               # Prevent projects from enabling LTO by default.  In Gentoo, 
LTO is
+               # enabled via setting *FLAGS appropriately.
+               -Db_lto=false
        )
 
        if [[ -n ${EMESON_BUILDTYPE} ]]; then
-- 
2.43.0


Reply via email to