public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* Re: [gentoo-dev] [PATCH 3/4] toolchain-funcs.eclass: Add tc-get-compiler-type()
  @ 2016-06-23  6:52 99%   ` Fabian Groffen
  0 siblings, 0 replies; 1+ results
From: Fabian Groffen @ 2016-06-23  6:52 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 864 bytes --]

On 22-06-2016 22:06:53 +0200, Michał Górny wrote:
> +# @FUNCTION: tc-get-compiler-type
> +# @RETURN: keyword identifying the compiler: gcc, clang, unknown
> +tc-get-compiler-type() {
> +	set -- $($(tc-getCPP "$@") -E -P - <<<"CPP_WORKS __GNUC__ __clang__")

% echo "CPP_WORKS __GNUC__ __clang__" | clang -E -P  - 
CPP_WORKS 4 1

The logic below does the right thing, but it might be good for future
reference to make note of this (clang).

> +
> +	# CPP_WORKS shouldn't be substituted -- so if it's not there,
> +	# cpp is probably broken
> +	if [[ $1 != CPP_WORKS ]]; then
> +		echo unknown
> +	# Check which of the defines were substituted
> +	elif [[ $3 != __clang__ ]]; then
> +		echo clang
> +	elif [[ $2 != __GNUC__ ]]; then
> +		echo gcc
> +	else
> +		echo unknown
> +	fi
> +}

-- 
Fabian Groffen
Gentoo on a different level

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-06-22 20:06     [gentoo-dev] [PATCH 0/4] toolchain-funcs.eclass: fix for version checks (v2) + compiler identification Michał Górny
2016-06-22 20:06     ` [gentoo-dev] [PATCH 3/4] toolchain-funcs.eclass: Add tc-get-compiler-type() Michał Górny
2016-06-23  6:52 99%   ` Fabian Groffen

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