diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index f6f613e..534e97e 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -147,12 +147,16 @@ def _zig_repository_impl(repository_ctx): cache_prefix = repository_ctx.os.environ.get("HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX", "") if cache_prefix == "": + # Append the username when available to reduce risks of conflict. + username = repository_ctx.os.environ.get("USER", "") + if username: + username = "-" + username if os == "windows": - cache_prefix = "C:\\\\Temp\\\\zig-cache" + cache_prefix = "C:\\\\Temp\\\\zig-cache" + username elif os == "macos": - cache_prefix = "/var/tmp/zig-cache" + cache_prefix = "/var/tmp/zig-cache" + username elif os == "linux": - cache_prefix = "/tmp/zig-cache" + cache_prefix = "/tmp/zig-cache" + username else: fail("unknown os: {}".format(os))