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 8D920158041 for ; Tue, 20 Feb 2024 04:33:20 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 90DA72BC033; Tue, 20 Feb 2024 04:32:42 +0000 (UTC) Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) (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 47DBF2BC02D for ; Tue, 20 Feb 2024 04:32:42 +0000 (UTC) Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6dc8b280155so3019428a34.0 for ; Mon, 19 Feb 2024 20:32:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708403558; x=1709008358; 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=fVTCIz4yZF9Re8NkS6RsF4TPdW0bW38ejtRJeqLPgA4=; b=LdUcSgX+kiwAnAUeOFAbjMIU4d+I2U/vFqLs9W/jaz038j2xKqhPIXMm85a/Nm1lM1 Ebhd4RWHkBW5ZLiEns/C/LDhOQFWSvgWRT+uS+/aPMkoX9v6npu6w4JlIB7+dYbAYhfV C+VgjS8gZ4E59a2yjrvAlqujRQUjCI0tbGM2HTwMhry8UJcd4T2TnHar7vO67v48q36A u4aNMrkQn5t50qf+rSI/IuqeVBa2DUteG1E+wHS6EFbWiEd7NyzJnZg9+Gtq3CRtPo06 HRTUQoR/9zinX8kj0MiZcQGSkZzSUHhsT/KCv3R9bDK89ksH4iANjN4nedLOr5PTUQJI aLjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708403558; x=1709008358; 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=fVTCIz4yZF9Re8NkS6RsF4TPdW0bW38ejtRJeqLPgA4=; b=BOUhunv+MK2Tn9Z3tSobJMJikiQWG0V8qUXsRB1RnFndcGU2Qtc3XWcf/yuG7GKx1i uT0R+ME2ULmdYmjU1BdmFAcSiKlI7C5GUjlOdkHFFnT8cDbnEzy3kkj/MGDKUP9lXVkH oQfBwuqKTMaoqFpcgTOXFH/etlWvSPzaJRnNDBk5kz19si/QBf/IShgpmtxIRF/1S23W iiS5TwKHncsjhUA+s8gKJlzTuZPJn7FmD+pQJBNPlJgyA4laR98/39Hj1soX7mrk5BGk 5JAWhvirSnu3vXWbiaOC8zjQnEXu4jPvTEmnMDoJ72nt0sF7derVQBi1Grghmr/M6kYj T0JQ== X-Gm-Message-State: AOJu0YxSEUuEyey2hXaenrS2yisl8bntt3OXaZdkWSpv4Idy2EO7sqvj rwQdO/dsosfdGnI/bFVTFVlUXdtFS57e1Pe2wjMyR1x/A9p4PIM8eA6Gs19T X-Google-Smtp-Source: AGHT+IHFyDWLwyvuAW8OvkoCKUqhfcPogmfoANtWrCbOASJfeDzwHHxK+1wldcym3opJKUCXyq2jlw== X-Received: by 2002:a05:6870:b98:b0:21e:df09:9a12 with SMTP id lg24-20020a0568700b9800b0021edf099a12mr4216222oab.10.1708403558139; Mon, 19 Feb 2024 20:32:38 -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 fu6-20020a0568705d8600b0021ed50d4741sm854858oab.7.2024.02.19.20.32.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 20:32:37 -0800 (PST) From: Eli Schwartz To: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] [PATCH 1/3] meson.eclass: wire up LTO support directly into the meson options Date: Mon, 19 Feb 2024 23:26:47 -0500 Message-ID: <20240220043235.3889132-2-eschwartz93@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240220043235.3889132-1-eschwartz93@gmail.com> References: <20240220043235.3889132-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: a44a21b9-6691-4ed7-8f99-95e068d6a8fa X-Archives-Hash: 3fa291d55b9e35cdfe6f84bcfe48cc3e 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 --- 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