[prev in list] [next in list] [prev in thread] [next in thread]
List: gentoo-dev
Subject: Re: [gentoo-dev] Add gcc-specs-stack-check() to toolchain-funcs.eclass
From: "Anthony G. Basile" <blueness () gentoo ! org>
Date: 2014-10-15 22:36:38
Message-ID: 543EF6F6.4080509 () gentoo ! org
[Download RAW message or body]
On 10/12/14 17:22, Anthony G. Basile wrote:
> On 10/12/14 15:55, Anthony G. Basile wrote:
>> On 10/12/14 15:46, Ulrich Mueller wrote:
>>>>>>>> On Sun, 12 Oct 2014, Dan Douglas wrote:
>>>> On Sun, Oct 12, 2014 at 11:22 AM, Anthony G. Basile
>>>> <blueness@gentoo.org> wrote:
>>>>> +# 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}" ]])
>>>>> +}
>>>> 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.
>>> The command produces no output, so return is effectively called
>>> without argument. Therefore it will return with the status of the last
>>> command executed, which is [[ ]] ...
>>>
>>> It would be clearer if the last line of the function was simply this:
>>> [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
>>>
>>> Ulrich
>>
>> Yeah the return there is useless and in fact deceiving. Its
>> returning a blank with an error code. Here's some bash to illustrate:
>>
>> do_true() {
>> return $([[ 42 == 42 ]])
>> }
>>
>> do_false() {
>> return $([[ 42 != 42 ]])
>> }
>>
>> do_true # echo's nothing
>>
>> do_false # echo's nothing
>>
>> do_true ; echo $?
>> 0
>>
>> do_false ; echo $?
>> 1
>>
>> I can fix my function as well as the other gcc-specs-* in there,
>> which I just copied. I'll produce two patches for the community's
>> approval before committing anything. However, we'd better grep the
>> tree for those gcc-specs-* functions just in case something subtle is
>> going on.
>>
>
> Okay, I grepped the tree and there's nothing subtle that I can see. So
> what I'll commit is the following:
>
> 1) First I'll clean up
>
> --- toolchain-funcs.eclass.orig 2014-10-12 11:23:41.585182742 -0400
> +++ toolchain-funcs.eclass 2014-10-12 17:19:30.086154455 -0400
> @@ -169,7 +169,7 @@
> # @FUNCTION: tc-is-cross-compiler
> # @RETURN: Shell true if we are using a cross-compiler, shell false
> otherwise
> tc-is-cross-compiler() {
> - return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]])
> + [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
> }
>
> # @FUNCTION: tc-is-softfloat
> @@ -210,7 +210,7 @@
> local host=${CTARGET:-${CHOST}}
>
> # *MiNT doesn't have shared libraries, only platform so far
> - return $([[ ${host} == *-mint* ]])
> + [[ ${host} == *-mint* ]]
> }
>
> # @FUNCTION: tc-export_build_env
> @@ -578,37 +578,37 @@
> gcc-specs-relro() {
> local directive
> directive=$(gcc-specs-directive link_command)
> - return $([[ "${directive/\{!norelro:}" != "${directive}" ]])
> + [[ "${directive/\{!norelro:}" != "${directive}" ]]
> }
> # Returns true if gcc sets now
> gcc-specs-now() {
> local directive
> directive=$(gcc-specs-directive link_command)
> - return $([[ "${directive/\{!nonow:}" != "${directive}" ]])
> + [[ "${directive/\{!nonow:}" != "${directive}" ]]
> }
> # Returns true if gcc builds PIEs
> gcc-specs-pie() {
> local directive
> directive=$(gcc-specs-directive cc1)
> - return $([[ "${directive/\{!nopie:}" != "${directive}" ]])
> + [[ "${directive/\{!nopie:}" != "${directive}" ]]
> }
> # Returns true if gcc builds with the stack protector
> gcc-specs-ssp() {
> local directive
> directive=$(gcc-specs-directive cc1)
> - return $([[ "${directive/\{!fno-stack-protector:}" !=
> "${directive}" ]])
> + [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
> }
> # Returns true if gcc upgrades fstack-protector to fstack-protector-all
> gcc-specs-ssp-to-all() {
> local directive
> directive=$(gcc-specs-directive cc1)
> - return $([[ "${directive/\{!fno-stack-protector-all:}" !=
> "${directive}" ]])
> + [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
> }
> # Returns true if gcc builds with fno-strict-overflow
> gcc-specs-nostrict() {
> local directive
> directive=$(gcc-specs-directive cc1)
> - return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}"
> ]])
> + [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
> }
>
>
> 2) Then I'll add gcc-specs-stack-check()
>
>
> --- toolchain-funcs.eclass 2014-10-12 17:19:30.086154455 -0400
> +++ /root/toolchain-funcs.eclass 2014-10-12 17:19:05.983153358 -0400
> @@ -610,6 +610,12 @@
> directive=$(gcc-specs-directive cc1)
> [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
> }
> +# Returns true if gcc builds with fstack-check
> +gcc-specs-stack-check() {
> + local directive
> + directive=$(gcc-specs-directive cc1)
> + [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
> +}
>
>
> # @FUNCTION: gen_usr_ldscript
>
This has been committed to the tree. Please alert asap if anything
breaks. Thanks!
--
Anthony G. Basile, Ph.D.
Gentoo Linux Developer [Hardened]
E-Mail : blueness@gentoo.org
GnuPG FP : 1FED FAD9 D82C 52A5 3BAB DC79 9384 FA6E F52D 4BBA
GnuPG ID : F52D4BBA
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic