Skip to content

Migrate from WORKSPACE to Bzlmod (Bazel 7-8, Ubuntu)#61

Open
smolkaj wants to merge 1 commit into
google:mainfrom
smolkaj:bzlmod
Open

Migrate from WORKSPACE to Bzlmod (Bazel 7-8, Ubuntu)#61
smolkaj wants to merge 1 commit into
google:mainfrom
smolkaj:bzlmod

Conversation

@smolkaj

@smolkaj smolkaj commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator

WORKSPACE → Bzlmod migration

New MODULE.bazel replaces the old WORKSPACE + p4_infra_deps.bzl dependency system. All deps now come from the Bazel Central Registry — no patches or overrides needed, thanks to grpc 1.80.0-pre1.

CI modernization

  • Build matrix: {ubuntu-22.04, ubuntu-latest} × {Bazel 7.x, 8.x}
  • Concurrency control: cancels preceding runs on the same PR
  • Smarter caching: duration-based save threshold (>3min), per-OS/Bazel-version cache keys

Code fixes for Bazel compatibility

  • p4_pdpi/ir_utils.cc: replaced std::optional::transform (C++23) with absl::optional + manual map
  • netaddr/network_address.h: removed redundant operator!= (C++20 synthesizes from operator==)
  • string_encodings/decimal_string_test_runner.cc: fixed test runner for Bzlmod runfiles

What's NOT in scope

  • Bazel 9: blocked by grpc 1.80.0-pre1 using native.cc_library (removed in Bazel 9).
  • macOS: blocked by p4c 1.2.5.11 using pipe2() (Linux-only). TODO in CI.
  • grpc API: grpc::Status-based public API is preserved — no breaking changes.

🤖 Generated with Claude Code

@smolkaj smolkaj force-pushed the bzlmod branch 3 times, most recently from f01dc4d to 615cc1e Compare March 11, 2026 23:01
@smolkaj smolkaj marked this pull request as ready for review March 11, 2026 23:06
@smolkaj smolkaj force-pushed the bzlmod branch 24 times, most recently from 9b5172a to f374dca Compare March 18, 2026 08:27
@smolkaj smolkaj changed the title Support Bzlmod, Bazel 7-9, Ubuntu 22.04/24.04, and macOS Migrate from WORKSPACE to Bzlmod (Bazel 7-8, Ubuntu) Mar 18, 2026
@smolkaj smolkaj changed the title Migrate from WORKSPACE to Bzlmod (Bazel 7-8, Ubuntu) Migrate from WORKSPACE to Bzlmod (Bazel 7-8, Ubuntu + macOS) Mar 18, 2026
@smolkaj smolkaj changed the title Migrate from WORKSPACE to Bzlmod (Bazel 7-8, Ubuntu + macOS) Migrate from WORKSPACE to Bzlmod (Bazel 7-8, Ubuntu) Mar 18, 2026
@smolkaj smolkaj force-pushed the bzlmod branch 4 times, most recently from 217e48f to a5a633c Compare March 18, 2026 16:07
Replace the legacy WORKSPACE + p4_infra_deps.bzl dependency system with a
MODULE.bazel file. All dependencies now come from the Bazel Central Registry,
including grpc 1.80.0-pre1 (no patches needed).

Bazel 9 is blocked by grpc 1.80.0-pre1 using native.cc_library (removed in
Bazel 9). macOS is blocked by p4c 1.2.5.11 using pipe2() (Linux-only).
smolkaj added a commit to smolkaj/sonic-pins that referenced this pull request Mar 19, 2026
Replace the legacy WORKSPACE + pins_infra_deps.bzl dependency system
with MODULE.bazel. All deps now come from the Bazel Central Registry
where possible; only otg_models and sonic_swss_common remain as
non-BCR deps via a module extension.

Key changes:

- 28 BCR bazel_dep() entries replace ~25 http_archive calls
- Delete local gutil/ and p4_infra/ forks; depend on upstream
  @gutil (BCR 20260309.0) and @p4_infra (pinned to smolkaj/p4-infra
  bzlmod branch via git_override, pending google/p4-infra#61)
- Extract sonic-pins-specific p4_runtime_session / matchers files
  to new p4rt_test_helpers/ package
- C++17 → C++20, Bazel 6.4.0 → 8.2.1
- GMP → boost.multiprecision (single call site in z3_util.cc)
- z3 dynamic → z3 static (BCR z3 dynamic has runfiles issues)
- Update ~840 #include paths (gutil/gutil/ → gutil/,
  p4_infra/p4_pdpi/ → p4_pdpi/, gnoi proto → github.com/openconfig/
  gnoi/ paths, etc.)
- Update golden files for new p4c 1.2.5.11 output
- Trim install_dependencies.sh to sonic_swss_common system deps only

Not yet working: p4rt_app/ (sonic_swss_common C++20 incompatibility).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@smolkaj smolkaj changed the title Migrate from WORKSPACE to Bzlmod (Bazel 7-8, Ubuntu) Migrate from WORKSPACE to Bzlmod, with WORKSPACE backwards compatibility Mar 19, 2026
@smolkaj smolkaj force-pushed the bzlmod branch 2 times, most recently from 9b4eb77 to 3f73359 Compare March 19, 2026 01:29
@smolkaj smolkaj changed the title Migrate from WORKSPACE to Bzlmod, with WORKSPACE backwards compatibility Migrate from WORKSPACE to Bzlmod (Bazel 7-8, Ubuntu) Mar 19, 2026
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.

1 participant