Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion bin/ebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export PORTAGE_BZIP2_COMMAND=${PORTAGE_BZIP2_COMMAND:-bzip2}

# These two functions wrap sourcing and calling respectively. At present they
# perform a qa check to make sure eclasses and ebuilds and profiles don't mess
# with shell opts (shopts). Ebuilds/eclasses changing shopts should reset them
# with shell opts (shopts). Ebuilds/eclasses changing shopts should reset them
# when they are done.

__qa_source() {
Expand Down Expand Up @@ -732,6 +732,13 @@ if [[ ${EBUILD_PHASE} != clean?(rm) ]]; then

[[ -n ${CCACHE_SIZE} ]] && ccache -M ${CCACHE_SIZE} &> /dev/null
fi

if contains_word sccache "${FEATURES}"; then
if [[ -n ${SCCACHE_DIR} ]] ; then
addread "${SCCACHE_DIR}"
addwrite "${SCCACHE_DIR}"
fi
fi
fi
fi
fi
Expand Down
3 changes: 2 additions & 1 deletion bin/phase-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,8 @@ __ebuild_main() {

local x
for x in ASFLAGS CCACHE_DIR CCACHE_SIZE \
CFLAGS CXXFLAGS LDFLAGS LIBCFLAGS LIBCXXFLAGS ; do
CFLAGS CXXFLAGS LDFLAGS LIBCFLAGS LIBCXXFLAGS \
SCCACHE_DIR SCCACHE_CACHE_SIZE ; do
[[ ${!x+set} = set ]] && export ${x}
done
unset x
Expand Down
3 changes: 2 additions & 1 deletion bin/save-ebuild-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ __save_ebuild_env() (
INSTALL_MASK
PKG_INSTALL_MASK

# CCACHE and DISTCC configuration variables.
# CCACHE, DISTCC, and SCCACHE configuration variables.
"${!CCACHE_@}"
"${!DISTCC_@}"
"${!SCCACHE_@}"
)

# Unset the collected variables before moving on to functions.
Expand Down
1 change: 1 addition & 0 deletions lib/_emerge/EbuildPhase.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class EbuildPhase(CompositeTask):
"nostrip",
"preserve-libs",
"sandbox",
"sccache",
"selinux",
"sesandbox",
"splitdebug",
Expand Down
17 changes: 17 additions & 0 deletions lib/_emerge/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,23 @@ def action_info(settings, trees, myopts, myfiles):
ccache_str += " [disabled]"
append(ccache_str)

try:
proc = subprocess.Popen(
["sccache", "-V"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
except OSError:
output = (1, None)
else:
output = _unicode_decode(proc.communicate()[0]).rstrip("\n")
output = (proc.wait(), output)
if output[0] == os.EX_OK:
sccache_str = output[1].split("\n", 1)[0]
if "sccache" in settings.features:
sccache_str += " [enabled]"
else:
sccache_str += " [disabled]"
append(sccache_str)

myvars = [
"dev-build/autoconf",
"dev-build/automake",
Expand Down
1 change: 1 addition & 0 deletions lib/portage/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
"python-trace",
"qa-unresolved-soname-deps",
"sandbox",
"sccache",
"selinux",
"sesandbox",
"sfperms",
Expand Down
2 changes: 1 addition & 1 deletion lib/portage/package/ebuild/_config/special_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
)
)

environ_whitelist_re = re.compile(r"^(CCACHE_|DISTCC_).*")
environ_whitelist_re = re.compile(r"^(S?CCACHE_|DISTCC_).*")

# Filter selected variables in the config.environ() method so that
# they don't needlessly propagate down into the ebuild environment.
Expand Down
11 changes: 10 additions & 1 deletion lib/portage/package/ebuild/doebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,9 @@ def doebuild_environment(
ccache = "ccache" in mysettings.features
distcc = "distcc" in mysettings.features
icecream = "icecream" in mysettings.features
sccache = "sccache" in mysettings.features

if ccache or distcc or icecream:
if ccache or distcc or icecream or sccache:
libdir = None
default_abi = mysettings.get("DEFAULT_ABI")
if default_abi:
Expand All @@ -628,6 +629,8 @@ def doebuild_environment(
masquerades.append(("icecream", "icecc"))
if ccache:
masquerades.append(("ccache", "ccache"))
if sccache:
masquerades.append(("sccache", "sccache"))

for feature, m in masquerades:
for l in possible_libexecdirs:
Expand All @@ -645,6 +648,12 @@ def doebuild_environment(
)
mysettings.features.remove(feature)

if sccache:
# Set to a custom default port (not the upstream default) to avoid conflicts with other users
# and avoid permission issue when other server has non-writable SCCACHE_DIR.
mysettings.setdefault("SCCACHE_SERVER_PORT", "6224")
mysettings["RUSTC_WRAPPER"] = "sccache"

# MAKEOPTS conflicts with MAKEFLAGS, so skip this if MAKEFLAGS exists.
if "MAKEOPTS" not in mysettings and "MAKEFLAGS" not in mysettings:
nproc = get_cpu_count()
Expand Down
5 changes: 5 additions & 0 deletions lib/portage/package/ebuild/prepare_build_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ def _prepare_features_dirs(mysettings):
"subdirs": ("lock", "state"),
"always_recurse": True,
},
"sccache": {
"basedir_var": "SCCACHE_DIR",
"default_dir": os.path.join(mysettings["PORTAGE_TMPDIR"], "sccache"),
"always_recurse": False,
},
}
dirmode = 0o2070
filemode = 0o60
Expand Down