Bug 266310 - Mk/bsd.ccache.mk: Add CCACHE_ENABLED variable for ports' convenience
Summary: Mk/bsd.ccache.mk: Add CCACHE_ENABLED variable for ports' convenience
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Yuri Victorovich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-09 06:56 UTC by Yuri Victorovich
Modified: 2022-09-12 07:48 UTC (History)
3 users (show)

See Also:


Attachments
patch (1007 bytes, patch)
2022-09-09 06:56 UTC, Yuri Victorovich
no flags Details | Diff
patch (1.01 KB, patch)
2022-09-10 18:25 UTC, Yuri Victorovich
tcberner: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer freebsd_triage 2022-09-09 06:56:51 UTC
Created attachment 236447 [details]
patch

bsd.ccache.mk can disable ccache in some situations.
Ports should be able to know when ccache is enabled but there is no single variable for this.

I propose that bsd.ccache.mk would always set the variable CCACHE_ENABLED with values yes/no.

For example, cmake based ports would be able to pass it to cmake:
> CMAKE_ARGS+=-DUSE_CCACHE:BOOL=${CCACHE_ENABLED:tu}

Currently there is no easy way to do this.
Comment 1 Tobias C. Berner freebsd_committer freebsd_triage 2022-09-10 15:47:20 UTC
Moin moin

Why do you not simply set 
NO_CCACHE=yes
in the affected port?

mfg Tobias
Comment 2 Yuri Victorovich freebsd_committer freebsd_triage 2022-09-10 17:14:36 UTC
(In reply to Tobias C. Berner from comment #1)

Because they have special handling of ccache, and it is triggered by the presence of the ccache program, not by what the user has set in make.conf.

I don't want to disable it altogether, I just want the project to play along with ccache settings like all other ports do.
Comment 3 Yuri Victorovich freebsd_committer freebsd_triage 2022-09-10 17:16:19 UTC
This port would still use ccache, regardless of the settings.
It is nice to have a variable that just tells the port if ccache should be used or not.
Comment 4 Tobias C. Berner freebsd_committer freebsd_triage 2022-09-10 17:44:23 UTC
(In reply to Yuri Victorovich from comment #3)

You still could make use of it, I think, even without this change in the meantime, with something on the lines of:

CMAKE_ARGS+=-DUSE_CCACHE:BOOL=${NO_CCACHE:DNO:UYES}


I'll get back to you about the proposed change :)
Comment 5 Yuri Victorovich freebsd_committer freebsd_triage 2022-09-10 18:16:02 UTC
(In reply to Tobias C. Berner from comment #4)

Tobias,

This line
> CMAKE_ARGS+=-DUSE_CCACHE:BOOL=${NO_CCACHE:DNO:UYES}
doesn't evaluate to the same. When no ccache settings are present in make.conf it evaluates to YES instead of NO.

Also it is a lot less error-prone to have a single variable for all such ports to use.
Comment 6 Yuri Victorovich freebsd_committer freebsd_triage 2022-09-10 18:25:53 UTC
Created attachment 236481 [details]
patch

Update patch: move explanation to the correct section.
Comment 7 Yuri Victorovich freebsd_committer freebsd_triage 2022-09-11 16:44:18 UTC
Port that would benefit: graphics/filament

Here https://github.com/google/filament/blob/main/CMakeLists.txt#L68 it looks for the ccache program which causes deviation from the ports framework ccache setting.

The CCACHE_ENABLED value can be passed to cmake to limit ccache use to situations when ccache is enabled through the ports framework.

ccache is in general very useful since it improved productivity of work on C/C++ ports by caching previous compilation results.
Comment 8 Tobias C. Berner freebsd_committer freebsd_triage 2022-09-12 07:33:45 UTC
Comment on attachment 236481 [details]
patch

ship it :)
Comment 9 Yuri Victorovich freebsd_committer freebsd_triage 2022-09-12 07:47:56 UTC
(In reply to Tobias C. Berner from comment #8)

Thank you!

-----------------------------------


Committed.
Comment 10 commit-hook freebsd_committer freebsd_triage 2022-09-12 07:48:37 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=679b9e2f43675a36fa552404c770ab620a350fa1

commit 679b9e2f43675a36fa552404c770ab620a350fa1
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2022-09-12 07:41:44 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2022-09-12 07:47:54 +0000

    Mk/bsd.ccache.mk: Add CCACHE_ENABLED variable for ports' convenience

    Some projects do some special handling when the ccache program is present.
    This causes problems because ports framework has its own ccache settings
    and mere presence of ccache program doesn't mean that ccache is enabled.
    The new CCACHE_ENABLED variable can be used to tell projects if ccache
    is really enabled.

    PR:             266310
    Approved by:    tcberner@ (as portmgr)

 Mk/bsd.ccache.mk | 8 ++++++++
 1 file changed, 8 insertions(+)