Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-util/ccache/, dev-util/ccache/files/
Date: Fri, 18 Jun 2021 10:15:17
Message-Id: 1624011306.8e1ed9330e1ac2cbf65e01bad5b97910daf0397d.slyfox@gentoo
1 commit: 8e1ed9330e1ac2cbf65e01bad5b97910daf0397d
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jun 18 10:12:52 2021 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Fri Jun 18 10:15:06 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8e1ed933
7
8 dev-util/ccache: backport PWD=. handling
9
10 Reported-by: 12101111
11 Closes: https://bugs.gentoo.org/751355
12 Package-Manager: Portage-3.0.20, Repoman-3.0.3
13 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
14
15 dev-util/ccache/ccache-4.3-r2.ebuild | 90 ++++++++++++++++++++++++++++++
16 dev-util/ccache/files/ccache-4.3-PWD.patch | 85 ++++++++++++++++++++++++++++
17 2 files changed, 175 insertions(+)
18
19 diff --git a/dev-util/ccache/ccache-4.3-r2.ebuild b/dev-util/ccache/ccache-4.3-r2.ebuild
20 new file mode 100644
21 index 00000000000..987b811477e
22 --- /dev/null
23 +++ b/dev-util/ccache/ccache-4.3-r2.ebuild
24 @@ -0,0 +1,90 @@
25 +# Copyright 1999-2021 Gentoo Authors
26 +# Distributed under the terms of the GNU General Public License v2
27 +
28 +EAPI=7
29 +
30 +inherit cmake toolchain-funcs
31 +
32 +DESCRIPTION="fast compiler cache"
33 +HOMEPAGE="https://ccache.dev/"
34 +SRC_URI="https://github.com/ccache/ccache/releases/download/v${PV}/ccache-${PV}.tar.xz"
35 +
36 +LICENSE="GPL-3 LGPL-3"
37 +SLOT="0"
38 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
39 +IUSE="static-c++ test"
40 +
41 +DEPEND=""
42 +RDEPEND="${DEPEND}
43 + app-arch/zstd:0=
44 + dev-util/shadowman
45 + sys-apps/gentoo-functions
46 +"
47 +# clang-specific tests use dev-libs/elfutils to compare objects for equality.
48 +# Let's pull in the dependency unconditionally.
49 +DEPEND+="
50 + test? ( dev-libs/elfutils )
51 +"
52 +BDEPEND="
53 + app-text/asciidoc
54 +"
55 +
56 +RESTRICT="!test? ( test )"
57 +
58 +DOCS=( doc/{AUTHORS,MANUAL,NEWS}.adoc CONTRIBUTING.md README.md )
59 +
60 +PATCHES=(
61 + "${FILESDIR}"/${PN}-3.5-nvcc-test.patch
62 + "${FILESDIR}"/${PN}-4.0-objdump.patch
63 + "${FILESDIR}"/${PN}-4.1-avoid-run-user.patch
64 + "${FILESDIR}"/${P}-PWD.patch
65 +)
66 +
67 +src_prepare() {
68 + cmake_src_prepare
69 +
70 + sed \
71 + -e "/^EPREFIX=/s:'':'${EPREFIX}':" \
72 + "${FILESDIR}"/ccache-config-3 > ccache-config || die
73 +
74 + # mainly used in tests
75 + tc-export CC OBJDUMP
76 +
77 + # Avoid dependency on libstdc++.so. Useful for cases when
78 + # we would like to use ccache to build older gcc which injects
79 + # into ccache locally built (possibly outdated) libstdc++
80 + # See bug #761220 for examples.
81 + #
82 + # Ideally gcc should not use LD_PRELOAD to avoid this type of failures.
83 + use static-c++ && append-ldflags -static-libstdc++
84 +}
85 +
86 +src_configure() {
87 + local mycmakeargs=(
88 + -DUSE_CCACHE=OFF
89 + -DUSE_FASTER_LINKER=OFF
90 + -DZSTD_FROM_INTERNET=OFF
91 + )
92 +
93 + cmake_src_configure
94 +}
95 +
96 +src_install() {
97 + cmake_src_install
98 +
99 + dobin ccache-config
100 + insinto /usr/share/shadowman/tools
101 + newins - ccache <<<"${EPREFIX}/usr/lib/ccache/bin"
102 +}
103 +
104 +pkg_prerm() {
105 + if [[ -z ${REPLACED_BY_VERSION} && ${ROOT:-/} == / ]] ; then
106 + eselect compiler-shadow remove ccache
107 + fi
108 +}
109 +
110 +pkg_postinst() {
111 + if [[ ${ROOT:-/} == / ]]; then
112 + eselect compiler-shadow update ccache
113 + fi
114 +}
115
116 diff --git a/dev-util/ccache/files/ccache-4.3-PWD.patch b/dev-util/ccache/files/ccache-4.3-PWD.patch
117 new file mode 100644
118 index 00000000000..3943dab5bd2
119 --- /dev/null
120 +++ b/dev-util/ccache/files/ccache-4.3-PWD.patch
121 @@ -0,0 +1,85 @@
122 +https://github.com/ccache/ccache/commit/2d720aed1843b47aafb2af8bfd15139228545e2b.patch
123 +https://bugs.gentoo.org/751355
124 +
125 +From 2d720aed1843b47aafb2af8bfd15139228545e2b Mon Sep 17 00:00:00 2001
126 +From: Joel Rosdahl <joel@×××××××.net>
127 +Date: Wed, 16 Jun 2021 18:19:04 +0200
128 +Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20crash=20on=20relative=20PWD=20v?=
129 + =?UTF-8?q?alue?=
130 +MIME-Version: 1.0
131 +Content-Type: text/plain; charset=UTF-8
132 +Content-Transfer-Encoding: 8bit
133 +
134 +Even though PWD “shall represent an absolute pathname of the current
135 +working directory”[1], we shouldn’t crash if a user sets it to a
136 +relative path.
137 +
138 +[1]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03
139 +
140 +Fixes #860.
141 +---
142 + src/Util.cpp | 2 +-
143 + test/run | 1 +
144 + test/suites/basedir.bash | 32 ++++++++++++++++++++++++++++++++
145 + 3 files changed, 34 insertions(+), 1 deletion(-)
146 +
147 +--- a/src/Util.cpp
148 ++++ b/src/Util.cpp
149 +@@ -617,7 +617,7 @@ get_apparent_cwd(const std::string& actual_cwd)
150 + return actual_cwd;
151 + #else
152 + auto pwd = getenv("PWD");
153 +- if (!pwd) {
154 ++ if (!pwd || !Util::is_absolute_path(pwd)) {
155 + return actual_cwd;
156 + }
157 +
158 +--- a/test/run
159 ++++ b/test/run
160 +@@ -356,6 +356,7 @@ reset_environment() {
161 + unset TERM
162 + unset XDG_CACHE_HOME
163 + unset XDG_CONFIG_HOME
164 ++ export PWD=$(pwd)
165 +
166 + export CCACHE_DETECT_SHEBANG=1
167 + export CCACHE_DIR=$ABS_TESTDIR/.ccache
168 +--- a/test/suites/basedir.bash
169 ++++ b/test/suites/basedir.bash
170 +@@ -311,4 +311,36 @@ EOF
171 + expect_stat 'cache miss' 1
172 + expect_equal_content reference.stderr ccache.stderr
173 + fi
174 ++
175 ++ # -------------------------------------------------------------------------
176 ++ TEST "Relative PWD"
177 ++
178 ++ cd dir1
179 ++ CCACHE_BASEDIR="$(pwd)" PWD=. $CCACHE_COMPILE -I$(pwd)/include -c src/test.c
180 ++ expect_stat 'cache hit (direct)' 0
181 ++ expect_stat 'cache hit (preprocessed)' 0
182 ++ expect_stat 'cache miss' 1
183 ++
184 ++ cd ../dir2
185 ++ CCACHE_BASEDIR="$(pwd)" PWD=. $CCACHE_COMPILE -I$(pwd)/include -c src/test.c
186 ++ expect_stat 'cache hit (direct)' 1
187 ++ expect_stat 'cache hit (preprocessed)' 0
188 ++ expect_stat 'cache miss' 1
189 ++
190 ++ # -------------------------------------------------------------------------
191 ++ TEST "Unset PWD"
192 ++
193 ++ unset PWD
194 ++
195 ++ cd dir1
196 ++ CCACHE_BASEDIR="$(pwd)" $CCACHE_COMPILE -I$(pwd)/include -c src/test.c
197 ++ expect_stat 'cache hit (direct)' 0
198 ++ expect_stat 'cache hit (preprocessed)' 0
199 ++ expect_stat 'cache miss' 1
200 ++
201 ++ cd ../dir2
202 ++ CCACHE_BASEDIR="$(pwd)" $CCACHE_COMPILE -I$(pwd)/include -c src/test.c
203 ++ expect_stat 'cache hit (direct)' 1
204 ++ expect_stat 'cache hit (preprocessed)' 0
205 ++ expect_stat 'cache miss' 1
206 + }