Bug 169579 - [bsd.port.mk] [exp-run] ccache support for building ports
Summary: [bsd.port.mk] [exp-run] ccache support for building ports
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Beat Gaetzi
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-01 17:30 UTC by Bryan Drewery
Modified: 2012-08-30 16:40 UTC (History)
1 user (show)

See Also:


Attachments
patch-ccache.txt (1.11 KB, patch)
2012-07-01 17:30 UTC, Bryan Drewery
no flags Details | Diff
patch-ccache2.txt (1.13 KB, patch)
2012-07-01 18:02 UTC, Bryan Drewery
no flags Details | Diff
patch-bsd.port.mk-ccache.txt (1.12 KB, patch)
2012-08-04 02:00 UTC, Bryan Drewery
no flags Details | Diff
patch-ccache3.txt (995 bytes, patch)
2012-08-20 15:28 UTC, Bryan Drewery
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bryan Drewery 2012-07-01 17:30:08 UTC
	This patch adds ccache support to ports (off by default). Other patches have changed $CC to use ccache, which results in having a space in $CC. This breaks many ports such as boost and libtool ports.
	This patch however utilizes the symlinks in /usr/local/libexec/ccache/world/{cc,gcc,etc...} by prepending that directory into $PATH in the $MAKE_ENV.
	Using this method, I have seen 0 failures, compared to the $CC method which results in many build failures and requiring to define which ports do not support ccache.

	To enable: Define WANT_CCACHE= in /etc/make.conf
	The cache directory CCACHE_DIR defaults to /usr/obj/ccache
	Defining NO_CCACHE can disable ccache support in make.conf or in a port. This is mostly to allow compatibility with current setups utilizing NO_CCACHE.
	If $CC already contains ccache, the support is disabled in case of custom setup.

	Users can override other ccache env variables [1] by using MAKE_ENV+= in their make.conf. Such as:
	MAKE_ENV+= CCACHE_LOGFILE=/var/log/ccache.log

	To use ccache(1) from the command line to configure the size or view stats: CCACHE_DIR=/usr/obj/ccache ccache -s

	[1] https://ccache.samba.org/manual.html#_environment_variables
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2012-07-01 17:30:25 UTC
Responsible Changed
From-To: freebsd-ports-bugs->portmgr

bsd.port.mk is portmgr territory (via the GNATS Auto Assign Tool)
Comment 2 Chris Rees freebsd_committer freebsd_triage 2012-07-01 17:51:11 UTC
We should not be using WANT_ in make.conf; this is a port Makefile variable.

Use WITH_CCACHE_BUILD or similar.

Chris
Comment 3 Bryan Drewery 2012-07-01 18:02:09 UTC
I wasn't 100% sure on that. Thanks for the input. Here's an updated patch.

-- 
Regards,
Bryan Drewery
bdrewery@freenode/EFNet
Comment 4 Bryan Drewery 2012-08-04 02:00:34 UTC
Updated to not use "world" ccache. Suggested by avilla.
Comment 5 Beat Gaetzi freebsd_committer freebsd_triage 2012-08-12 10:54:00 UTC
Responsible Changed
From-To: portmgr->beat

Take for exp-run.
Comment 6 Bryan Drewery freebsd_committer freebsd_triage 2012-08-20 15:28:15 UTC
After discussion on ports@, removing CCACHE_DIR to stick with ccache's
default of $HOME/.ccache, which will allow non-root building and utilize
a larger partition by default without stepping on hier(7) issues.

The user can override in /etc/make.conf:

MAKE_ENV+= CCACHE_DIR=/var/cache/ccache
Comment 7 dfilter service freebsd_committer freebsd_triage 2012-08-30 16:31:39 UTC
Author: beat
Date: Thu Aug 30 15:31:25 2012
New Revision: 303381
URL: http://svn.freebsd.org/changeset/ports/303381

Log:
  - Add ccache support for building ports. [1]
  - Fix CONFIGURE_FAIL_MESSAGE to be pkgng-aware. [2]
  - Resolve symlinks in PREFIX on deinstall. [3]
  - Introduce CLEAN_FETCH_ENV variable to disable package dependency
    in fetch target for mass fetching. [4]
  
  PR:		ports/169579 [1], ports/170552 [2],
  		ports/170784 [3], ports/170796 [4]
  Submitted by:	bdrewery@ [1], crees@ [2], gahr@ [3], ohauer@ [4]
  Tested on:	pointyhat

Modified:
  head/CHANGES
  head/Mk/bsd.port.mk

Modified: head/CHANGES
==============================================================================
--- head/CHANGES	Thu Aug 30 15:17:20 2012	(r303380)
+++ head/CHANGES	Thu Aug 30 15:31:25 2012	(r303381)
@@ -10,6 +10,22 @@ in the release notes and/or placed into 
 
 All ports committers are allowed to commit to this file.
 
