From 680169fb61ede7e084adef8666f10128e9c543c3 Mon Sep 17 00:00:00 2001 From: Guoxin Pu Date: Tue, 4 Jun 2024 17:28:19 +0800 Subject: [PATCH] libmakepkg: set CCACHE_PREFIX to absolute path of distcc when using both The current logic sets CCACHE_PREFIX to distcc when both distcc and ccache are enabled. However, according to the source of ccache, it would execute the command with execv, which would not look up arg0 from PATH, unlike those exec functions with _p suffix. This would result in the following error, when building a package with both ccache and distcc enabled: ``` ccache: error: execute_noreturn of distcc failed: No such file or directory ``` This breaks package builds in different ways: packages that use make/cc directly would yield the actual error which is the same as the above line, packages that rely on other build systems wouldn't go through compiler check and complain on a bad compiler. To reproduce the problem, try to build a simple package: ``` git clone https://gitlab.archlinux.org/archlinux/packaging/packages/abc.git cd abc cp /etc/makepkg.conf . echo 'BUILDENV=(distcc color ccache check !sign)' >> makepkg.conf makepkg --config makepkg.conf ``` refs: https://github.com/ccache/ccache/blob/f887434d35bf6544ce3b56dd7684de804cdaacfa/src/ccache/execute.cpp#L348 https://man.archlinux.org/man/exec.3.en#v_-_execv(),_execvp(),_execvpe() Signed-off-by: Guoxin Pu --- scripts/libmakepkg/buildenv/compiler.sh.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in b/scripts/libmakepkg/buildenv/compiler.sh.in index dc3ee73a..782eaf3f 100644 --- a/scripts/libmakepkg/buildenv/compiler.sh.in +++ b/scripts/libmakepkg/buildenv/compiler.sh.in @@ -44,8 +44,9 @@ buildenv_ccache() { buildenv_distcc() { if check_buildoption "distcc" "y"; then if (( using_ccache )); then - if [[ " $CCACHE_PREFIX " != *" distcc "* ]]; then - export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc" + local distcc=$(type -p 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