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 57B06158041 for ; Tue, 20 Feb 2024 06:35:17 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2F30A2BC083; Tue, 20 Feb 2024 06:35:09 +0000 (UTC) Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) (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 A85AF2BC07A for ; Tue, 20 Feb 2024 06:35:08 +0000 (UTC) Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3bbbc6bcc78so3893674b6e.1 for ; Mon, 19 Feb 2024 22:35:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708410907; x=1709015707; darn=lists.gentoo.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rISsnCdKRnQust2fqhE/lt94156rfTNSdPW/UZCwAg0=; b=bLHLk7I3FoUBYgTD/pCef878jWjLocWHi5asIOt2G4KWR84u1AUMRr0/ffhhwqe66S EtnVEhj1ttcL5D+X5vacsjdXDdCueKcEpDBzrUaSyToljZ+nkzQ687IzLuvhYdp1HgFs eSTxCpJ6KROaQnmCD4FqXcLLtHuonOcaO0VfdchDxAYfx+K+YoK1TRP1Esde17KFrfZf 8ga2ULmFl92+vsIjLllC42Re0seIfJArHRUV2ATmIl6UlSHE+Ii10NZlDh93uMd9aEGa Ctalh/gwP+UJmUxoaCksJJxZz5kAtl9MMfkpieLnnJ6xTh/uWpH9kafylHOCbbPcaSeV cCfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708410907; x=1709015707; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rISsnCdKRnQust2fqhE/lt94156rfTNSdPW/UZCwAg0=; b=c9OHbIuB7SBKGHoRZBZWKMjzgb6O6rHVYqrFwy+MQwHeOahaacuSzJaWajhM8orfcK fvxoygcz810CehI4LIs+FCOjPkDJq3en8C4LYBYNyaB/700zU8+zE7BCbLIh94QiAm/4 pxH5haBkL83uSf39+eSymGr1YQ+PqBKagUG+3XI25bz0TvhjGNe2IhE847nedQH8oM/W +k0ud6YeJh4sC6NkFN9NEZ0s+2jMdDMWeZVASPi3vJj6SmO/8RTWLPUkDS7BdYazgWkA MB3mtCeiC79CYNWOtLUKDy7WMXX+8+Pf6PIJvqAvVV0LmtAEKGbvgUtf2gSP779agiVE /Bpw== X-Gm-Message-State: AOJu0YxWj4Y+XS+s5CgelZhwhso1Xw1ftH01CLMOopw4mczDGnTtKN1O oNeJRVA0N6QWRvls5mOoknjpVCA+ubqf3ksdAPXD6ulEcEvoxo9cJ1JKu+u3 X-Google-Smtp-Source: AGHT+IEfg0r8AyZwpOLz2DjXza0yxOUvZGb4497hdmeBKDIZLB0nJTDcAi3A2JI6eK8w4Jzu5J1dMw== X-Received: by 2002:a05:6808:4d0:b0:3c1:347f:39d1 with SMTP id a16-20020a05680804d000b003c1347f39d1mr14610248oie.22.1708410907169; Mon, 19 Feb 2024 22:35:07 -0800 (PST) Received: from acleverhostname.attlocal.net (108-200-163-197.lightspeed.bcvloh.sbcglobal.net. [108.200.163.197]) by smtp.gmail.com with ESMTPSA id a14-20020a05680802ce00b003c15d61ec3fsm461475oid.37.2024.02.19.22.35.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 22:35:06 -0800 (PST) From: Eli Schwartz To: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] [PATCH v2 1/5] meson.eclass: wire up LTO support directly into the meson options Date: Tue, 20 Feb 2024 01:14:41 -0500 Message-ID: <20240220063504.3959739-2-eschwartz93@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240220063504.3959739-1-eschwartz93@gmail.com> References: <1b9b73ea-9895-4680-aab7-117e47c9cc36@gmail.com> <20240220063504.3959739-1-eschwartz93@gmail.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: f662c5cc-f331-4a79-b719-32a4cb7157f1 X-Archives-Hash: a65a40945db45be66d40cff72d3b4b31 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 --- no change eclass/meson.eclass | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/eclass/meson.eclass b/eclass/meson.eclass index d8bd93082ea5..c2ae289019e9 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} @@ -286,6 +286,36 @@ meson_src_configure() { [[ -n "${NINJA_DEPEND}" ]] || ewarn "Unknown value '${NINJA}' for \${NINJA}" + local ltoflags=() + 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. + ltoflags+=( -Db_lto=true ) + + # respect -flto value, e.g. -flto=8, -flto=thin + local v=$(get-flag flto) + case ${v} in + thin) + ltoflags+=( -Db_lto_mode=thin ) + ;; + ''|*[!0-9]*) + ;; + *) ltoflags+=( -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. + ltoflags+=( -Db_lto=false ) + fi + local BUILD_CFLAGS=${BUILD_CFLAGS} local BUILD_CPPFLAGS=${BUILD_CPPFLAGS} local BUILD_CXXFLAGS=${BUILD_CXXFLAGS} @@ -335,9 +365,7 @@ 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 -- 2.43.0