+20120830:
+AUTHOR: beat@FreeBSD.org
+
+  * CCACHE support for building ports has been added (depends on
+    devel/ccache). Therefore new user settable variables are available:
+
+    WITH_CCACHE_BUILD - Enable CCACHE support (Default off)
+
+    NO_CCACHE         - Disable CCACHE support for example for certain
+                        ports if CCACHE is enabled.
+
+    By default CCACHE uses $HOME/.ccache as cache directory. To use
+    a non-default cache directory this could be overwritten like:
+
+    MAKE_ENV+= CCACHE_DIR=/var/cache/ccache
+
 20120820:
 AUTHOR: gahr@FreeBSD.org
 

Modified: head/Mk/bsd.port.mk
==============================================================================
--- head/Mk/bsd.port.mk	Thu Aug 30 15:17:20 2012	(r303380)
+++ head/Mk/bsd.port.mk	Thu Aug 30 15:31:25 2012	(r303381)
@@ -833,6 +833,9 @@ FreeBSD_MAINTAINER=	portmgr@FreeBSD.org
 #				  Default: none
 # FETCH_REGET	- Times to retry fetching of files on checksum errors.
 #				  Default: 1
+# CLEAN_FETCH_ENV		
+#				- Disable package dependency in fetch target for mass
+#				  fetching.  User settable.
 #
 # For extract:
 #
@@ -934,6 +937,13 @@ FreeBSD_MAINTAINER=	portmgr@FreeBSD.org
 #				  that are explicitly marked MAKE_JOBS_UNSAFE.  User settable.
 # MAKE_JOBS_NUMBER
 #				- Override the number of make jobs to be used.  User settable.
+## cacche
+#
+# WITH_CCACHE_BUILD
+# 				- Enable CCACHE support (devel/ccache).  User settable.
+# NO_CCACHE
+#				- Disable CCACHE support for example for certain ports if
+#				  CCACHE is enabled.  User settable.
 #
 # For install:
 #
@@ -1626,9 +1636,11 @@ PLIST_SUB+=	LIB32DIR=${LIB32DIR}
 
 .if defined(WITH_PKGNG)
 .if !defined(PKG_DEPENDS)
+.if !defined(CLEAN_FETCH_ENV)
 PKG_DEPENDS+=		${LOCALBASE}/sbin/pkg:${PORTSDIR}/ports-mgmt/pkg
 .endif
 .endif
+.endif
 
 .if defined(USE_ZIP)
 EXTRACT_DEPENDS+=	${LOCALBASE}/bin/unzip:${PORTSDIR}/archivers/unzip
@@ -2217,6 +2229,19 @@ BUILD_FAIL_MESSAGE+=	"You have chosen to
 .endif
 .endif
 
+# ccache support
+# Support NO_CCACHE for common setups, require WITH_CCACHE_BUILD, and
+# don't use if ccache already set in CC
+.if !defined(NO_CCACHE) && defined(WITH_CCACHE_BUILD) && !${CC:M*ccache*}
+# Avoid depends loops between pkg and ccache
+.	if !${.CURDIR:M*/devel/ccache} && !${.CURDIR:M*/ports-mgmt/pkg}
+BUILD_DEPENDS+=		${LOCALBASE}/bin/ccache:${PORTSDIR}/devel/ccache
+.	endif
+
+# Prepend the ccache dir into the PATH and setup ccache env
+MAKE_ENV+=	PATH=${LOCALBASE}/libexec/ccache:${PATH}
+.endif
+
 PTHREAD_CFLAGS?=
 PTHREAD_LIBS?=		-pthread
 
@@ -2908,7 +2933,7 @@ CONFIGURE_TARGET:=	${CONFIGURE_TARGET:S/
 CONFIGURE_LOG?=		config.log
 
 # A default message to print if do-configure fails.
-CONFIGURE_FAIL_MESSAGE?=	"Please report the problem to ${MAINTAINER} [maintainer] and attach the \"${CONFIGURE_WRKSRC}/${CONFIGURE_LOG}\" including the output of the failure of your make command. Also, it might be a good idea to provide an overview of all packages installed on your system (e.g. an \`ls ${PKG_DBDIR}\`)."
+CONFIGURE_FAIL_MESSAGE?=	"Please report the problem to ${MAINTAINER} [maintainer] and attach the \"${CONFIGURE_WRKSRC}/${CONFIGURE_LOG}\" including the output of the failure of your make command. Also, it might be a good idea to provide an overview of all packages installed on your system (e.g. a ${PKG_INFO} -Ea)."
 
 .if defined(GNU_CONFIGURE)
 # Maximum command line length
@@ -4474,7 +4499,7 @@ deinstall:
 			check_name=`${ECHO_CMD} $${p} | ${SED} -e 's/-[^-]*$$//'`; \
 			if [ "$${check_name}" = "${PKGBASE}" ]; then \
 					prfx=`${PKG_INFO} -q -p $${p} 2> /dev/null | ${SED} -ne '1s|^@cwd ||p'`; \
-					if [ "x${PREFIX}" = "x$${prfx}" ]; then \
+					if [ "x`${READLINK_CMD} -f ${PREFIX}`" = "x$${prfx}" ]; then \
 							${ECHO_MSG} "===>   Deinstalling $${p}"; \
 							${PKG_DELETE} -f $${p}; \
 					else \
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 8 Beat Gaetzi freebsd_committer freebsd_triage 2012-08-30 16:33:32 UTC
State Changed
From-To: open->closed

Committed. Thanks!