autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unoptimized autoconf generated code


From: Eric Blake
Subject: Re: unoptimized autoconf generated code
Date: Mon, 01 Mar 2010 17:32:24 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

According to Bruno Haible on 2/23/2010 4:43 PM:
> Hi Eric,
> 
>>> The first use of as_gl_Symbol is now like this:
>>>
>>>   if { as_var=$as_gl_Symbol; eval "test \"\${$as_var+set}\" = set"; }; then
>>>
>>> Autoconf could have optimized this to
>>>
>>>   if eval "test \"\${$as_gl_Symbol+set}\" = set"; then
>>>
>>> Neither autoconf 2.60 not 2.65 do this optimization.
>>
>> That's because it is too complex at m4 time to tell whether the
>> indirection is simple enough to simplify like that.  The whole point of
>> AS_LITERAL_IF and AS_VAR_* is that you can have things more complex than
>> '$as_gl_Symbol' as the indirect variable name, such as '`program that
>> outputs valid shell name`', and in that case, you cannot simplify things
>> by bypassing the intermediate variable without running into "`""`" shell
>> bugs.
> 
> It is not that complicated:
> 
> m4_define([AS_VAR_TEST_SET],
> [AS_LITERAL_IF([$1],
>                [test "${$1+set}" = set],
>                [AS_VAR_REF_IF([$1],
>                               [eval "test \"\${][$1][+set}\" = set"],
>                               [{ as_var=$1; eval "test \"\${$as_var+set}\" = 
> set"; }])])])
> 
> # Tests whether the first argument is a shell variable reference, like $foo
> # AS_VAR_REF_IF(EXPRESSION, IF_BRANCH, ELSE_BRANCH)
> m4_define([AS_VAR_REF_IF],
> [_AS_VAR_REF_IF(m4_expand([$1]), [$2], [$3])])
> 
> m4_define([_AS_VAR_REF_IF],
> [m4_if(m4_substr([$1],[0],[1]),[$],
>   [AS_LITERAL_IF([m4_substr([$1],[1])], [$2], [$3])],
>   [$3])])
> 
> Should I submit a patch to autoconf-patches?

I'm game.  But I think this patch series is a little more robust.  It
shaves more than 1k size off of coreutils' configure.  The number of
reduced processes is in the noise.

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden

Attachment: autoconf.patch258
Description: Text document

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]