1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-15 07:56:36 +00:00

devel/ccache*: Split memcached fork into its own port.

This commit is contained in:
Bryan Drewery 2021-07-09 12:37:19 -07:00
parent 3153ff43c5
commit 53c0dd5715
16 changed files with 369 additions and 84 deletions

View File

@ -1,8 +1,8 @@
PKGNAMESUFFIX= -memcached-static
MASTERDIR= ${.CURDIR}/../ccache
MASTERDIR= ${.CURDIR}/../ccache-memcached
OPTIONS_SLAVE= MEMCACHED STATIC
OPTIONS_SLAVE= STATIC
CONFLICTS_INSTALL= ccache-[0-9]* ccache-memcached[0-9]* ccache-static[0-9]*

View File

@ -1,9 +1,109 @@
PKGNAMESUFFIX= -memcached
# Created by: Dominic Marks <d.marks@student.umist.ac.uk>
MASTERDIR= ${.CURDIR}/../ccache
PORTNAME= ccache
PKGNAMESUFFIX?= -memcached
PORTVERSION= 3.5.dev.20180926
PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= LOCAL/bdrewery \
GH
OPTIONS_SLAVE= MEMCACHED
MAINTAINER= bdrewery@FreeBSD.org
COMMENT= Tool to minimize the compile time of C/C++ programs
CONFLICTS_INSTALL= ccache-[0-9]* ccache-memcached-static[0-9]* ccache-static-[0-9]*
LICENSE= GPLv3+
LICENSE_FILE= ${WRKSRC}/GPL-3.0.txt
.include "${MASTERDIR}/Makefile"
USE_GITHUB= yes
GH_TAGNAME= f7712082106bef085515f86ae47e7dbbd2a48b57
CONFLICTS_INSTALL?= ccache-[0-9]* ccache-static-[0-9]* ccache-memcached-static-[0-9]*
GNU_CONFIGURE= yes
# Some files shared with devel/ccache
CCACHEDIR?= ${MASTERDIR}/../ccache
HOWTO= ccache-howto-freebsd.txt
SUB_FILES= ${HOWTO} world-ccache pkg-message ccache-update-links.sh
PORTDOCS= ccache-howto-freebsd.txt MANUAL.html MANUAL.adoc NEWS.adoc \
NEWS.html
OPTIONS_DEFINE= CLANGLINK LLVMLINK STATIC DOCS TINDERBOX
OPTIONS_DEFAULT=CLANGLINK LLVMLINK
OPTIONS_SUB= yes
CLANGLINK_DESC= Create clang compiler links if clang is installed
LLVMLINK_DESC= Create llvm compiler links if llvm is installed
TINDERBOX_DESC= Create tarball for tinderbox usage
USES= autoreconf compiler gmake pkgconfig
CONFIGURE_ENABLE+= memcached
LIB_DEPENDS+= libmemcached.so:databases/libmemcached
LDFLAGS+= -L${LOCALBASE}/lib
CFLAGS+= -I${LOCALBASE}/include
STATIC_CONFIGURE_ENABLE= static
STATIC_LDFLAGS+= -static
# Hack for libsasl2.a requiring HMAC_CTX_reset from hidden libntlm.a.
STATIC_LDFLAGS+= -L${LOCALBASE}/lib/sasl2
# While this works in theory it breaks due to install conflict in Poudriere
NO_CCACHE_DEPEND= yes
.include <bsd.port.options.mk>
# Extra dependencies needed for generating manpage
.if ${PORT_OPTIONS:MDOCS}
BUILD_DEPENDS+= ${LOCALBASE}/bin/a2x:textproc/asciidoc
ALL_TARGET= all docs
.endif
.include <bsd.port.pre.mk>
. if ${COMPILER_TYPE} == clang
CPPFLAGS+= -DCC_IS_CLANG
. elif ${COMPILER_TYPE} == gcc
CPPFLAGS+= -DCC_IS_GCC
. endif
.include "${CCACHEDIR}/Makefile.compilers"
SUB_LIST+= HOWTO="${HOWTO}"
post-build-TINDERBOX-on:
@${MKDIR} ${WRKDIR}/tb/opt
${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${WRKDIR}/tb/opt
.for l in ${CCACHE_COMPILERS}
@${LN} -sf ${PORTNAME} ${WRKDIR}/tb/opt/${l}
.endfor
@${TAR} -C ${WRKDIR}/tb -cpf ${WRKSRC}/${PORTNAME}.tar opt
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/ccache ${STAGEDIR}${PREFIX}/bin
# Memcached uses the 3.5 dev branch which requires asciidoc to generate
# ccache.1.
.if ${PORT_OPTIONS:MDOCS}
${INSTALL_MAN} ${WRKSRC}/doc/ccache.1 ${STAGEDIR}${PREFIX}/man/man1
.endif
${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
do-install-TINDERBOX-on:
${MKDIR} ${STAGEDIR}${DATADIR}
${INSTALL_DATA} ${WRKSRC}/${PORTNAME}.tar ${STAGEDIR}${DATADIR}
do-install-DOCS-on:
${MKDIR} ${STAGEDIR}${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/doc/MANUAL.html ${STAGEDIR}${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/doc/MANUAL.adoc ${STAGEDIR}${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/doc/NEWS.adoc ${STAGEDIR}${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/doc/NEWS.html ${STAGEDIR}${DOCSDIR}
${INSTALL_DATA} ${WRKDIR}/${HOWTO} ${STAGEDIR}${DOCSDIR}
.include <bsd.port.post.mk>

View File

@ -0,0 +1,67 @@
To use ccache for ports, just add WITH_CCACHE_BUILD=yes to
/etc/make.conf. The rest of this guide is for building
/usr/src and other checkouts.
To use ccache for base (11.0+) just add WITH_CCACHE_BUILD=yes
to /etc/src.conf. Refer to src.conf(5) for more information.
-------------------------------------------------------------------------------
For older releases, before 11.0, 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) && exists(%%PREFIX%%/%%CCLINKDIR%%/world/cc)
CC:=${CC:C,^cc,%%PREFIX%%/%%CCLINKDIR%%/world/cc,1}
CXX:=${CXX:C,^c\+\+,%%PREFIX%%/%%CCLINKDIR%%/world/c++,1}
.endif
.endif
For Korn/Bourne shells Add the following to /etc/profile:
export PATH=%%PREFIX%%/%%CCLINKDIR%%:$PATH
export CCACHE_PATH=/usr/bin:%%LOCALBASE%%/bin
For csh/tcsh Add the following to /etc/csh.cshrc:
setenv PATH %%PREFIX%%/%%CCLINKDIR%%:$PATH
setenv CCACHE_PATH /usr/bin:%%LOCALBASE%%/bin
For icc users:
Add %%ICCPREFIX%% to CCACHE_PATH
-------------------------------------------------------------------------------
To use distcc:
For Korn/Bourne shells Add the following to /etc/profile:
export CCACHE_PREFIX=distcc
export DISTCC_HOSTS="localhost host1 host2"
For csh/tcsh Add the following to /etc/csh.cshrc:
setenv CCACHE_PREFIX distcc
setenv DISTCC_HOSTS "localhost host1 host2"
--
If you have a problem building world
define NOCCACHE and try again.
If you have a problem building a port
reset PATH=$CCACHE_PATH and try again.
--
Make sure you run 'ccache-update-links' after you install/uninstall
additional compilers in order to create/remove compiler links.
--
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
cache location on a different partition with the following examples.
For Korn/Bourne shells Add the following to /etc/profile:
export CCACHE_DIR=/usr/.ccache
For csh/tcsh Add the following to /etc/csh.cshrc
setenv CCACHE_DIR "/usr/.ccache"

View File

@ -0,0 +1,69 @@
#!/bin/sh
#
# Author: Emanuel Haupt <ehaupt@FreeBSD.org>
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

View File

@ -0,0 +1,56 @@
- Determine whether cc(1) is clang or gcc at compile-time.
- Don't hash -fcolor-diagnostics; make will auto use it while make -j will not.
There's no reason to not use the cache in either of these cases if it is
already available.
-bdrewery
--- src/ccache.c.orig 2018-03-25 13:24:05.000000000 -0700
+++ src/ccache.c 2018-06-26 11:44:03.336177000 -0700
@@ -487,6 +487,16 @@ guess_compiler(const char *path)
} else if (str_eq(name, "pump") || str_eq(name, "distcc-pump")) {
result = GUESSED_PUMP;
}
+#if defined(CC_IS_CLANG) || defined(CC_IS_GCC)
+ if (result == GUESSED_UNKNOWN &&
+ (strcmp(name, "cc") == 0 || strcmp(name, "CC") == 0 ||
+ strcmp(name, "c++") == 0))
+#if defined(CC_IS_CLANG)
+ result = GUESSED_CLANG;
+#elif defined(CC_IS_GCC)
+ result = GUESSED_GCC;
+#endif
+#endif
free(name);
return result;
}
@@ -1657,6 +1667,7 @@ calculate_common_hash(struct args *args, struct mdfour
free(p);
}
+#if 0
// Possibly hash GCC_COLORS (for color diagnostics).
if (guessed_compiler == GUESSED_GCC) {
const char *gcc_colors = getenv("GCC_COLORS");
@@ -1665,6 +1676,7 @@ calculate_common_hash(struct args *args, struct mdfour
hash_string(hash, gcc_colors);
}
}
+#endif
}
// Update a hash sum with information specific to the direct and preprocessor
@@ -1697,6 +1709,13 @@ calculate_object_hash(struct args *args, struct mdfour
// -Wl,... doesn't affect compilation (except for clang).
if (str_startswith(args->argv[i], "-Wl,") && !is_clang) {
+ continue;
+ }
+
+ /* Colors do not affect compilation. */
+ if (str_startswith(args->argv[i], "-fcolor-diagnostics") ||
+ str_eq(args->argv[i], "-fdiagnostics-color") ||
+ str_eq(args->argv[i], "-fdiagnostics-color=always")) {
continue;
}

View File

@ -0,0 +1,9 @@
[
{ type: install
message: <<EOM
NOTE:
Please read %%DOCSDIR%%/%%HOWTO%% for
information on using ccache with FreeBSD ports and src.
EOM
}
]

View File

@ -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##*/} "$@"

View File

@ -0,0 +1,8 @@
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.
ccache-memcached is an older fork with memcached support.
WWW: https://ccache.samba.org/

View File

@ -0,0 +1,9 @@
bin/ccache
bin/ccache-update-links
@comment manpage requires extra dependencies
%%DOCS%%man/man1/ccache.1.gz
%%CCLINKDIR%%/world/ccache
%%TINDERBOX%%%%DATADIR%%/ccache.tar
@postexec echo "Create compiler links..."
@postexec %D/bin/ccache-update-links -v
@preunexec find %D/%%CCLINKDIR%% -type l -exec rm -f {} \;

View File

@ -1,7 +1,7 @@
# Created by: Dominic Marks <d.marks@student.umist.ac.uk>
PORTNAME= ccache
#PORTVERSION must be set later due to depending on PORT_OPTIONS.
PORTVERSION= 3.7.1
PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= https://github.com/ccache/ccache/releases/download/v${DISTVERSION}/ \
@ -18,70 +18,27 @@ CONFLICTS_INSTALL?= ccache-static-[0-9]* ccache-memcached-[0-9]* ccache-memcache
GNU_CONFIGURE= yes
HOWTO= ccache-howto-freebsd.txt
CCLINKDIR= libexec/ccache
SUB_FILES= ${HOWTO} world-ccache pkg-message ccache-update-links.sh
PORTDOCS= ccache-howto-freebsd.txt MANUAL.html MANUAL.adoc NEWS.adoc \
NEWS.html
OPTIONS_DEFINE= CLANGLINK LLVMLINK STATIC DOCS TINDERBOX MEMCACHED
OPTIONS_DEFINE= CLANGLINK LLVMLINK STATIC DOCS TINDERBOX
OPTIONS_DEFAULT=CLANGLINK LLVMLINK
OPTIONS_SUB= yes
CLANGLINK_DESC= Create clang compiler links if clang is installed
LLVMLINK_DESC= Create llvm compiler links if llvm is installed
TINDERBOX_DESC= Create tarball for tinderbox usage
MEMCACHED_DESC= Build in experimental Memcached support
USES= compiler
MEMCACHED_EXTRA_PATCHES= \
${FILESDIR}/extra-patch-memcached-configure.ac \
${FILESDIR}/extra-patch-memcached-Makefile.in
MEMCACHED_CONFIGURE_ENABLE= memcached
MEMCACHED_USES= autoreconf gmake pkgconfig
MEMCACHED_LIB_DEPENDS= libmemcached.so:databases/libmemcached
MEMCACHED_LDFLAGS= -L${LOCALBASE}/lib
MEMCACHED_CFLAGS= -I${LOCALBASE}/include
STATIC_CONFIGURE_ENABLE= static
.if empty(OPTIONS_SLAVE:MMEMCACHED)
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-Makefile.in
.endif
.if defined(WITH_CCACHE_BUILD) && empty(OPTIONS_SLAVE:MMEMCACHED) && \
!defined(NO_CCACHE_DEPEND)
MEMCACHED_IGNORE= MEMCACHED cannot be combined with WITH_CCACHE_BUILD. Use devel/ccache-memcached
# XXX: This needs more testing with Poudriere before enabling. Also bsd.options.mk support.
#MEMCACHED_DEPENDS_ARGS+= NO_CCACHE_DEPEND=1
.endif
STATIC_LDFLAGS+= -static
# Support WITH_CCACHE_BUILD but don't depend on it.
NO_CCACHE_DEPEND= yes
OPTIONS_SUB= yes
STATIC_LDFLAGS+= -static
.include <bsd.port.options.mk>
.if ${PORT_OPTIONS:MMEMCACHED}
# Hack for libsasl2.a requiring HMAC_CTX_reset from hidden libntlm.a.
STATIC_LDFLAGS+= -L${LOCALBASE}/lib/sasl2
PORTVERSION= 3.5.dev.20180926
USE_GITHUB= yes
GH_TAGNAME= f7712082106bef085515f86ae47e7dbbd2a48b57
MASTER_SITES=
DISTINFO_FILE= ${MASTERDIR}/distinfo.memcached
.if ${PORT_OPTIONS:MDOCS}
BUILD_DEPENDS+= ${LOCALBASE}/bin/a2x:textproc/asciidoc
ALL_TARGET= all docs
PLIST_FILES+= man/man1/ccache.1.gz
.endif
.else
PORTVERSION= 3.7.1
.endif
.include <bsd.port.pre.mk>
. if ${COMPILER_TYPE} == clang
@ -90,35 +47,11 @@ CPPFLAGS+= -DCC_IS_CLANG
CPPFLAGS+= -DCC_IS_GCC
. endif
PLIST_SUB+= CCLINKDIR="${CCLINKDIR}"
.include "${MASTERDIR}/Makefile.compilers"
.if ${ARCH}=="i386"
CCACHE_COMPILERS+= icc icpc
.endif
SUB_LIST+= HOWTO="${HOWTO}"
GNU_COMPILERS+= 34 42 43 44 45 46 47 48 49 5 6 7 8 9 10
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+= 33 34 35 36 37 38 39 40 50 60 70 80 90 10 -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}" \
ICCPREFIX="${LOCALBASE}/intel_cc_80/bin" \
HOWTO="${HOWTO}"
post-patch-MEMCACHED-off:
post-patch:
@${REINPLACE_CMD} \
-e 's,_XOPEN_SOURCE 600,_XOPEN_SOURCE 700,' \
-e 's,_POSIX_C_SOURCE 200112L,_POSIX_C_SOURCE 200809L,' \
@ -136,9 +69,7 @@ do-install:
${INSTALL_PROGRAM} ${WRKSRC}/ccache ${STAGEDIR}${PREFIX}/bin
# Memcached uses the 3.5 dev branch which requires asciidoc to generate
# ccache.1.
.if !${PORT_OPTIONS:MMEMCACHED} || ${PORT_OPTIONS:MDOCS}
${INSTALL_MAN} ${WRKSRC}/doc/ccache.1 ${STAGEDIR}${PREFIX}/man/man1
.endif
${MKDIR} ${STAGEDIR}${PREFIX}/${CCLINKDIR}/world
${INSTALL_SCRIPT} ${WRKDIR}/world-ccache \
${STAGEDIR}${PREFIX}/${CCLINKDIR}/world/ccache

View File

@ -0,0 +1,27 @@
CCLINKDIR?= libexec/ccache
PLIST_SUB+= CCLINKDIR="${CCLINKDIR}"
SUB_LIST+= CCACHE_COMPILERS="${CCACHE_COMPILERS}" \
CCLINKDIR="${CCLINKDIR}" \
ICCPREFIX="${LOCALBASE}/intel_cc_80/bin"
.if ${ARCH}=="i386"
CCACHE_COMPILERS+= icc icpc
.endif
GNU_COMPILERS+= 34 42 43 44 45 46 47 48 49 5 6 7 8 9 10
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+= 33 34 35 36 37 38 39 40 50 60 70 80 90 10 -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}

View File

@ -1,6 +1,6 @@
bin/ccache
bin/ccache-update-links
%%NO_MEMCACHED%%man/man1/ccache.1.gz
man/man1/ccache.1.gz
%%CCLINKDIR%%/world/ccache
%%TINDERBOX%%%%DATADIR%%/ccache.tar
@postexec echo "Create compiler links..."