Bug 224471 - bsd.gecko.mk: add conditional for ccache
Summary: bsd.gecko.mk: add conditional for ccache
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-gecko (Nobody)
URL: https://reviews.freebsd.org/D14154
Keywords: performance
: 232183 249338 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-12-20 01:00 UTC by Charlie Li
Modified: 2024-04-17 17:30 UTC (History)
13 users (show)

See Also:


Attachments
bsd.gecko.mk.patch (515 bytes, patch)
2017-12-20 01:00 UTC, Charlie Li
no flags Details | Diff
Add --with-cache=${CCACHE_BIN:Q} to MOZ_OPTIONS, when WITH_CCACHE_BUILD is defined (527 bytes, patch)
2020-04-04 13:59 UTC, Mikhail Teterin
no flags Details | Diff
Base the decision on whether to use ccache on ${CCACHE_BIN} being not-empty (506 bytes, patch)
2020-04-04 14:41 UTC, Mikhail Teterin
no flags Details | Diff
v1 (1.01 KB, patch)
2023-09-26 13:28 UTC, Anton Saietskii
vsasjason: maintainer-approval?
Details | Diff
poudriere build logs (280.02 KB, application/x-xz)
2023-09-26 13:30 UTC, Anton Saietskii
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Charlie Li freebsd_committer freebsd_triage 2017-12-20 01:00:00 UTC
Created attachment 188982 [details]
bsd.gecko.mk.patch

On systems with WITH_CCACHE_BUILD enabled, the Mozilla build system still ignores the presence of ccache, as the C and C++ compilers are executed with an explicit path to /usr/bin. This method of execution prevents any caching of C and C++ objects as intended by ccache.

This patch adds a conditional to allow use of ccache where available, through the --with-ccache flag present in the Mozilla build system's configure script.
Comment 1 Charlie Li freebsd_committer freebsd_triage 2018-10-11 20:33:51 UTC
Comment on attachment 188982 [details]
bsd.gecko.mk.patch

review D14154 updated with new patch. Prompted by competing proposal bug 232183.
Comment 2 Nuno Teixeira freebsd_committer freebsd_triage 2018-11-23 09:08:44 UTC
I've tested both patches on FreeBSD 11.2 RELEASE, poudriere 3.2.8, ports current:

- removing absolute pathnames does't work, ccache not called

- using --with-ccache works, cccache caches ok.

Conclusion:

To have ccache working within poudriere, we just need patch:

.if ${WITH_CCACHE_BUILD}
MOZ_OPTIONS+=     --with-ccache
.endif.

