diff mbox

ccache: fix explicit build 'make clean host-ccache'

Message ID 1461952973-20054-1-git-send-email-patrickdepinguin@gmail.com
State Changes Requested
Headers show

Commit Message

Thomas De Schampheleire April 29, 2016, 6:02 p.m. UTC
From: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>

To build host-ccache we need to call the bare compiler. With a standard
'make', this is guaranteed because host-ccache is built as part of the
dependencies, and a target-specific variable sets HOSTCC/HOSTCXX to the
no-ccache version (see support/dependencies/dependencies.mk).
However, this is not the case when using 'make host-ccache' explicitly
from a clean build.

Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
---
 package/ccache/ccache.mk | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Thomas Petazzoni May 1, 2016, 12:39 p.m. UTC | #1
Hello,

On Fri, 29 Apr 2016 20:02:53 +0200, Thomas De Schampheleire wrote:

> To build host-ccache we need to call the bare compiler. With a standard
> 'make', this is guaranteed because host-ccache is built as part of the
> dependencies, and a target-specific variable sets HOSTCC/HOSTCXX to the
> no-ccache version (see ).
> However, this is not the case when using 'make host-ccache' explicitly
> from a clean build.

I think this means that the CC/CXX assignments in
support/dependencies/dependencies.mk are useless, no? If you do "make
clean host-tar", or "make clean host-xz" or "make clean host-sstrip",
it will fail the same way, no? Doesn't this mean that those "special"
package should be fixed to define CC=$(HOSTCC_NOCCACHE)
CXX=$(HOSTCXX_NOCCACHE) in their environment ?

> +# To build host-ccache we need to call the bare compiler. With a standard
> +# 'make', this is guaranteed because host-ccache is built as part of the
> +# dependencies, and a target-specific variable sets HOSTCC/HOSTCXX to the
> +# no-ccache version (see support/dependencies/dependencies.mk).
> +# However, this is not the case when using 'make host-ccache'.
> +HOST_CCACHE_CONF_ENV += CC=$(HOSTCC_NOCCACHE) CXX=$(HOSTCXX_NOCCACHE)

Double quotes around the variable value?

Thanks,

Thomas
Thomas De Schampheleire May 1, 2016, 8:11 p.m. UTC | #2
Hi Thomas,

On Sun, May 1, 2016 at 2:39 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Hello,
>
> On Fri, 29 Apr 2016 20:02:53 +0200, Thomas De Schampheleire wrote:
>
>> To build host-ccache we need to call the bare compiler. With a standard
>> 'make', this is guaranteed because host-ccache is built as part of the
>> dependencies, and a target-specific variable sets HOSTCC/HOSTCXX to the
>> no-ccache version (see ).fo
>> However, this is not the case when using 'make host-ccache' explicitly
>> from a clean build.
>
> I think this means that the CC/CXX assignments in
> support/dependencies/dependencies.mk are useless, no? If you do "make
> clean host-tar", or "make clean host-xz" or "make clean host-sstrip",
> it will fail the same way, no? Doesn't this mean that those "special"
> package should be fixed to define CC=$(HOSTCC_NOCCACHE)
> CXX=$(HOSTCXX_NOCCACHE) in their environment ?

After some quick checking, it seems to depend which packages are in
DEPENDENCIES_HOST_PREREQ: 'make clean host-foo' will fail if host-foo
is in DEPENDENCIES_HOST_PREREQ but will succeed if it is not. This is
because packages that all packages get 'dependencies' as dependency,
except packages that are itself in DEPENDENCIES_HOST_PREREQ.

So, on my system, 'make clean host-xz' worked fine because I have a
suitable xzcat already and hence host-xz is not put in
DEPENDENCIES_HOST_PREREQ. Similar for host-tar. If I cheat and add
host-xz in DEPENDENCIES_HOST_PREREQ unconditionally, 'make clean
host-xz' indeed fails.

This difference depending on the host system also means that a
solution where e.g. host-xz is changed to set CC and CXX to
no-ccache-versions is suboptimal: in case host-xz is not in
DEPENDENCIES_HOST_PREREQ, the package would be built without ccache
even if it were available. One could argue that there's no need to
build host-xz in this scenario, but I can imagine other packages that
can be mandatory in some situations and optional in others.
Maybe this is nothing to worry about and we should keep things simple:
don't use ccache for host packages that are potentially a core
dependency for buildroot.

