Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Feb 2011 17:18:56 GMT
From:      Alberto Villa <avilla@FreeBSD.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/155008: [patch] devel/ccache - support other world compilers
Message-ID:  <201102241718.p1OHIu51042533@red.freebsd.org>
Resent-Message-ID: <201102241720.p1OHK3dP008466@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         155008
>Category:       ports
>Synopsis:       [patch] devel/ccache - support other world compilers
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 24 17:20:03 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Alberto Villa
>Release:        FreeBSD 9.0-CURRENT
>Organization:
>Environment:
FreeBSD echo.hoth 9.0-CURRENT FreeBSD 9.0-CURRENT #4 r216495: Fri Dec 17 02:39:21 CET 2010     root@echo.hoth:/usr/obj/usr/src/sys/HPDV6  amd64
>Description:
the attached patch allows ccache to use non-default compilers 
(especially clang, as it's the only one which will actually work) to build 
world and kernel

it also updates documentation with the new instructions, and replaces 
libtool15 with libtool

a couple of notes:
- the clang warnings about unused arguments are really harmless. read 
more here: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-
June/009539.html
- i replaced world-* with world/* (this would obviously require a note in 
UPDATING) because of this (/sys/boot/i386/boot2/Makefile and others):
CC:=${CC:C/^(.*\/)?clang$/gcc/1}
world-clang wouldn't be replaced with world-gcc, while ${PREFIX}/libexec/ccache/world/clang is 
successfully changed to gcc. in addition, this allows to have only 
one script (world/ccache), and just create links to it (like world/clang, 
world/llvm-gcc...)
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

Index: Makefile
===================================================================
RCS file: /home/pcvs/ports/devel/ccache/Makefile,v
retrieving revision 1.58
diff -u -r1.58 Makefile
--- Makefile	10 Jan 2011 16:44:24 -0000	1.58
+++ Makefile	24 Feb 2011 17:12:42 -0000
@@ -7,6 +7,7 @@
 
 PORTNAME=	ccache
 PORTVERSION=	3.1.4
+PORTREVISION=	1
 CATEGORIES=	devel
 MASTER_SITES=	http://samba.org/ftp/ccache/ CRITICAL
 
@@ -26,7 +27,7 @@
 .if !defined(WITHOUT_COMPILER_LINKS)
 HOWTO=		ccache-howto-freebsd.txt
 CCLINKDIR=	libexec/ccache
-PLIST_DIRS=	${CCLINKDIR}
+PLIST_DIRS=	${CCLINKDIR}/world ${CCLINKDIR}
 SUB_FILES=	${HOWTO} pkg-message
 .endif
 
@@ -42,10 +43,10 @@
 .if defined(EXTRA_COMPILERS)
 CCACHE_COMPILERS+=	${EXTRA_COMPILERS}
 .endif
-WORLD_COMPILERS=	world-cc world-c++
 PLIST_FILES+=	${CCACHE_COMPILERS:S|^|${CCLINKDIR}/|} \
-		${WORLD_COMPILERS:S|^|${CCLINKDIR}/|}
-SUB_FILES+=	${WORLD_COMPILERS}
+		${CCACHE_COMPILERS:S|^|${CCLINKDIR}/world/|} \
+		${CCLINKDIR}/world/ccache
+SUB_FILES+=	world-ccache
 SUB_LIST+=	CCACHE_COMPILERS="${CCACHE_COMPILERS}" \
 		CCLINKDIR="${CCLINKDIR}" \
 		ICCPREFIX="${LOCALBASE}/intel_cc_80/bin" \
@@ -69,12 +70,11 @@
 	${INSTALL_PROGRAM} ${WRKSRC}/ccache ${PREFIX}/bin
 	${INSTALL_MAN} ${WRKSRC}/${MAN1} ${PREFIX}/man/man1
 .if !defined(WITHOUT_COMPILER_LINKS)
-	@${MKDIR} ${PREFIX}/${CCLINKDIR}
+	@${MKDIR} ${PREFIX}/${CCLINKDIR}/world
+	${INSTALL_SCRIPT} ${WRKDIR}/world-ccache ${PREFIX}/${CCLINKDIR}/world/ccache
 .for link in ${CCACHE_COMPILERS}
 	${LN} -sf ${PREFIX}/bin/ccache ${PREFIX}/${CCLINKDIR}/${link}
-.endfor
-.for script in ${WORLD_COMPILERS}
-	${INSTALL_SCRIPT} ${WRKDIR}/${script} ${PREFIX}/${CCLINKDIR}
+	${LN} -sf ccache ${PREFIX}/${CCLINKDIR}/world/${link}
 .endfor
 .endif
 .if !defined(NOPORTDOCS)
Index: files/ccache-howto-freebsd.txt.in
===================================================================
RCS file: /home/pcvs/ports/devel/ccache/files/ccache-howto-freebsd.txt.in,v
retrieving revision 1.13
diff -u -r1.13 ccache-howto-freebsd.txt.in
--- files/ccache-howto-freebsd.txt.in	17 Nov 2010 18:41:35 -0000	1.13
+++ files/ccache-howto-freebsd.txt.in	24 Feb 2011 17:12:42 -0000
@@ -2,12 +2,14 @@
 # $FreeBSD: ports/devel/ccache/files/ccache-howto-freebsd.txt.in,v 1.13 2010/11/17 18:41:35 ehaupt Exp $
 #
 
-To use ccache add the following to /etc/make.conf
+To use ccache add the following to /etc/make.conf.
+You can replace cc and c++ with the compilers of your choice.
+(remember that only GCC and Clang can build world and kernel)
 
 .if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*))
 .if !defined(NOCCACHE)
-CC:=${CC:C,^cc,%%PREFIX%%/%%CCLINKDIR%%/world-cc,1}
-CXX:=${CXX:C,^c\+\+,%%PREFIX%%/%%CCLINKDIR%%/world-c++,1}
+CC:=${CC:C,^cc,%%PREFIX%%/%%CCLINKDIR%%/world/cc,1}
+CXX:=${CXX:C,^c\+\+,%%PREFIX%%/%%CCLINKDIR%%/world/c++,1}
 .endif
 .endif
 
@@ -47,18 +49,25 @@
 Ccache has installed links for the following compilers
 %%CCACHE_COMPILERS%%
 in %%PREFIX%%/%%CCLINKDIR%%
+and %%PREFIX%%/%%CCLINKDIR%%/world
+
+Clang will return a lot of 'unused argument' warnings: they are harmless.
+Just add this to /etc/make.conf if you want to hide them:
+.if ${CC:T} == "clang"
+CFLAGS+=	-Qunused-arguments
+.endif
 
 !!! WARNING !!!
 Please make sure you have the compiler installed before you do this or your
 build will fail because it will not be able to find the compiler.
 
-Any time you change CC/CXX you need to reinstall devel/libtool15 or you 
+Any time you change CC/CXX you need to reinstall devel/libtool or you
 will run in to problems.
 
 --
 
 Ccache's default cache size is 1GB and this is larger than the default size of
-the root partition (/) on FreeBSD. To over come this you may specify a new 
+the root partition (/) on FreeBSD. To over come this you may specify a new
 cache location on a different partition with the following examples.
 
 For Korn/Bourne shells Add the following to /etc/profile:
Index: files/world-c++.in
===================================================================
RCS file: files/world-c++.in
diff -N files/world-c++.in
--- files/world-c++.in	31 Jul 2010 10:48:26 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,4 +0,0 @@
-#!/bin/sh
-unset CCACHE_PATH
-export CCACHE_COMPILERCHECK=content
-exec %%PREFIX%%/%%CCLINKDIR%%/c++ "$@"
Index: files/world-cc.in
===================================================================
RCS file: files/world-cc.in
diff -N files/world-cc.in
--- files/world-cc.in	31 Jul 2010 10:48:26 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,4 +0,0 @@
-#!/bin/sh
-unset CCACHE_PATH
-export CCACHE_COMPILERCHECK=content
-exec %%PREFIX%%/%%CCLINKDIR%%/cc "$@"
Index: files/world-ccache.in
===================================================================
RCS file: files/world-ccache.in
diff -N files/world-ccache.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/world-ccache.in	24 Feb 2011 17:12:42 -0000
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+[ "${0##*/}" = "ccache" ] &&
+printf "Please, use one of the compiler links in\n%%PREFIX%%/%%CCLINKDIR%%/world\nto invoke ccache\n" >&2 &&
+exit 1
+
+unset CCACHE_PATH
+export CCACHE_COMPILERCHECK=content
+exec %%PREFIX%%/%%CCLINKDIR%%/${0##*/} "$@"


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102241718.p1OHIu51042533>