Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep order for PATH components #4252

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

lukasoyen
Copy link
Contributor

@lukasoyen lukasoyen commented Feb 7, 2025

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

The starlark dict already will return items in the order in which they where inserted on iteration. There is no need to explicitly sort the items. But it does break use cases, where the user has explicitly defined a order of PATH components. As for example is possible with the env attribute of cc_args() with the new rule_cc based toolchains.

Which issues(s) does this PR fix?

Fixes #

Other notes for review

The starlark `dict` already will return items in the order in which
they where inserted on iteration. There is no need to explicitly
sort the items. But it does break use cases, where the user has
explicitly defined a order of `PATH` components. As for example
is possible with the `env` attribute of `cc_args()` with the new
`rule_cc` based toolchains.
Copy link
Contributor

@jayconrod jayconrod left a comment

Choose a reason for hiding this comment

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

We chatted on Bazel Slack earlier. I don't remember why this was sorted originally, but I think it was paranoia to keep the path list in a deterministic order. The Starlark spec says that dict iteration order is deterministic, same as insertion order, so this paranoia was not justified.

@jayconrod jayconrod merged commit 8c95bcf into bazel-contrib:master Feb 7, 2025
1 check passed
@lukasoyen lukasoyen deleted the keep-path-order branch February 10, 2025 07:37
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