From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C5F71158041 for ; Fri, 1 Mar 2024 19:25:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 96FBAE2A01; Fri, 1 Mar 2024 19:25:41 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 7824AE29FF for ; Fri, 1 Mar 2024 19:25:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9D1C03430F7 for ; Fri, 1 Mar 2024 19:25:40 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D283314A8 for ; Fri, 1 Mar 2024 19:25:38 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1709321116.5e7b32c59d53f8240dfd7a17e31fc533fa811f75.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/meson.eclass X-VCS-Directories: eclass/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 5e7b32c59d53f8240dfd7a17e31fc533fa811f75 X-VCS-Branch: master Date: Fri, 1 Mar 2024 19:25:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 03a30a50-76de-4991-9220-6d086b9434b3 X-Archives-Hash: 3b8c5df497a45f3d177a5a431f363e05 commit: 5e7b32c59d53f8240dfd7a17e31fc533fa811f75 Author: Eli Schwartz gmail com> AuthorDate: Tue Jan 16 05:43:58 2024 +0000 Commit: Sam James gentoo org> CommitDate: Fri Mar 1 19:25:16 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5e7b32c5 meson.eclass: wire up LTO support directly into the meson options meson's builtin LTO support allows meson to introspect whether LTO is enabled and do some fancy things, such as forcing LTO off for a single target that is known to be special(ly bad) and not support LTO. Signed-off-by: Eli Schwartz gmail.com> Signed-off-by: Sam James gentoo.org> eclass/meson.eclass | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/eclass/meson.eclass b/eclass/meson.eclass index 629bf3be4f2e..b24bb40eb0a0 100644 --- a/eclass/meson.eclass +++ b/eclass/meson.eclass @@ -41,7 +41,7 @@ esac if [[ -z ${_MESON_ECLASS} ]]; then _MESON_ECLASS=1 -inherit multiprocessing ninja-utils python-utils-r1 toolchain-funcs +inherit flag-o-matic multiprocessing ninja-utils python-utils-r1 toolchain-funcs BDEPEND=">=dev-build/meson-1.2.1 ${NINJA_DEPEND} @@ -283,6 +283,38 @@ meson_feature() { # variables. Invoke via "${MESONARGS[@]}" in the calling environment. # This function is called from meson_src_configure. setup_meson_src_configure() { + MESONARGS=() + if tc-is-lto; then + # We want to connect -flto in *FLAGS to the dedicated meson option, + # to ensure that meson has visibility into what the user set. Although + # it is unlikely projects will check `get_option('b_lto')` and change + # their behavior, individual targets which are broken with LTO can + # disable it per target. Injecting via *FLAGS means that meson cannot + # strip -flto from that target. + MESONARGS+=( -Db_lto=true ) + + # respect -flto value, e.g. -flto=8, -flto=thin + local v=$(get-flag flto) + case ${v} in + thin) + MESONARGS+=( -Db_lto_mode=thin ) + ;; + ''|*[!0-9]*) + ;; + *) + MESONARGS+=( -Db_lto_threads=${v} ) + ;; + esac + # finally, remove it from *FLAGS to avoid passing it: + # - twice, with potentially different values + # - on excluded targets + filter-lto + else + # Prevent projects from enabling LTO by default. In Gentoo, LTO is + # enabled via setting *FLAGS appropriately. + MESONARGS+=( -Db_lto=false ) + fi + local BUILD_CFLAGS=${BUILD_CFLAGS} local BUILD_CPPFLAGS=${BUILD_CPPFLAGS} local BUILD_CXXFLAGS=${BUILD_CXXFLAGS} @@ -311,7 +343,7 @@ setup_meson_src_configure() { : "${BUILD_PKG_CONFIG_PATH:=${PKG_CONFIG_PATH}}" fi - MESONARGS=( + MESONARGS+=( --libdir "$(get_libdir)" --localstatedir "${EPREFIX}/var/lib" --prefix "${EPREFIX}/usr" @@ -331,9 +363,7 @@ setup_meson_src_configure() { # 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 + "${ltoflags[@]}" ) if [[ -n ${EMESON_BUILDTYPE} ]]; then