Gentoo Archives: gentoo-dev

From: Michael Orlitzky <mjo@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] How to set CXX compiler?
Date: Fri, 03 Jul 2020 22:46:28
Message-Id: c778760e-34fe-50df-ebbc-704d886fa062@gentoo.org
In Reply to: [gentoo-dev] How to set CXX compiler? by "Xianwen Chen (陈贤文)"
1 On 2020-07-03 18:35, Xianwen Chen (陈贤文) wrote:
2 >
3 > In the Makefile, it is written that
4 >
5 > cc = g++
6 >
7 > I would like to use sed to patch it so that it ebuild knows which g++ to
8 > use. For example, depending on whether ccache is set, ebuild shall know
9 > whether to use ccache.
10
11 First, you should suggest to upstream that they don't force a particular
12 compiler in their Makefile. One uncontroversial way to do this is by
13 setting the default only if the user does not already have one set, with
14 the "?=" assignment operator:
15
16 cc ?= g++
17
18 Then, you should suggest that they change the name of that variable to
19 the relatively-standard "CXX" that is used for the C++ compiler:
20
21 CXX ?= g++
22
23 Finally, in your ebuild, you should run
24
25 emake CXX=$(tc-getCXX) ...
26
27 to override the default CXX in the Makefile. Even if upstream doesn't
28 respond right away, you can patch the Makefile with these suggestions in
29 Gentoo and send them the patch.