summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2020-03-24 22:27:06 +0000
committerSergei Trofimovich <slyfox@gentoo.org>2020-03-24 22:29:55 +0000
commit650d7b15773aea3eda20f2b870ad3266ddeefa6d (patch)
treecc822cfcece8d6321a529fee1cb4f9d31dffd43a /dev-util/ccache
parentsys-libs/libutempter: EAPI-7 revbump (diff)
downloadgentoo-650d7b15773aea3eda20f2b870ad3266ddeefa6d.tar.gz
gentoo-650d7b15773aea3eda20f2b870ad3266ddeefa6d.tar.bz2
gentoo-650d7b15773aea3eda20f2b870ad3266ddeefa6d.zip
dev-util/ccache: backport workaround for /dev/null clobber
In bug #712080 'hard_link = true' mode of ccache unlinked /dev/null as ccache was running as root. This workaround allows /dev/null to survive. Other special files still stay affected. Bug: https://bugs.gentoo.org/712080 Package-Manager: Portage-2.3.95, Repoman-2.3.21 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Diffstat (limited to 'dev-util/ccache')
-rw-r--r--dev-util/ccache/ccache-3.7.8-r1.ebuild71
-rw-r--r--dev-util/ccache/files/ccache-3.7.8-dev-null.patch57
2 files changed, 128 insertions, 0 deletions
diff --git a/dev-util/ccache/ccache-3.7.8-r1.ebuild b/dev-util/ccache/ccache-3.7.8-r1.ebuild
new file mode 100644
index 000000000000..c84c0678c54e
--- /dev/null
+++ b/dev-util/ccache/ccache-3.7.8-r1.ebuild
@@ -0,0 +1,71 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+DESCRIPTION="fast compiler cache"
+HOMEPAGE="https://ccache.dev/"
+SRC_URI="https://github.com/ccache/ccache/releases/download/v${PV}/ccache-${PV}.tar.xz"
+
+LICENSE="GPL-3"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86"
+IUSE="test"
+
+DEPEND="app-arch/xz-utils
+ sys-libs/zlib"
+RDEPEND="${DEPEND}
+ dev-util/shadowman
+ sys-apps/gentoo-functions"
+# clang-specific tests use dev-libs/elfutils to compare objects for equality.
+# Let's pull in the dependency unconditionally.
+DEPEND+="
+ test? ( dev-libs/elfutils )"
+
+RESTRICT="!test? ( test )"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-3.5-nvcc-test.patch
+ "${FILESDIR}"/${PN}-3.7.8-dev-null.patch
+)
+
+src_prepare() {
+ default
+
+ sed \
+ -e "/^EPREFIX=/s:'':'${EPREFIX}':" \
+ "${FILESDIR}"/ccache-config-3 > ccache-config || die
+}
+
+src_configure() {
+ econf --without-bundled-zlib
+}
+
+src_compile() {
+ emake V=1
+}
+
+src_test() {
+ emake check V=1
+}
+
+src_install() {
+ DOCS=( doc/{AUTHORS,MANUAL,NEWS}.adoc CONTRIBUTING.md README.md )
+ default
+
+ dobin ccache-config
+ insinto /usr/share/shadowman/tools
+ newins - ccache <<<"${EPREFIX}/usr/lib/ccache/bin"
+}
+
+pkg_prerm() {
+ if [[ -z ${REPLACED_BY_VERSION} && ${ROOT:-/} == / ]] ; then
+ eselect compiler-shadow remove ccache
+ fi
+}
+
+pkg_postinst() {
+ if [[ ${ROOT:-/} == / ]]; then
+ eselect compiler-shadow update ccache
+ fi
+}
diff --git a/dev-util/ccache/files/ccache-3.7.8-dev-null.patch b/dev-util/ccache/files/ccache-3.7.8-dev-null.patch
new file mode 100644
index 000000000000..389f9e3a1e2b
--- /dev/null
+++ b/dev-util/ccache/files/ccache-3.7.8-dev-null.patch
@@ -0,0 +1,57 @@
+https://bugs.gentoo.org/712080
+
+From 9a794689a8ba47e79c96d6c370976448b756973c Mon Sep 17 00:00:00 2001
+From: Joel Rosdahl <joel@rosdahl.net>
+Date: Sun, 22 Mar 2020 14:30:23 +0100
+Subject: [PATCH] Disable hard link mode when the output object file is
+ /dev/null
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When hard link mode is enabled, ccache ≥3.6 unlinks the output file
+before writing to it as a workaround for a bug in Clang (#331). This
+unfortunately means that /dev/null will be removed when building as root
+(don’t do that, BTW) with hard link mode enabled and /dev/null as the
+the output file. A similar problem exists if the dependency file is
+/dev/null, regardless of hard link mode.
+
+Fix this by not unlinking the output file if it’s /dev/null and by not
+copying files to /dev/null at all. (There is no need to handle other
+non-regular output files since /dev/null is the only allowed non-regular
+output file.)
+
+Fixes #564.
+---
+ src/ccache.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/src/ccache.c b/src/ccache.c
+index 6e9da51..b9bafac 100644
+--- a/src/ccache.c
++++ b/src/ccache.c
+@@ -1299,6 +1299,11 @@ move_file_to_cache_same_fs(const char *source, const char *dest)
+ static void
+ do_copy_or_link_file_from_cache(const char *source, const char *dest, bool copy)
+ {
++ if (str_eq(dest, "/dev/null")) {
++ cc_log("Skipping copy from %s to %s", source, dest);
++ return;
++ }
++
+ int ret;
+ bool do_link = !copy && conf->hard_link && !file_is_compressed(source);
+ if (do_link) {
+@@ -1432,7 +1437,8 @@ to_cache(struct args *args, struct hash *depend_mode_hash)
+ args_add(args, "-o");
+ args_add(args, output_obj);
+
+- if (conf->hard_link) {
++ if (conf->hard_link && !str_eq(output_obj, "/dev/null")) {
++ // This is a workaround for https://bugs.llvm.org/show_bug.cgi?id=39782.
+ x_unlink(output_obj);
+ }
+
+--
+2.26.0
+