Re: [gentoo-dev] [PATCH v2 4/7] distutils-r1.eclass: Make vars local before calling filter-lto

2024-03-09 Thread Eli Schwartz
On 3/9/24 2:59 PM, Mike Gilbert wrote:
> On Tue, Mar 5, 2024 at 12:16 PM Michał Górny  wrote:
>>
>> Make LTO filtering local to the compilation code.  This avoids disabling
>> LTO for non-Python parts of an ebuild.
>>
>> Signed-off-by: Michał Górny 
>> ---
>>  eclass/distutils-r1.eclass | 4 
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
>> index ee1dcef24ff6..134cb39f276a 100644
>> --- a/eclass/distutils-r1.eclass
>> +++ b/eclass/distutils-r1.eclass
>> @@ -1828,6 +1828,10 @@ distutils-r1_run_phase() {
>> # Rust extensions are incompatible with C/C++ LTO compiler
>> # see e.g. https://bugs.gentoo.org/910220
>> if has cargo ${INHERITED}; then
>> +   local x
>> +   for x in $(all-flag-vars); do
>> +   local -x "${x}=${!x}"
>> +   done
>> filter-lto
>> fi
>> fi
> 
> I had never thought to loop over all-flag-vars like this. Added to my
> mental code repo, thanks!


To be fair, when I suggested this in review of the patch it wasn't my
idea either. I shamelessly stole it from... flag-o-matic.eclass, where
it is used by filter-flags, replace-flags, is-flagq, strip-flags, get-flag.

filter-flags in turn is used by filter-lto, hence all-flag-vars is the
direct API that governs what variables filter-lto will modify. It seemed
fitting to single-source that information.


-- 
Eli Schwartz


OpenPGP_0x84818A6819AF4A9B.asc
Description: OpenPGP public key


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: [gentoo-dev] [PATCH v2 4/7] distutils-r1.eclass: Make vars local before calling filter-lto

2024-03-09 Thread Mike Gilbert
On Tue, Mar 5, 2024 at 12:16 PM Michał Górny  wrote:
>
> Make LTO filtering local to the compilation code.  This avoids disabling
> LTO for non-Python parts of an ebuild.
>
> Signed-off-by: Michał Górny 
> ---
>  eclass/distutils-r1.eclass | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
> index ee1dcef24ff6..134cb39f276a 100644
> --- a/eclass/distutils-r1.eclass
> +++ b/eclass/distutils-r1.eclass
> @@ -1828,6 +1828,10 @@ distutils-r1_run_phase() {
> # Rust extensions are incompatible with C/C++ LTO compiler
> # see e.g. https://bugs.gentoo.org/910220
> if has cargo ${INHERITED}; then
> +   local x
> +   for x in $(all-flag-vars); do
> +   local -x "${x}=${!x}"
> +   done
> filter-lto
> fi
> fi

I had never thought to loop over all-flag-vars like this. Added to my
mental code repo, thanks!



[gentoo-dev] [PATCH v2 4/7] distutils-r1.eclass: Make vars local before calling filter-lto

2024-03-05 Thread Michał Górny
Make LTO filtering local to the compilation code.  This avoids disabling
LTO for non-Python parts of an ebuild.

Signed-off-by: Michał Górny 
---
 eclass/distutils-r1.eclass | 4 
 1 file changed, 4 insertions(+)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index ee1dcef24ff6..134cb39f276a 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1828,6 +1828,10 @@ distutils-r1_run_phase() {
# Rust extensions are incompatible with C/C++ LTO compiler
# see e.g. https://bugs.gentoo.org/910220
if has cargo ${INHERITED}; then
+   local x
+   for x in $(all-flag-vars); do
+   local -x "${x}=${!x}"
+   done
filter-lto
fi
fi
-- 
2.44.0