What are your thoughts?

>
>> +# To build host-ccache we need to call the bare compiler. With a standard
>> +# 'make', this is guaranteed because host-ccache is built as part of the
>> +# dependencies, and a target-specific variable sets HOSTCC/HOSTCXX to the
>> +# no-ccache version (see support/dependencies/dependencies.mk).
>> +# However, this is not the case when using 'make host-ccache'.
>> +HOST_CCACHE_CONF_ENV += CC=$(HOSTCC_NOCCACHE) CXX=$(HOSTCXX_NOCCACHE)
>
> Double quotes around the variable value?

Yes, indeed. Need to fix that in any case.

/Thomas
Thomas Petazzoni May 1, 2016, 8:20 p.m. UTC | #3
Hello,

On Sun, 1 May 2016 22:11:18 +0200, Thomas De Schampheleire wrote:

> > I think this means that the CC/CXX assignments in
> > support/dependencies/dependencies.mk are useless, no? If you do "make
> > clean host-tar", or "make clean host-xz" or "make clean host-sstrip",
> > it will fail the same way, no? Doesn't this mean that those "special"
> > package should be fixed to define CC=$(HOSTCC_NOCCACHE)
> > CXX=$(HOSTCXX_NOCCACHE) in their environment ?  
> 
> After some quick checking, it seems to depend which packages are in
> DEPENDENCIES_HOST_PREREQ: 'make clean host-foo' will fail if host-foo
> is in DEPENDENCIES_HOST_PREREQ but will succeed if it is not. This is
> because packages that all packages get 'dependencies' as dependency,
> except packages that are itself in DEPENDENCIES_HOST_PREREQ.
> 
> So, on my system, 'make clean host-xz' worked fine because I have a
> suitable xzcat already and hence host-xz is not put in
> DEPENDENCIES_HOST_PREREQ. Similar for host-tar. If I cheat and add
> host-xz in DEPENDENCIES_HOST_PREREQ unconditionally, 'make clean
> host-xz' indeed fails.
> 
> This difference depending on the host system also means that a
> solution where e.g. host-xz is changed to set CC and CXX to
> no-ccache-versions is suboptimal: in case host-xz is not in
> DEPENDENCIES_HOST_PREREQ, the package would be built without ccache
> even if it were available. One could argue that there's no need to
> build host-xz in this scenario, but I can imagine other packages that
> can be mandatory in some situations and optional in others.
> Maybe this is nothing to worry about and we should keep things simple:
> don't use ccache for host packages that are potentially a core
> dependency for buildroot.
> 
> What are your thoughts?

I think we should be simple, and indeed build those few packages always
without ccache. I don't think we have any package that depends on
"host-tar". Regarding host-xz, I'm not that sure, but it's a small
package, so building it without ccache is not a big deal.

Alternatively, we could try to make those packages depend on
host-ccache. But I'm really not sure it's worth it.

Thanks!

Thomas
diff mbox

Patch

diff --git a/package/ccache/ccache.mk b/package/ccache/ccache.mk
index c4f0310..ae369a6 100644
--- a/package/ccache/ccache.mk
+++ b/package/ccache/ccache.mk
@@ -21,6 +21,13 @@  CCACHE_LICENSE_FILES = LICENSE.txt GPL-3.0.txt
 # has zero dependency besides the C library.
 HOST_CCACHE_CONF_OPTS += --with-bundled-zlib
 
+# To build host-ccache we need to call the bare compiler. With a standard
+# 'make', this is guaranteed because host-ccache is built as part of the
+# dependencies, and a target-specific variable sets HOSTCC/HOSTCXX to the
+# no-ccache version (see support/dependencies/dependencies.mk).
+# However, this is not the case when using 'make host-ccache'.
+HOST_CCACHE_CONF_ENV += CC=$(HOSTCC_NOCCACHE) CXX=$(HOSTCXX_NOCCACHE)
+
 # Patch host-ccache as follows:
 #  - Use BR_CACHE_DIR instead of CCACHE_DIR, because CCACHE_DIR
 #    is already used by autotargets for the ccache package.