diff --git a/build_tools/setup_ccache.py b/build_tools/setup_ccache.py index 2c60f4a21f..0a0c79399f 100755 --- a/build_tools/setup_ccache.py +++ b/build_tools/setup_ccache.py @@ -47,19 +47,19 @@ # so that Windows workflows can direct logs to BUILD_DIR/logs/ccache/ (B:\build) # instead of REPO_ROOT/build/logs/ccache/ (C: drive). CONFIG_PRESETS_MAP = { - "local": {}, + "local": {"max_size": "10G"}, # Dev and release use separate cache servers to avoid cache pollution. # We may later split these further into presubmit (PR) vs postsubmit # (post-merge) presets — presubmit serves varied code at mixed trust # levels while postsubmit serves a uniform stream of approved commits, # so separating them improves both cache hit rates and data integrity. "github-oss-dev": { - "secondary_storage": CACHE_SRV_DEV, - "max_size": "5G", + "remote_storage": CACHE_SRV_DEV, + "max_size": "10G", }, "github-oss-release": { - "secondary_storage": CACHE_SRV_REL, - "max_size": "5G", + "remote_storage": CACHE_SRV_REL, + "max_size": "10G", }, } @@ -98,25 +98,34 @@ def gen_config(dir: Path, compiler_check_file: Path, args: argparse.Namespace): local_path.mkdir(parents=True, exist_ok=True) lines.append(f"cache_dir = {local_path}") - # Compiler check: on POSIX we use a custom script that fingerprints the - # compiler binary and its shared libraries via ldd + sha256sum. On Windows - # (MSVC) those tools don't exist; ccache's default mtime check works well. + # Compiler Check if not IS_WINDOWS: + # On POSIX we use a custom script that fingerprints the + # compiler binary and its shared libraries via ldd + sha256sum. lines.append( f"compiler_check = {sys.executable} {compiler_check_file} " f"{dir / 'compiler_check_cache'} %compiler%" ) - - # Slop settings. - # Creating a hard link to a file increasing the link count, which triggers - # a ctime update (since ctime tracks changes to the inode metadata) for - # *all* links to the file. Since we are basically always creating hard - # link farms in parallel as part of sandboxing, we have to disable this - # check as it is never valid for our build system and will result in - # spurious ccache panics where it randomly falls back to the real compiler - # if the ccache invocation happens to coincide with parallel sandbox - # creation for another sub-project. - lines.append(f"sloppiness = include_file_ctime") + else: + # On Windows the LLVM toolchain is compiled statically linked, + # therefore using content is sufficient to detect changes. + lines.append(f"compiler_check = content") + + # Sloppiness settings. + # include_file_ctime: + # Creating a hard link to a file increasing the link count, which triggers + # a ctime update (since ctime tracks changes to the inode metadata) for + # *all* links to the file. Since we are basically always creating hard + # link farms in parallel as part of sandboxing, we have to disable this + # check as it is never valid for our build system and will result in + # spurious ccache panics where it randomly falls back to the real compiler + # if the ccache invocation happens to coincide with parallel sandbox + # creation for another sub-project. + # pch_defines, time_macros: + # amd-llvm uses PCH on Windows builds by default, CMake will correctly + # use the appropriate compilation flags that ccache understands. See + # https://ccache.dev/manual/4.7.html#_precompiled_headers for details. + lines.append(f"sloppiness = include_file_ctime,pch_defines,time_macros") # End with blank line. lines.append("") diff --git a/cmake/therock_subproject.cmake b/cmake/therock_subproject.cmake index 1e33f66461..fd3a1538c8 100644 --- a/cmake/therock_subproject.cmake +++ b/cmake/therock_subproject.cmake @@ -834,6 +834,14 @@ function(therock_cmake_subproject_activate target_name) string(APPEND _init_contents "set(THEROCK_PKG_CONFIG_DIRS \"@_private_pkg_config_dirs@\")\n") string(APPEND _init_contents "${_compiler_toolchain_init_contents}") + + # Enable reproducible builds on Windows. /Brepro makes the linker (both + # MSVC link.exe and lld-link) zero out timestamps in PE headers, producing + # deterministic output. + if(WIN32) + string(APPEND _init_contents "add_link_options(\"LINKER:/Brepro\")\n") + endif() + if(_dep_provider_file) string(APPEND _init_contents "include(${_dep_provider_file})\n") endif()