
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:
f887434d35/src/ccache/execute.cpp (L348)
https://man.archlinux.org/man/exec.3.en#v_-_execv(),_execvp(),_execvpe()
Signed-off-by: Guoxin Pu <pugokushin@gmail.com>
58 lines
1.8 KiB
Bash
58 lines
1.8 KiB
Bash
#!/usr/bin/bash
|
|
#
|
|
# compiler.sh - CCache and DistCC compilation
|
|
# ccache - Cache compilations and reuse them to save time on repetitions
|
|
# distcc - Distribute compilation of C and C++ across machines
|
|
#
|
|
# Copyright (c) 2007-2024 Pacman Development Team <pacman-dev@lists.archlinux.org>
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
[[ -n "$LIBMAKEPKG_BUILDENV_COMPILER_SH" ]] && return
|
|
LIBMAKEPKG_BUILDENV_COMPILER_SH=1
|
|
|
|
MAKEPKG_LIBRARY=${MAKEPKG_LIBRARY:-'@libmakepkgdir@'}
|
|
|
|
source "$MAKEPKG_LIBRARY/util/option.sh"
|
|
|
|
build_options+=('ccache' 'distcc')
|
|
buildenv_functions+=('buildenv_ccache' 'buildenv_distcc')
|
|
|
|
using_ccache=0
|
|
|
|
buildenv_ccache() {
|
|
if check_buildoption "ccache" "y"; then
|
|
if [ -d /usr/lib/ccache/bin ]; then
|
|
export PATH="/usr/lib/ccache/bin:$PATH"
|
|
using_ccache=1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
buildenv_distcc() {
|
|
if check_buildoption "distcc" "y"; then
|
|
if (( using_ccache )); then
|
|
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
|
|
export PATH="/usr/lib/distcc/bin:$PATH"
|
|
fi
|
|
|
|
export DISTCC_HOSTS
|
|
fi
|
|
}
|