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

Use boolean instead of string parameter for repeatable Starlark flags #266

Merged
merged 2 commits into from
Jul 11, 2022

Conversation

fmeum
Copy link
Contributor

@fmeum fmeum commented Jun 30, 2022

@aranguyen @gregestren This is the update to the proposal following the result of our discussion.


```
--copt=a,b,c --> ["a,b,c"]
--copt=a --copt=b,c --> ["a", "b,c"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok the example really make the paragraph clearer. Thanks. Why can't this be ["a", "b", "c"]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could, but I think that it shouldn't:

If we pass ["a", "b,c"] to the build setting implementation function unprocessed, it is free to turn this into ["a", "b", "c"] and pass it on to consumers via a provider in that form.

But if we pass ["a", "b", "c"] directly, we forcibly remove information that the build setting implementation function wouldn't be able to recover. For example, this would mess up linker flags such as -Wl,--enable-auto-import.

Given that build settings can already do any post-processing they require in Starlark, I would opt for doing as little pre-processing as possible within Bazel.

Copy link
Contributor

@aranguyen aranguyen Jul 6, 2022

Choose a reason for hiding this comment

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

Thanks for the explanation. I'm not familiar with the linker flags mentioned. Could you elaborate on how having ["a", "b", "c"] would mess them up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you have a (hypothetical) Starlark version of the native --copt, then you may want to pass in -Wl,--enable-auto-import as a single argument. But if all repeated flags also split on ,, then this would be impossible: The final list of args would always include two separate args -Wl and --enable-auto-import, which changes semantics (in fact, in the case of this particular flag, this would likely lead to a compiler error).

fmeum added 2 commits July 7, 2022 20:53
@aranguyen @gregestren This is the update to the proposal following the result of our discussion.
Copy link
Contributor

@aranguyen aranguyen left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@fmeum
Copy link
Contributor Author

fmeum commented Jul 8, 2022

This looks good to me.

Thanks! Could you merge? I don't have the rights.

@aranguyen aranguyen merged commit 823973e into bazelbuild:main Jul 11, 2022
@aranguyen
Copy link
Contributor

Done! FYI, I'm working on your PR and will update as soon as I can.

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