I not tested build outside poudriere.
Comment 3 Charlie Li freebsd_committer freebsd_triage 2018-11-23 15:29:50 UTC
(In reply to Nuno Teixeira from comment #2)
> .if ${WITH_CCACHE_BUILD}
This syntax breaks dialog4ports. Thus, .if defined(WITH_CCACHE_BUILD).

Additionally, in poudriere with static ccache, where ccache lives in a different /ccache hierarchy that is not in $PATH, a build dependency on devel/ccache needs added for now. I'll update the phabricator review.
Comment 4 Nuno Teixeira freebsd_committer freebsd_triage 2018-11-24 01:53:09 UTC
${WITH_CCACHE_BUILD} breaks dialog4ports but activates MOZ_OPTIONS: --with-ccache

with defined{WITH_CCACHE_BUILD} unbreaks dialog4ports but --with-ccache is not included in build configure.

maybe better to change Makefile port instead of bsd.gecko.mk?
Comment 5 Charlie Li freebsd_committer freebsd_triage 2018-11-24 02:02:41 UTC
(In reply to Nuno Teixeira from comment #4)
> defined{WITH_CCACHE_BUILD}
Curly brackets in defined() is incorrect syntax. Please read/understand the patch again.

Everything living at the root of either comm-* (Thunderbird, SeaMonkey) or mozilla-* (Firefox) use the same complex build system, so inserting logic like this into individual port Makefiles is redundant.
Comment 6 Nuno Teixeira freebsd_committer freebsd_triage 2018-11-24 09:00:55 UTC
oops! My fault using wrong syntax.

I applied patch correctly and everything is working perfectly.

Very nice build results on a old Asus ROG G50V in poudriere using 2 cores for a single build of firefox:

02h40m 1st time build with ccache

00h40m build using ccache

:)
Comment 7 Nuno Teixeira freebsd_committer freebsd_triage 2018-11-24 09:04:59 UTC
correction:

*02h25m* 1st time build with ccache

00h40m build using ccache
Comment 8 Walter Schwarzenfeld freebsd_triage 2019-08-16 14:49:10 UTC

*** This bug has been marked as a duplicate of bug 232183 ***
Comment 9 Walter Schwarzenfeld freebsd_triage 2019-08-16 15:40:51 UTC
Wrong PR.
Comment 10 Walter Schwarzenfeld freebsd_triage 2019-08-16 15:41:34 UTC
*** Bug 232183 has been marked as a duplicate of this bug. ***
Comment 11 Walter Schwarzenfeld freebsd_triage 2019-08-16 17:38:41 UTC
See

https://reviews.freebsd.org/D14154
Comment 12 Baptiste Daroussin freebsd_committer freebsd_triage 2019-09-05 13:58:32 UTC
This is not for portmgr, more to gecko@
Comment 13 Mikhail Teterin freebsd_committer freebsd_triage 2020-04-04 13:59:03 UTC
Created attachment 213057 [details]
Add --with-cache=${CCACHE_BIN:Q} to MOZ_OPTIONS, when WITH_CCACHE_BUILD is defined

Instructions from:

https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/ccache
Comment 14 Mikhail Teterin freebsd_committer freebsd_triage 2020-04-04 14:41:28 UTC
Created attachment 213059 [details]
Base the decision on whether to use ccache on ${CCACHE_BIN} being not-empty

This variant leaves the logic on whether to enable ccache to bsd.ccache.mk, which sets CCACHE_BIN as appropriate.
Comment 15 Matthias Andree freebsd_committer freebsd_triage 2020-09-15 16:02:17 UTC
*** Bug 249338 has been marked as a duplicate of this bug. ***
Comment 16 Graham Perrin freebsd_committer freebsd_triage 2023-04-23 12:33:50 UTC
I'll bump things in Phabricator.
Comment 17 Anton Saietskii 2023-09-04 14:04:03 UTC
First of all I need to say that I'm building Firefox on a potato-laptop with 2C Merom CPU & 3G RAM. Been struggling with Rust, but finally maganed to make everything build correctly.
It takes 6-7 hours, so I manually added following lines to bsd.gecko.mk:

.if defined(WITH_CCACHE_BUILD) !defined(NO_CCACHE)
MOZ_OPTIONS+=   --with-ccache
.endif

2nd rebuild after that took only 1 hour. (I'll upload poudriere build logs by request.)

Can we please, please get this finally landed in ports tree?
(Yes, simply adding "--with-ccache" doesn't cover poudriere's static ccache from host, but anyway we can already enable basic setup and work on advanced one later. Right now ccache doesn't work at all.)
Comment 18 Anton Saietskii 2023-09-04 14:06:21 UTC
(In reply to Anton Saietskii from comment #17)

Typo in conditional, here's correct one:
.if defined(WITH_CCACHE_BUILD) && !defined(NO_CCACHE)
Comment 19 Anton Saietskii 2023-09-26 13:28:51 UTC
Created attachment 245253 [details]
v1

Simple patch I'm using to make ccache work.
Comment 20 Anton Saietskii 2023-09-26 13:30:56 UTC
Created attachment 245255 [details]
poudriere build logs

First and second builds of firefox in poudriere.

==> /usr/local/poudriere/data/logs/bulk/releng132-default/2023-09-19_19h13m58s/logs/firefox-118.0,2.log <==
build of www/firefox | firefox-118.0,2 ended at Wed Sep 20 05:15:01 EEST 2023
build time: 07:44:00

==> /usr/local/poudriere/data/logs/bulk/releng132-default/2023-09-21_13h13m28s/logs/firefox-118.0,2.log <==
build of www/firefox | firefox-118.0,2 ended at Thu Sep 21 14:51:48 EEST 2023
build time: 01:32:04
Comment 21 Denis Shaposhnikov 2024-04-17 13:53:11 UTC
Hi,

my temporary (I hope it is temporary) solution is using custom bsd.overlay.mk:

.if !defined(_DSH_OVERLAY_INCLUDED)
_DSH_OVERLAY_INCLUDED=	yes

.if defined(WITH_CCACHE_BUILD) && !defined(NO_CCACHE)
# From bsd.ccache.mk, because it isn't included yet. The system includes
# bsd.ccache.mk after bsd.overlay.mk.
.  if defined(CCACHE_WRAPPER_PATH)
CCACHE_PKG_PREFIX=	${CCACHE_WRAPPER_PATH:C,/libexec/ccache$,,}
.  endif
CCACHE_PKG_PREFIX?=	${LOCALBASE}
CCACHE_WRAPPER_PATH?=	${CCACHE_PKG_PREFIX}/libexec/ccache
CCACHE_BIN?=		${CCACHE_PKG_PREFIX}/bin/ccache

.  if ${.CURDIR:M*/www/firefox}
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224471
MOZ_OPTIONS+=	--with-ccache="${CCACHE_BIN}"
.  endif
.endif # defined(WITH_CCACHE_BUILD) && !defined(NO_CCACHE)

.endif # !defined(_DSH_OVERLAY_INCLUDED)

and build it using poudriere with my own overlay ports tree.
Comment 22 Anton Saietskii 2024-04-17 14:02:10 UTC
(In reply to Denis Shaposhnikov from comment #21)

Looks to me a bit too complicated in comparison to 'v1' from comment #19. I believe we just need that, which will fix all gecko ports at once.
Comment 23 Denis Shaposhnikov 2024-04-17 17:30:31 UTC
(In reply to Anton Saietskii from comment #22)
I agree, but v1 was proposed 6 month ago and is still not commited and my temporary workaround available right now. I posted it for anybody, who needs this workaround right now, like me.