[pacman-dev,v2] makepkg: Don't double-layer distcc on ccache

Message ID 20210130174640.1445218-1-matti.niemenmaa+pacman-dev@iki.fi
State New
Headers show
Series [pacman-dev,v2] makepkg: Don't double-layer distcc on ccache | expand

Commit Message

Matti Niemenmaa Jan. 30, 2021, 5:46 p.m. UTC
From: Matti Niemenmaa <matti.niemenmaa+git@iki.fi>

buildenv is set once for build() and a second time for package(). When
using both distcc and ccache, this lead to CCACHE_PREFIX="distcc distcc"
in package(), which breaks PKGBUILDs that execute the compiler in
package() because distcc complains:

    distcc[383041] (main) CRITICAL! distcc seems to have invoked itself
    recursively!

Avoid causing this error by only adding "distcc" to CCACHE_PREFIX if
it's not yet there.

Signed-off-by: Matti Niemenmaa <matti.niemenmaa+git@iki.fi>
---
 scripts/libmakepkg/buildenv/compiler.sh.in | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

This time using globbing instead of regex, as requested by Eli.

Comments

Allan McRae Feb. 8, 2021, 4:25 a.m. UTC | #1
On 31/1/21 3:46 am, Matti Niemenmaa wrote:
> From: Matti Niemenmaa <matti.niemenmaa+git@iki.fi>
> 
> buildenv is set once for build() and a second time for package(). When
> using both distcc and ccache, this lead to CCACHE_PREFIX="distcc distcc"
> in package(), which breaks PKGBUILDs that execute the compiler in
> package() because distcc complains:
> 
>     distcc[383041] (main) CRITICAL! distcc seems to have invoked itself
>     recursively!
> 
> Avoid causing this error by only adding "distcc" to CCACHE_PREFIX if
> it's not yet there.
> 
> Signed-off-by: Matti Niemenmaa <matti.niemenmaa+git@iki.fi>

Thanks for chasing this up.

A

> ---
>  scripts/libmakepkg/buildenv/compiler.sh.in | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> This time using globbing instead of regex, as requested by Eli.
> 
> diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in b/scripts/libmakepkg/buildenv/compiler.sh.in
> index 69f58a29..b1e36f56 100644
> --- a/scripts/libmakepkg/buildenv/compiler.sh.in
> +++ b/scripts/libmakepkg/buildenv/compiler.sh.in
> @@ -44,7 +44,9 @@ buildenv_ccache() {
>  buildenv_distcc() {
>  	if check_buildoption "distcc" "y"; then
>  		if (( using_ccache )); then
> -			export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc"
> +			if [[ " $CCACHE_PREFIX " != *" distcc "* ]]; then
> +				export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc"
> +			fi
>  			export CCACHE_BASEDIR="$srcdir"
>  		elif [[ -d /usr/lib/distcc/bin ]]; then
>  			export PATH="/usr/lib/distcc/bin:$PATH"
>

Patch

diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in b/scripts/libmakepkg/buildenv/compiler.sh.in
index 69f58a29..b1e36f56 100644
--- a/scripts/libmakepkg/buildenv/compiler.sh.in
+++ b/scripts/libmakepkg/buildenv/compiler.sh.in
@@ -44,7 +44,9 @@  buildenv_ccache() {
 buildenv_distcc() {
 	if check_buildoption "distcc" "y"; then
 		if (( using_ccache )); then
-			export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc"
+			if [[ " $CCACHE_PREFIX " != *" distcc "* ]]; then
+				export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc"
+			fi
 			export CCACHE_BASEDIR="$srcdir"
 		elif [[ -d /usr/lib/distcc/bin ]]; then
 			export PATH="/usr/lib/distcc/bin:$PATH"