Gentoo Archives: gentoo-dev

From: Fabian Groffen <grobian@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH 3/4] toolchain-funcs.eclass: Add tc-get-compiler-type()
Date: Thu, 23 Jun 2016 06:52:55
Message-Id: 20160623065220.svcr7uwzvr274zax@gentoo.org
In Reply to: [gentoo-dev] [PATCH 3/4] toolchain-funcs.eclass: Add tc-get-compiler-type() by "Michał Górny"
1 On 22-06-2016 22:06:53 +0200, Michał Górny wrote:
2 > +# @FUNCTION: tc-get-compiler-type
3 > +# @RETURN: keyword identifying the compiler: gcc, clang, unknown
4 > +tc-get-compiler-type() {
5 > + set -- $($(tc-getCPP "$@") -E -P - <<<"CPP_WORKS __GNUC__ __clang__")
6
7 % echo "CPP_WORKS __GNUC__ __clang__" | clang -E -P -
8 CPP_WORKS 4 1
9
10 The logic below does the right thing, but it might be good for future
11 reference to make note of this (clang).
12
13 > +
14 > + # CPP_WORKS shouldn't be substituted -- so if it's not there,
15 > + # cpp is probably broken
16 > + if [[ $1 != CPP_WORKS ]]; then
17 > + echo unknown
18 > + # Check which of the defines were substituted
19 > + elif [[ $3 != __clang__ ]]; then
20 > + echo clang
21 > + elif [[ $2 != __GNUC__ ]]; then
22 > + echo gcc
23 > + else
24 > + echo unknown
25 > + fi
26 > +}
27
28 --
29 Fabian Groffen
30 Gentoo on a different level

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies