Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Mar 2023 21:07:12 GMT
From:      Kurt Jaeger <pi@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 61e5c612e7f1 - main - devel/ccache4: new port
Message-ID:  <202303132107.32DL7CL7050806@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by pi:

URL: https://cgit.FreeBSD.org/ports/commit/?id=61e5c612e7f14178fec95fd56dcbf2b6b9fce5d4

commit 61e5c612e7f14178fec95fd56dcbf2b6b9fce5d4
Author:     Oleg Sidorkin <osidorkin@gmail.com>
AuthorDate: 2023-03-13 21:04:41 +0000
Commit:     Kurt Jaeger <pi@FreeBSD.org>
CommitDate: 2023-03-13 21:04:41 +0000

    devel/ccache4: new port
    
    ccache is a compiler cache.  It acts as a caching pre-processor to C/C++
    compilers, using the -E compiler switch and a hash to detect when a
    compilation can be satisfied from cache.  This often results in a 5 to 10
    times speedup in common compilations.
    
    PR:             234971
    Approved by:    bdrewery
    Author:    Oleg Sidorkin <osidorkin@gmail.com>
---
 devel/Makefile                                |   1 +
 devel/ccache/Makefile                         |   2 +-
 devel/ccache4/Makefile                        | 101 ++++++++++++++++++++++++++
 devel/ccache4/distinfo                        |   3 +
 devel/ccache4/files/ccache-update-links.sh.in |  72 ++++++++++++++++++
 devel/ccache4/files/ccache_clean.in           |  71 ++++++++++++++++++
 devel/ccache4/files/pkg-message.in            |  10 +++
 devel/ccache4/files/world-ccache.in           |   9 +++
 devel/ccache4/pkg-descr                       |   4 +
 devel/ccache4/pkg-plist                       |   9 +++
 10 files changed, 281 insertions(+), 1 deletion(-)

diff --git a/devel/Makefile b/devel/Makefile
index 0f833ed637c3..0dbfaf4fb83b 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -339,6 +339,7 @@
     SUBDIR += ccache-memcached
     SUBDIR += ccache-memcached-static
     SUBDIR += ccache-static
+    SUBDIR += ccache4
     SUBDIR += cccc
     SUBDIR += ccdoc
     SUBDIR += ccls
diff --git a/devel/ccache/Makefile b/devel/ccache/Makefile
index 99c902e6399f..97ca1446269d 100644
--- a/devel/ccache/Makefile
+++ b/devel/ccache/Makefile
@@ -12,7 +12,7 @@ WWW=		https://ccache.samba.org/
 LICENSE=	GPLv3+
 LICENSE_FILE=	${WRKSRC}/GPL-3.0.txt
 
-CONFLICTS_INSTALL?=	ccache-static ccache-memcached ccache-memcached-static
+CONFLICTS_INSTALL?=	ccache-static ccache-memcached ccache-memcached-static ccache4
 
 GNU_CONFIGURE=	yes
 
diff --git a/devel/ccache4/Makefile b/devel/ccache4/Makefile
new file mode 100644
index 000000000000..f1dadfa4a86d
--- /dev/null
+++ b/devel/ccache4/Makefile
@@ -0,0 +1,101 @@
+PORTNAME=	ccache
+PORTVERSION=	4.8
+DISTVERSIONPREFIX=	v
+CATEGORIES=	devel
+PKGNAMESUFFIX=	4
+
+MAINTAINER=	bdrewery@FreeBSD.org
+COMMENT=	Tool to minimize the compile time of C/C++ programs
+WWW=		https://ccache.dev/
+
+LICENSE=	GPLv3+
+LICENSE_FILE=	${WRKSRC}/GPL-3.0.txt
+
+USES=		cmake:noninja pathfix shebangfix compiler:c++11-lang
+CONFLICTS_INSTALL?=	ccache ccache-static \
+		ccache-memcached ccache-memcached-static
+
+PORTDOCS=	AUTHORS.adoc AUTHORS.html MANUAL.html MANUAL.adoc \
+		NEWS.adoc NEWS.html
+
+USE_GITHUB=	yes
+SUB_FILES=	world-ccache ccache-update-links.sh ccache_clean
+# Prevent infinite recursion.
+NO_CCACHE_DEPEND=	yes
+
+LIB_DEPENDS+=	libzstd.so:archivers/zstd
+
+# /bin/bash -> /bin/sh to reduce tests dep.
+SHEBANG_FILES=	test/*
+SHEBANG_GLOB=	*.sh *.bash
+bash_CMD=	/bin/sh
+
+CMAKE_OFF=	WARNINGS_AS_ERRORS \
+		ENABLE_IPO \
+		ZSTD_FROM_INTERNET \
+		ENABLE_TRACING \
+		REDIS_STORAGE_BACKEND \
+		STATIC_LINK
+
+OPTIONS_DEFINE=	DOCS CLANGLINK LLVMLINK STATIC TEST
+OPTIONS_DEFAULT=CLANGLINK LLVMLINK
+OPTIONS_SUB=	yes
+
+DOCS_BUILD_DEPENDS=	asciidoctor:textproc/rubygem-asciidoctor
+DOCS_ALL_TARGET=	all doc
+DOCS_USES=		perl5
+DOCS_CMAKE_BOOL=	ENABLE_DOCUMENTATION
+
+CLANGLINK_DESC=	Create clang compiler links if clang is installed
+LLVMLINK_DESC=	Create llvm compiler links if llvm is installed
+
+STATIC_LDFLAGS=	-static
+
+TEST_CMAKE_BOOL=ENABLE_TESTING
+TEST_TARGET=	check
+
+.include <bsd.port.pre.mk>
+
+CCLINKDIR=		libexec/ccache
+PLIST_SUB+=		CCLINKDIR="${CCLINKDIR}"
+
+.if ${ARCH}=="i386"
+CCACHE_COMPILERS+=	icc icpc
+.endif
+
+GNU_COMPILERS+=		48 8 9 10 11 12
+CCACHE_COMPILERS+=	cc c++ CC gcc g++ ${GNU_COMPILERS:S|^|gcc|} \
+			${GNU_COMPILERS:S|^|g++|} \
+			${GNU_COMPILERS:S|^|cpp|}
+
+.if ${PORT_OPTIONS:MCLANGLINK}
+CLANG_COMPILERS+=	10 11 12 13 14 15 16 -devel
+CCACHE_COMPILERS+=	clang clang++ ${CLANG_COMPILERS:S|^|clang|} \
+			${CLANG_COMPILERS:S|^|clang++|} \
+			${CLANG_COMPILERS:S|^|cpp|}
+.endif
+
+.if ${PORT_OPTIONS:MLLVMLINK}
+CCACHE_COMPILERS+=	llvm-gcc llvm-c++ llvm-g++
+.endif
+
+CCACHE_COMPILERS+=	${EXTRA_COMPILERS}
+SUB_LIST+=		CCACHE_COMPILERS="${CCACHE_COMPILERS}" \
+			CCLINKDIR="${CCLINKDIR}"
+
+post-install:
+	${MKDIR} ${STAGEDIR}${PREFIX}/${CCLINKDIR}/world
+	${INSTALL_SCRIPT} ${WRKDIR}/world-ccache \
+		${STAGEDIR}${PREFIX}/${CCLINKDIR}/world/ccache
+	${INSTALL_SCRIPT} ${WRKDIR}/ccache-update-links.sh \
+		${STAGEDIR}${PREFIX}/bin/ccache-update-links
+	@${MKDIR} ${STAGEDIR}${PREFIX}/etc/periodic/daily
+	${INSTALL_SCRIPT} ${WRKDIR}/ccache_clean \
+		${STAGEDIR}${PREFIX}/etc/periodic/daily
+
+post-install-DOCS-on:
+	${MKDIR} ${STAGEDIR}${DOCSDIR}
+	${INSTALL_DATA} ${BUILD_WRKSRC}/doc/*.html ${STAGEDIR}${DOCSDIR}
+	${INSTALL_DATA} ${WRKSRC}/doc/*.adoc ${STAGEDIR}${DOCSDIR}
+
+.include <bsd.port.post.mk>
diff --git a/devel/ccache4/distinfo b/devel/ccache4/distinfo
new file mode 100644
index 000000000000..5b7926ccb96e
--- /dev/null
+++ b/devel/ccache4/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1678706114
+SHA256 (ccache-ccache-v4.8_GH0.tar.gz) = 47c9ff1668c9c6892b34642f9f09027f4a41e719dad1062f82265ff0087299ce
+SIZE (ccache-ccache-v4.8_GH0.tar.gz) = 767312
diff --git a/devel/ccache4/files/ccache-update-links.sh.in b/devel/ccache4/files/ccache-update-links.sh.in
new file mode 100644
index 000000000000..15bc180aef2d
--- /dev/null
+++ b/devel/ccache4/files/ccache-update-links.sh.in
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# Author: Emanuel Haupt <ehaupt@FreeBSD.org>
+#
+# $FreeBSD: head/devel/ccache/files/ccache-update-links.sh.in 435560 2017-03-06 17:50:14Z bdrewery $
+#
+
+CCACHE_COMPILERS="%%CCACHE_COMPILERS%% ${EXTRA_COMPILERS}"
+CCLINKDIR="%%CCLINKDIR%%"
+PREFIX="%%PREFIX%%"
+
+usage() {
+	cat << "EOUSAGE"
+Usage: ccache-update-links [hv]
+
+ccache-update-links maintains symlinks needed by ccache to work with additional
+compilers.
+
+    -h, --help   this help
+    -v           verbose
+
+EOUSAGE
+}
+
+case "$1"
+in
+	-h|--help)
+	usage
+	;;
+esac
+
+strip_path() {
+	local IFS=":"
+	local path
+	set -- ${PATH}
+	while [ $# -gt 0 ]; do
+		if ! [ "${1}" = "${PREFIX}/libexec/ccache" ]; then
+			path="${path}${path:+:}${1}"
+		fi
+		shift
+	done
+	echo "${path}"
+}
+
+# Remove ccache wrappers from PATH
+PATH=$(strip_path)
+
+# create compiler links
+for comp in ${CCACHE_COMPILERS}
+do
+	if command -v "${comp}" >/dev/null; then
+		if [ ! -L "${PREFIX}/${CCLINKDIR}/${comp}" ]; then
+			[ "$1" = "-v" ] && echo "create symlink for ${comp}"
+        		ln -sf ${PREFIX}/bin/ccache ${PREFIX}/${CCLINKDIR}/${comp}
+		fi
+
+		if [ ! -L "${PREFIX}/${CCLINKDIR}/world/${comp}" ]; then
+			[ "$1" = "-v" ] && echo "create symlink for ${comp} (world)"
+        		ln -sf ccache ${PREFIX}/${CCLINKDIR}/world/${comp}
+		fi
+	else
+		if [ -L "${PREFIX}/${CCLINKDIR}/${comp}" ]; then
+			[ "$1" = "-v" ] && echo "remove symlink for ${comp}"
+			rm -f ${PREFIX}/${CCLINKDIR}/${comp}
+		fi
+
+		if [ -L "${PREFIX}/${CCLINKDIR}/world/${comp}" ]; then
+			[ "$1" = "-v" ] && echo "remove symlink for ${comp} (world)"
+			rm -f ${PREFIX}/${CCLINKDIR}/world/${comp}
+		fi
+	fi
+done
diff --git a/devel/ccache4/files/ccache_clean.in b/devel/ccache4/files/ccache_clean.in
new file mode 100755
index 000000000000..c68d621bba64
--- /dev/null
+++ b/devel/ccache4/files/ccache_clean.in
@@ -0,0 +1,71 @@
+#!/bin/sh
+#
+# Copyright (c) 2020 Rozhuk Ivan <rozhuk.im@gmail.com>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+if [ -r /etc/defaults/periodic.conf ]; then
+	. /etc/defaults/periodic.conf
+	source_periodic_confs
+fi
+
+
+case "${daily_ccache_clean_enable:-YES}" in
+[Nn][Oo])
+	;;
+*)
+	SYS_CCACHE_DIR=`make -V CCACHE_DIR`
+	if [ -z "${SYS_CCACHE_DIR}" ]; then
+		SYS_CCACHE_DIR='/var/cache/ccache'
+	fi
+	if [ -d "${SYS_CCACHE_DIR}" ]; then
+		echo "ccache dir: ${SYS_CCACHE_DIR}"
+		env CCACHE_DIR="${SYS_CCACHE_DIR}" \
+			/usr/bin/nice -n 15 \
+				%%PREFIX%%/bin/ccache --cleanup
+	fi
+
+	_USERS_HOME_DIRS=`pw usershow -a | awk -F":" '{print $9}' | sort -u`
+	for _USER_HOME in ${_USERS_HOME_DIRS}; do
+		if [ -d "${_USER_HOME}/.ccache" ]; then
+			echo "ccache dir: ${_USER_HOME}/.ccache"
+			env CCACHE_DIR="${_USER_HOME}/.ccache" \
+				/usr/bin/nice -n 15 \
+					%%PREFIX%%/bin/ccache --cleanup
+		fi
+		if [ -d "${_USER_HOME}/.cache/ccache" ]; then
+			echo "ccache dir: ${_USER_HOME}/.cache/ccache"
+			env CCACHE_DIR="${_USER_HOME}/.cache/ccache" \
+			    CCACHE_CONFIGPATH="${_USER_HOME}/.config/ccache/ccache.conf" \
+				/usr/bin/nice -n 15 \
+					%%PREFIX%%/bin/ccache --cleanup
+		fi
+	done
+	;;
+esac
+
+
+exit 0
diff --git a/devel/ccache4/files/pkg-message.in b/devel/ccache4/files/pkg-message.in
new file mode 100644
index 000000000000..ce77e2104573
--- /dev/null
+++ b/devel/ccache4/files/pkg-message.in
@@ -0,0 +1,10 @@
+[
+{ type: install
+  message: <<EOM
+This version of ccache has large nubmer of dependencies and will cause
+warnings and errors due to dependency loops when used with ports and poudriere.
+The easiest way to workaround them is to temporary disable ccache builds until
+all ccache dependencies are built.
+EOM
+}
+]
diff --git a/devel/ccache4/files/world-ccache.in b/devel/ccache4/files/world-ccache.in
new file mode 100644
index 000000000000..9803d12b8298
--- /dev/null
+++ b/devel/ccache4/files/world-ccache.in
@@ -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##*/} "$@"
diff --git a/devel/ccache4/pkg-descr b/devel/ccache4/pkg-descr
new file mode 100644
index 000000000000..a6b59b8988a8
--- /dev/null
+++ b/devel/ccache4/pkg-descr
@@ -0,0 +1,4 @@
+ccache is a compiler cache.  It acts as a caching pre-processor to C/C++
+compilers, using the -E compiler switch and a hash to detect when a
+compilation can be satisfied from cache.  This often results in a 5 to 10
+times speedup in common compilations.
diff --git a/devel/ccache4/pkg-plist b/devel/ccache4/pkg-plist
new file mode 100644
index 000000000000..b4b4599bdacb
--- /dev/null
+++ b/devel/ccache4/pkg-plist
@@ -0,0 +1,9 @@
+etc/periodic/daily/ccache_clean
+bin/ccache
+bin/ccache-update-links
+%%PORTDOCS%%share/man/man1/ccache.1.gz
+%%PORTDOCS%%%%DOCSDIR%%/LICENSE.html
+%%CCLINKDIR%%/world/ccache
+@postexec echo "Create compiler links..."
+@postexec %D/bin/ccache-update-links -v
+@preunexec find %D/%%CCLINKDIR%% -type l -exec rm -f {} \;



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