Skip to content

Conversation

@genedna
Copy link
Member

@genedna genedna commented Jan 21, 2026

No description provided.

Signed-off-by: Eli Ma <eli@patch.sh>
Copilot AI review requested due to automatic review settings January 21, 2026 12:34
@github-actions
Copy link

github-actions bot commented Jan 21, 2026

Claude finished @genedna's task in 2m 58s —— View job


Code Review Complete ✓

Reviewed PR #83: Upgrade the buck2 support with newest buckal

Tasks

  • Read repository guidelines (CLAUDE.md)
  • Review core configuration changes (PACKAGE, .buckconfig)
  • Review toolchain modifications
  • Sample third-party BUCK file changes
  • Assess impact of deleted files
  • Check documentation completeness
  • Provide comprehensive review feedback

Summary

This PR upgrades the buck2 build system to use the newest version of buckal (cargo-buckal), transitioning from a manual configuration to a more automated, generated approach. The changes involve:

  • Migration from buckal.toml to a generated PACKAGE file
  • Updates to .buckconfig to use buckal bundles from GitHub
  • Regenerated third-party dependency BUCK files with new patterns
  • Version upgrades: thiserror 2.0.17→2.0.18, colored 3.0.0→3.1.1
  • New platform and toolchain configuration files
  • Removal of obsolete README documentation

Overall Assessment

Status: APPROVE with minor recommendations ⚠️

The upgrade appears well-structured and follows the new buckal conventions. However, there are several areas that need attention:


Critical Issues

None identified - the changes appear safe and consistent.


High Priority Concerns

1. Missing PR Description

Severity: High

The PR has no description explaining:

  • Why this upgrade is needed
  • What version of buckal is being used
  • What testing was performed
  • Whether buck2 builds were verified

Recommendation: Add a PR description covering:

- Buckal version being upgraded to
- Motivation for the upgrade (new features, bug fixes, etc.)
- Testing performed (cargo build, buck2 build, etc.)
- Breaking changes or migration notes

2. Documentation Gap

File: third-party/README.md (DELETED)
Lines: N/A

The deletion of third-party/README.md removes all documentation about:

  • How to install buckal
  • How to add dependencies
  • How to use cargo buckal commands
  • Prerequisites (Buck2, Python 3)

Recommendation:

  • Either restore this documentation in a different location (root README or docs/)
  • Or update the main README.md to include buck2/buckal setup instructions
  • Consider adding a BUILDING.md file with build system documentation

Fix this →


Medium Priority Issues

3. .gitignore Change Unclear

File: .gitignore:12

-examples/output_packs
+examples/output_packs/buck-out

This change narrows the ignore pattern from ignoring the entire examples/output_packs directory to only ignoring examples/output_packs/buck-out.

Questions:

  • Is this intentional? Should examples/output_packs content now be tracked?
  • Was this pattern correction necessary for the buckal upgrade?

Recommendation: Clarify the intention behind this change in the PR description.

4. Windows Support Dependencies Removed

Files:

  • third-party/rust/crates/windows-sys/0.59.0/BUCK (deleted)
  • third-party/rust/crates/windows-targets/0.52.6/BUCK (deleted)
  • third-party/rust/crates/windows_**/0.52.6/BUCK (8 files deleted)

These Windows-specific dependencies were removed, but:

  • The main BUCK file still references windows-sys/0.61.2 for colored and tokio
  • Platform support includes x86_64-pc-windows-msvc in platforms/BUCK:19-26

Recommendation:

  • Verify that Windows builds still work with the new versions
  • Document any Windows platform testing performed
  • Consider adding CI checks for Windows builds if not present

5. Toolchain Configuration Simplified

File: toolchains/BUCK

The toolchain configuration was dramatically simplified:

  • Removed: Go, Haskell, OCaml toolchain configurations
  • Removed: oncall("open_source") annotation
  • Added: Custom demo toolchains via separate .bzl files

Observations:

  • This is good - removes unused toolchains
  • The custom CXX toolchain avoids forcing lld (good for compatibility)
  • Rust edition changed from 2024 → 2021 in demo_rust.bzl:16

⚠️ Potential Issue: CLAUDE.md:64 states "Language: Rust Edition 2024", but toolchains/rust/demo_rust.bzl:16 sets default_edition = "2021".

Recommendation: Either:

  • Update demo_rust.bzl to use edition 2024, or
  • Update CLAUDE.md if edition 2021 is intentional

Fix this →

6. New Toolchain Helper Files

Files Added:

  • toolchains/cxx/tools/lld_link.py
  • toolchains/cxx/tools/*.bat files

These appear to be Windows MSVC linker wrappers, but:

  • No documentation about their purpose
  • The Python script (112 lines) has no inline documentation
  • Batch files have minimal context

Recommendation: Add header comments explaining their purpose and usage.


Low Priority / Style Issues

7. All BUCK Files Now Marked @generated

All modified BUCK files now start with:

# @generated by `cargo buckal`

This is correct and follows the new buckal pattern. However:

  • Developers should know not to manually edit these files
  • Consider adding a .editorconfig or pre-commit hook to prevent manual edits

8. Third-Party BUCK Pattern Changes

The third-party BUCK files now use a more consistent pattern:

  • http_archive for downloading crates from static.crates.io
  • cargo_manifest for parsing Cargo.toml
  • Simplified dependency declarations

Example (colored/3.1.1/BUCK):

http_archive(
    name = "colored-vendor",
    urls = ["https://static.crates.io/crates/colored/colored-3.1.1.crate"],
    sha256 = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34",
    ...
)

This is good - improves reproducibility and hermetic builds.

9. Buckal Bundle Configuration

File: .buckconfig:24-26

[external_cell_buckal]
  commit_hash = 22bd38c79d2348d9a6591b7156c42d615377eaad
  git_origin = https://github.com/buck2hub/buckal-bundles

This pins buckal to a specific commit. Good for reproducibility, but:

  • No context about what version this commit represents
  • No changelog or release notes linked

Recommendation: Add a comment above this section noting the buckal version/date.


Testing Recommendations

Since I cannot run buck2 commands without the tool installed, I recommend:

  1. Build Verification:

    buck2 build //:git_internal
    cargo build  # Ensure cargo still works
  2. Platform Testing:

    • Test on Linux (primary platform based on CI)
    • Test on Windows if supported
    • Test on macOS if supported
  3. Dependency Resolution:

    cargo buckal migrate  # Verify buckal migration works
  4. Integration Testing:

    • Run the full test suite: cargo test
    • Verify examples still build

Code Quality Assessment

Positive Aspects ✓

  • Consistent code generation with @generated markers
  • Improved hermetic builds with http_archive
  • Cleaner toolchain configuration
  • Proper SHA-256 checksums for all downloaded crates
  • Removed unused toolchain configurations
  • Upgraded dependencies (thiserror, colored)

Security ✓

  • All crate downloads use HTTPS URLs
  • SHA-256 checksums present for integrity verification
  • No obvious security vulnerabilities introduced

Performance ✓

  • Should have no performance impact (build-time only)
  • The new buckal approach may improve build reproducibility

Final Recommendations

  1. Add PR description with upgrade details and testing notes
  2. Restore buckal documentation somewhere in the repo
  3. Fix Rust edition mismatch (2024 vs 2021)
  4. Clarify .gitignore change intention
  5. Document Windows platform testing or note if unsupported
  6. Add comments to new toolchain helper scripts
  7. Consider adding CI check for buck2 builds

Overall, this is a solid upgrade that modernizes the buck2 configuration. With the documentation gaps addressed, this should be good to merge.


Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc161c193c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +10 to +13
rustc_target_triple = select({
"prelude//os/constraints:linux": "x86_64-unknown-linux-gnu",
"prelude//os/constraints:macos": "aarch64-apple-darwin",
"prelude//os/constraints:windows": "x86_64-pc-windows-msvc",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fix macOS target triple for x86_64 hosts

The new toolchain hardcodes prelude//os/constraints:macos to aarch64-apple-darwin, which forces Intel macs to build for arm64. On x86_64 macOS, rustc will try to cross-compile and typically fails unless the arm64 stdlib/SDK is installed, which is a regression from the prior host-based mapping. Consider selecting on CPU constraints (e.g., prelude//cpu/constraints:x86_64 vs arm64) or adding an x86_64 triple so Intel mac builds still target their native architecture.

Useful? React with 👍 / 👎.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the Buck2 build system integration by migrating to the newest version of buckal (cargo-buckal). The upgrade modernizes the build configuration with improved toolchain definitions, platform specifications, and dependency management patterns.

Changes:

  • Added custom toolchain configurations (Rust and C++ with OS-specific compiler selection)
  • Migrated dependency patterns from select() to os_deps/os_named_deps for cleaner syntax
  • Added platform definitions for cross-compilation support
  • Updated buckal bundle to newer commit (22bd38c79d2348d9a6591b7156c42d615377eaad)

Reviewed changes

Copilot reviewed 56 out of 57 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
toolchains/rust/demo_rust.bzl New Rust toolchain with platform-specific target triples
toolchains/cxx/demo_cxx.bzl New C++ toolchain avoiding lld requirement, using gcc/bfd on Linux
toolchains/cxx/tools/lld_link.py Python wrapper for Windows linker, auto-detecting Rust sysroot
toolchains/cxx/tools/*.bat Architecture-specific Windows batch launchers for linker
toolchains/BUCK Simplified toolchain setup using new demo configurations
platforms/BUCK New platform definitions for aarch64-darwin, x86_64-windows-msvc, x86_64-linux-gnu
PACKAGE Added cfg modifiers and constructor for build mode aliases
.buckconfig Updated buckal bundle commit, alphabetized cells
BUCK Removed test targets (likely intentional for buckal-generated code)
third-party/rust/crates/*/BUCK Migrated 30+ crate BUCK files from select() to os_deps pattern
third-party/rust/crates/*/0.52.6/BUCK Removed unused Windows crate versions (0.52.6)
third-party/README.md Removed buckal installation/usage documentation
.gitignore Made pattern more specific (buck-out subdir only)
buckal.toml Removed configuration file


g++ -L"%SELF_CONTAINED%" %*
set "STATUS=!ERRORLEVEL!"
exit /b %STATUS%
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With EnableDelayedExpansion enabled, variable expansion should use !VAR! syntax for consistency, especially when the variable was just set. The STATUS variable is set on the previous line, so it should be accessed using !STATUS! instead of %STATUS% to ensure the correct value is used.

Copilot uses AI. Check for mistakes.
@@ -1,43 +1,21 @@
# @generated by `cargo buckal`

load("@//cxx:demo_cxx.bzl", "system_demo_cxx_toolchain")
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The load path @//cxx:demo_cxx.bzl is incorrect. When loading from within the toolchains cell, @// refers to the root cell, not the toolchains cell. The file cxx/demo_cxx.bzl does not exist at the root of the repository; it exists at toolchains/cxx/demo_cxx.bzl. The correct path should be //cxx:demo_cxx.bzl (without the @) to load from the current cell, or @toolchains//cxx:demo_cxx.bzl to explicitly reference the toolchains cell.

Copilot uses AI. Check for mistakes.
"system_python_toolchain",
)
load("@prelude//toolchains:remote_test_execution.bzl", "remote_test_execution_toolchain")
load("@//rust:demo_rust.bzl", "system_demo_rust_toolchain")
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The load path @//rust:demo_rust.bzl is incorrect. When loading from within the toolchains cell, @// refers to the root cell, not the toolchains cell. The file rust/demo_rust.bzl does not exist at the root of the repository; it exists at toolchains/rust/demo_rust.bzl. The correct path should be //rust:demo_rust.bzl (without the @) to load from the current cell, or @toolchains//rust:demo_rust.bzl to explicitly reference the toolchains cell.

Copilot uses AI. Check for mistakes.
# @generated by `cargo buckal`

load("@prelude//cfg/modifier:set_cfg_modifiers.bzl", "set_cfg_modifiers")
load("@prelude//rust:with_workspace.bzl", "with_rust_workspace")
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import with_rust_workspace is loaded but never used in this file. This import should be removed to keep the code clean and avoid confusion.

Suggested change
load("@prelude//rust:with_workspace.bzl", "with_rust_workspace")

Copilot uses AI. Check for mistakes.
if not defined NEED_SELF_CONTAINED (
g++ %*
set "STATUS=!ERRORLEVEL!"
exit /b %STATUS%
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within a compound statement (parentheses block) with EnableDelayedExpansion, variable expansion should use !VAR! syntax instead of %VAR%. The STATUS variable is set on the previous line within this block, so it should be accessed using !STATUS! instead of %STATUS% to get the correct value. The current code may exit with an undefined or stale value.

Copilot uses AI. Check for mistakes.
@genedna genedna merged commit 096151b into web3infra-foundation:main Jan 21, 2026
17 checks passed
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