Skip to content

Avoid modifying frozen list#220

Merged
linzhp merged 1 commit intouber:mainfrom
linzhp:host
Apr 28, 2025
Merged

Avoid modifying frozen list#220
linzhp merged 1 commit intouber:mainfrom
linzhp:host

Conversation

@linzhp
Copy link
Copy Markdown
Contributor

@linzhp linzhp commented Apr 28, 2025

repository_ctx.attr.exec_platforms and its values are all frozen. We cannot remove host platforms from them. So when we have this in WORKSPACE:

RBE_PLATFORMS = {
    "linux": ["amd64", "arm64"],
}

zig_toolchains(
  exec_platforms = RBE_PLATFORMS
)

Builds would fail on Linux because:

        File "/home/user/.cache/bazel/_bazel_zplin/391a7464ab75ac3a8cb620cc52c50a30/external/hermetic_cc_toolchain/toolchain/private/repositories.bzl", line 75, column 22, in _zig_sdk_repository_impl
                _archs.remove(_arch)
Error in remove: trying to mutate a frozen list value
ERROR: Target parsing failed due to unexpected exception: trying to mutate a frozen list value

This PR creates a regular dictionary out of the frozen one so we can remove the host platforms from exec_platforms

@birunts can you review?

Copy link
Copy Markdown
Contributor

@birunts birunts left a comment

Choose a reason for hiding this comment

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

Oh, good spot! Thanks 🙂

LGTM!

@linzhp linzhp merged commit 608ea99 into uber:main Apr 28, 2025
6 checks passed
@linzhp linzhp deleted the host branch April 28, 2025 19:39
@albertocavalcante
Copy link
Copy Markdown

albertocavalcante commented Jun 15, 2025

@linzhp, can a 4.0.1 be released with this fix? Thanks!

@linzhp
Copy link
Copy Markdown
Contributor Author

linzhp commented Jun 16, 2025

released

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.

3 participants