public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] Re: [PATCH] Fix tc-cpp-is-true to work with clang
       [not found] <20191104101120.230510-1-mnissler@chromium.org>
@ 2019-11-04 20:18 ` Sergei Trofimovich
  2019-11-06 22:46   ` Sergei Trofimovich
  0 siblings, 1 reply; 2+ messages in thread
From: Sergei Trofimovich @ 2019-11-04 20:18 UTC (permalink / raw
  To: Mattias Nissler; +Cc: gentoo-dev

On Mon,  4 Nov 2019 10:11:20 +0000
Mattias Nissler <mnissler@chromium.org> wrote:

> Clang's preprocessor likes to output a leading newline, which makes
> the comparison always fail. GCC generates additional output with certain
> flags (e.g. -ggdb3) as well. Hence, switch the test to trigger a
> preprocessor error when the condition is not true and examine the exit
> code.
> 
> Bug: https://bugs.gentoo.org/698912
> 
> Signed-off-by: Mattias Nissler <mnissler@chromium.org>
> ---
>  eclass/toolchain-funcs.eclass | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)

Looks good! I'll pull it in to ::gentoo in a few days.

Thank you!

> diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
> index e358d484417..1bc6cbbc108 100644
> --- a/eclass/toolchain-funcs.eclass
> +++ b/eclass/toolchain-funcs.eclass
> @@ -207,14 +207,13 @@ tc-cpp-is-true() {
>  	local CONDITION=${1}
>  	shift
>  
> -	local RESULT=$($(tc-getTARGET_CPP) "${@}" -P - <<-EOF 2>/dev/null
> -			#if ${CONDITION}
> -			true
> -			#endif
> -		EOF
> -	)
> -
> -	[[ ${RESULT} == true ]]
> +	$(tc-getTARGET_CPP) "${@}" -P - <<-EOF >/dev/null 2>&1
> +		#if ${CONDITION}
> +		true
> +		#else
> +		#error false
> +		#endif
> +	EOF
>  }
>  
>  # @FUNCTION: tc-detect-is-softfloat
> -- 
> 2.21.0
> 


-- 

  Sergei


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [gentoo-dev] Re: [PATCH] Fix tc-cpp-is-true to work with clang
  2019-11-04 20:18 ` [gentoo-dev] Re: [PATCH] Fix tc-cpp-is-true to work with clang Sergei Trofimovich
@ 2019-11-06 22:46   ` Sergei Trofimovich
  0 siblings, 0 replies; 2+ messages in thread
From: Sergei Trofimovich @ 2019-11-06 22:46 UTC (permalink / raw
  To: Mattias Nissler; +Cc: gentoo-dev

On Mon, 4 Nov 2019 20:18:11 +0000
Sergei Trofimovich <slyfox@gentoo.org> wrote:

> On Mon,  4 Nov 2019 10:11:20 +0000
> Mattias Nissler <mnissler@chromium.org> wrote:
> 
> > Clang's preprocessor likes to output a leading newline, which makes
> > the comparison always fail. GCC generates additional output with certain
> > flags (e.g. -ggdb3) as well. Hence, switch the test to trigger a
> > preprocessor error when the condition is not true and examine the exit
> > code.
> > 
> > Bug: https://bugs.gentoo.org/698912
> > 
> > Signed-off-by: Mattias Nissler <mnissler@chromium.org>
> > ---
> >  eclass/toolchain-funcs.eclass | 15 +++++++--------
> >  1 file changed, 7 insertions(+), 8 deletions(-)  
> 
> Looks good! I'll pull it in to ::gentoo in a few days.

Pushed to ::gentoo as:
    https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3ef6b33339da7bb04afd77e1bc5db011b02d658a
Also while at it added basic regression test:
    https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8f02136721af40dd89a09101504750fb28f8142e

-- 

  Sergei


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-06 22:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20191104101120.230510-1-mnissler@chromium.org>
2019-11-04 20:18 ` [gentoo-dev] Re: [PATCH] Fix tc-cpp-is-true to work with clang Sergei Trofimovich
2019-11-06 22:46   ` Sergei Trofimovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox