Skip to content

Conversation

@DoDoENT
Copy link
Contributor

@DoDoENT DoDoENT commented Oct 18, 2025

This adds support for using a prebuilt cache as an archive instead of building it from scratch every time.

This solves multiple problems:

  • build speed on CI machines that have cold cache
    • instead of building the secondary cache every time, it can simply download it
  • effective support for multiple caches (Bazel support for multiple emscripten caches #1581)
    • emscripten supports having multiple caches on its own, but it builds thinlto, lto, and other cache combinations on demand. This doesn't work in the Bazel world, where the cache needs to be frozen.
    • the current solution allowed building a secondary cache, but only with a single configuration
    • this allows the use of any archive that contain any emscripten cache
    • this PR does not handle how that cache is built - you can build it with embuilder, zip it and serve it from your server or whatever you want
  • secondary cache hermeticity problem
    • the current solution for secondary cache generated emscripten_config file that contained full path to the cache.
    • this was not hermetic as this path could be different on different machines
    • this PR calculates the cache path by using the same trick with environment variables, ensuring that emscripten_config file is always same, regardless of the machine
    • additionally, it ensures that the cache is provided as an input to the toolchain so that Bazel can correctly add it to the sandbox environment

After applying this patch to our internal codebase, the regular builds of WASM code went down from 12-15 minutes to cca 30 seconds, regardless on which machine it runs, as long as remote cache is warm.

@sbc100
Copy link
Collaborator

sbc100 commented Oct 18, 2025

@walkingeyerobot can you recommend anyone else who might be good to review this?

@DoDoENT DoDoENT force-pushed the feature/custom-cache branch from f260754 to 89182a9 Compare November 3, 2025 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants