Skip to content

Conversation

@albertocavalcante
Copy link
Contributor

@albertocavalcante albertocavalcante commented Jan 25, 2026

Adds support for platform-specific BAZELISK_VERIFY_SHA256 variables, enabling SHA256 verification in multiplatform projects.

Fixes #522

Problem

The current BAZELISK_VERIFY_SHA256 only accepts a single hash value, but Bazel binaries have different SHA256 hashes per platform. Projects building on multiple platforms cannot use SHA256 verification.

Solution

Since each platform has a different binary with a different hash, Bazelisk now supports platform-specific hash variables:

  • BAZELISK_VERIFY_SHA256_<OS>_<ARCH> - hash for a specific platform (e.g., BAZELISK_VERIFY_SHA256_LINUX_X86_64)
  • BAZELISK_VERIFY_SHA256_NOJDK_<OS>_<ARCH> - hash for nojdk builds (when BAZELISK_NOJDK is enabled)
  • BAZELISK_VERIFY_SHA256 - fallback used when no platform-specific hash is set

Supported Platforms

OS Architectures
DARWIN ARM64, X86_64
LINUX ARM64, X86_64
WINDOWS ARM64, X86_64

Example .bazeliskrc

BAZELISK_VERIFY_SHA256_DARWIN_ARM64=2c3cce548a4b6a97a2a5267712187b784b52714c4a2b0613e7386b15669d783c
BAZELISK_VERIFY_SHA256_DARWIN_X86_64=aa7e5fc364eaaba7f4f271dbf8c14172a5433f663cca6b130325df4b6569b3f0
BAZELISK_VERIFY_SHA256_LINUX_X86_64=c44a93f25398c68f904fa1d19b61d321de6c0d2f09dca375d7bc0dc9b9428403
BAZELISK_VERIFY_SHA256_LINUX_ARM64=cab23c59d3d39c5e5382f12cd116b47445afdff9813516c18ae3ee8836b3037f
BAZELISK_VERIFY_SHA256_WINDOWS_X86_64=463faee497df2913854d80776784137cb47f42960b4ef4e4f85068c8da4849a8
BAZELISK_VERIFY_SHA256_WINDOWS_ARM64=ab3db0b1f129436180927baa0f1f38e6d86a88fc9ee802572a76c9519a06f550

Implementation Notes

  • Refactored downloadBazelIfNecessary to compute platform info once upfront
  • Added FormatBazelFilename helper in platforms package
  • Hash normalized to lowercase once at return (SHA256 hex is case-insensitive)
  • Full backward compatibility with existing BAZELISK_VERIFY_SHA256

Test Plan

  • Unit tests for getExpectedSHA256 (7 focused tests)
  • Unit tests for FormatBazelFilename (2 tests)
  • Shell integration test with Bazel 9.0.0 (all 6 platform/arch combinations)
  • All existing tests pass

@albertocavalcante albertocavalcante force-pushed the feat/platform-specific-sha256-verification branch 9 times, most recently from 658831a to 76873b5 Compare January 25, 2026 15:56
@albertocavalcante albertocavalcante force-pushed the feat/platform-specific-sha256-verification branch from 76873b5 to f78653c Compare January 25, 2026 15:57
Adds support for platform-specific BAZELISK_VERIFY_SHA256 variables,
enabling SHA256 verification in multiplatform projects.

Bazelisk now checks for configuration in the following order:
1. BAZELISK_VERIFY_SHA256_NOJDK_<OS>_<ARCH> (when BAZELISK_NOJDK is enabled)
2. BAZELISK_VERIFY_SHA256_<OS>_<ARCH>
3. BAZELISK_VERIFY_SHA256 (existing behavior, fallback)

Implementation notes:
- Refactored downloadBazelIfNecessary to compute platform info once upfront
- Added FormatBazelFilename helper to avoid redundant OS/arch computation
- Hash values normalized to lowercase for case-insensitive comparison
- Full backward compatibility maintained

Fixes bazelbuild#522
@albertocavalcante albertocavalcante force-pushed the feat/platform-specific-sha256-verification branch from f78653c to 81f96d5 Compare January 28, 2026 20:33
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.

Support BAZELISK_VERIFY_SHA256 for multiplatform projects

1 participant