On Sun, Oct 12, 2014 at 2:03 PM, Dan Douglas <orm...@gmail.com> wrote:
> On Sun, Oct 12, 2014 at 11:22 AM, Anthony G. Basile <bluen...@gentoo.org> 
> wrote:
>> Hi everyone,
>>
>> I'd like to add the patch below to toolchain-funcs.eclass.  I need it for
>> bug #499996 and it helps to address a category of bugs which gcc-4.8
>> uncovers.  4.8 and above introduces -fstack-check.  This is code emitted by
>> gcc to make sure you don't go past the beyond the boundary of the stack in a
>> multithreaded environment.  It requires one register on at least i686 and
>> amd64, but I'm not sure about the others.  In asm heavy code, such as vlc
>> and ffmpeg, we hit the limit of useable registers pretty quickly and go over
>> the top with either -fstack-check or pie.  We have tests to check for pie in
>> toolchain-funcs, but not for stack-check.  The following adds that check.  I
>> tested it already.  I'll commit in a few days if there are no objections.
>>
>> --- toolchain-funcs.eclass.orig    2014-10-12 11:23:41.585182742 -0400
>> +++ toolchain-funcs.eclass    2014-10-12 11:31:57.170205300 -0400
>> @@ -610,6 +610,12 @@
>>      directive=$(gcc-specs-directive cc1)
>>      return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]])
>>  }
>> +# Returns true if gcc builds with fstack-check
>> +gcc-specs-stack-check() {
>> +    local directive
>> +    directive=$(gcc-specs-directive cc1)
>> +    return $([[ "${directive/\{!fno-stack-check:}" != "${directive}" ]])
>> +}
>>
>>
>>  # @FUNCTION: gen_usr_ldscript
>
> Am I missing something here? I don't see how any of the tests used in
> gcc-specs-* functions could possibly produce an output. The fact that this
> coincidentally works in Bash shouldn't be relied upon.
>

I think he just copy/pasted the style of the other gcc-specs functions.

I think they could all be improved by removing that weird/unnecessary
subshell, which always evaluates to an empty string. When passed no
arguments, the return statement just defaults to the value of $?,
which in this case is the exit status of the subshell.

So, instead of this:

return $([[ "${directive/\{!fno-stack-check:}" != "${directive}" ]])

Just do this:

[[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]

Which should be equivalent.

Reply via email to