Bug 284893 - Fix ccache for ports that have USES=llvm and USES=cmake
Summary: Fix ccache for ports that have USES=llvm and USES=cmake
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: 2025-02-19 06:28 UTC by Yuri Victorovich
Modified: 2025-03-23 07:56 UTC (History)
6 users (show)

See Also:


Attachments
patch (527 bytes, patch)
2025-02-19 06:28 UTC, Yuri Victorovich
no flags 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 2025-02-19 06:28:21 UTC
Created attachment 257644 [details]
patch

Currently ccache doesn't work when USES contains both llvm and cmake.

The reason that ccache works without USES=llvm is that CXX=c++ in such case and bsd.ccache.mk adds the directory with ccache-provided c++ into PATH.

USES=llvm causes CXX to have the full path to the compiler executable, and the PATH method doesn't work.

The attached patch adds ccache to cmake launchers when USES=llvm which fixes ccache in these cases.
Comment 1 Rene Ladan freebsd_committer freebsd_triage 2025-03-06 17:13:46 UTC
Adding kde@ as they maintain cmake and can perhaps chime in too.
Comment 2 Baptiste Daroussin freebsd_committer freebsd_triage 2025-03-21 14:20:10 UTC
ok if ccmake people are ok with it.
Comment 3 Max Brazhnikov freebsd_committer freebsd_triage 2025-03-21 18:03:56 UTC
(In reply to Yuri Victorovich from comment #0)
If the problem is not specific to USES=llvm, shall we enable compiler launcher unconditionally when ccache is used?

Is there other need to set CMAKE_C_COMPILER_LAUNCHER? If yes, we should allow user to override it.
Comment 4 Yuri Victorovich freebsd_committer freebsd_triage 2025-03-22 07:50:01 UTC
(In reply to Max Brazhnikov from comment #3)

> If the problem is not specific to USES=llvm, shall we enable compiler launcher unconditionally when ccache is used?

ccache only supports C/C++ compilers.
C/C++ compilers come from (1) base, (2) llvm, (3) gcc.

The case (1) base is already works through the links in /usr/local/libexec/ccache.
This patch solves it for (2) llvm.
The case (3) gcc is also already works through the links in /usr/local/libexec/ccache.

I am not aware of any other C/C++ compilers used on FreeBSD.
Comment 5 Yuri Victorovich freebsd_committer freebsd_triage 2025-03-22 07:52:17 UTC
(In reply to Max Brazhnikov from comment #3)

> Is there other need to set CMAKE_C_COMPILER_LAUNCHER? If yes, we should allow user to override it.

This appears to be outside of the scope of the issue that this patch solves.
Comment 6 Yuri Victorovich freebsd_committer freebsd_triage 2025-03-23 07:56:33 UTC
Committed.
Comment 7 commit-hook freebsd_committer freebsd_triage 2025-03-23 07:56:49 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=56538adacf53391307f687155be3fc787a95f40b

commit 56538adacf53391307f687155be3fc787a95f40b
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2025-03-23 05:09:17 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2025-03-23 07:56:12 +0000

    Mk/bsd.ccache.mk: Fix ccache for ports that have USES=llvm and USES=cmake

    PR:             284893
    Approved by:    Rene Ladan <rene@FreeBSD.org> (on behalf of portmgr@)

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