@@ -609,8 +609,9 @@ def doebuild_environment(
609609 ccache = "ccache" in mysettings .features
610610 distcc = "distcc" in mysettings .features
611611 icecream = "icecream" in mysettings .features
612+ sccache = "sccache" in mysettings .features
612613
613- if ccache or distcc or icecream :
614+ if ccache or distcc or icecream or sccache :
614615 libdir = None
615616 default_abi = mysettings .get ("DEFAULT_ABI" )
616617 if default_abi :
@@ -628,6 +629,8 @@ def doebuild_environment(
628629 masquerades .append (("icecream" , "icecc" ))
629630 if ccache :
630631 masquerades .append (("ccache" , "ccache" ))
632+ if sccache :
633+ masquerades .append (("sccache" , "sccache" ))
631634
632635 for feature , m in masquerades :
633636 for l in possible_libexecdirs :
@@ -645,6 +648,12 @@ def doebuild_environment(
645648 )
646649 mysettings .features .remove (feature )
647650
651+ if sccache :
652+ # Set to a custom default port (not the upstream default) to avoid conflicts with other users
653+ # and avoid permission issue when other server has non-writable SCCACHE_DIR.
654+ mysettings .setdefault ("SCCACHE_SERVER_PORT" , "6224" )
655+ mysettings ["RUSTC_WRAPPER" ] = "sccache"
656+
648657 # MAKEOPTS conflicts with MAKEFLAGS, so skip this if MAKEFLAGS exists.
649658 if "MAKEOPTS" not in mysettings and "MAKEFLAGS" not in mysettings :
650659 nproc = get_cpu_count ()
0 commit comments