Skip to content

Allow platform-specific startup bazelrc flags#26882

Closed
keith wants to merge 1 commit intomasterfrom
ks/allow-platform-specific-startup-bazelrc-flags
Closed

Allow platform-specific startup bazelrc flags#26882
keith wants to merge 1 commit intomasterfrom
ks/allow-platform-specific-startup-bazelrc-flags

Conversation

@keith
Copy link
Copy Markdown
Member

@keith keith commented Sep 3, 2025

This enables the use of startup:linux, startup:macos, etc. This is
always enabled.

Fixes #22763

RELNOTES[inc]: Add support for startup:linux, startup:macos, etc
bazelrc options.

@keith keith marked this pull request as ready for review September 3, 2025 15:51
@github-actions github-actions Bot added team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels Sep 3, 2025
@meisterT meisterT requested a review from gregestren September 11, 2025 10:16
@meisterT meisterT added team-Configurability platforms, toolchains, cquery, select(), config transitions and removed team-Rules-CPP Issues for C++ rules labels Sep 11, 2025
Copy link
Copy Markdown
Contributor

@gregestren gregestren left a comment

Choose a reason for hiding this comment

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

Idea LGTM. I'd update the docs to acknowledge startup support too (maybe just acknowledge on the https://bazel.build/run/bazelrc#enable_platform_specific_config).

And this one isn't triggered by the flag?

&& !command.equals(ALWAYS_PSEUDO_COMMAND)
&& !command.equals(COMMON_PSEUDO_COMMAND)) {
&& !command.equals(COMMON_PSEUDO_COMMAND)
&& !command.equals(STARTUP_PSEUDO_COMMAND)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What makes this necessary now if startup was already a known key?

Naively, couldn't the C++ code remove the arch-specific suffix so at this point Bazel sees the same generic startup setting it would see for any other it already processes?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

validCommands here is the literal subcommands like build, test etc, so it doesn't include startup. Without this addition this logic prints:

WARNING: while reading option defaults file '/private/tmp/foo/.bazelrc':
  invalid command name 'startup:linux'.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Naively, couldn't the C++ code remove the arch-specific suffix so at this point Bazel sees the same generic startup setting it would see for any other it already processes?

I think that would work, but I don't know of any downsides with this change either. I could imagine that version being worse for --announce_rc output but currently that doesn't show any difference AFAICT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

validCommands here is the literal subcommands like build, test etc, so it doesn't include startup

That makes sense. But why wasn't this an issue before with existing startup: --foo settings? I think somehow those are stripped out before they get to this point, but startup:linux isn't?

I think that would work, but I don't know of any downsides with this change either.

If that works, IMO it's a bit nicer in that it's a more isolated change. Just change a single function in the .cc file and no changes needed for this file?

I could imagine that version being worse for --announce_rc output but currently that doesn't show any difference AFAICT

If that's less accurate, that's a fair critique. What specifically might it say inaccurately? You didn't actually notice that happening?

To be clear, I'm not super-familiar with the C++ options parsing. These questions are mostly me trying to clarify my basic understanding of the surrounding code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ok my understanding of this has changed reading more.

before this change this logic would warn if you have something like startup:foo in your .bazelrc, since that was always invalid, with this change, that warning never appears (although we could keep it as long as we manually filtered out the known valid platform based ones)

but the C++ logic and this java parsing logic are entirely separate. they both parse the bazelrc separately, so I think we have to have changes in both places. the C++ logic doesn't forward it post-parse, it just applies the settings and drops its knowledge of things AFAICT.

@keith keith force-pushed the ks/allow-platform-specific-startup-bazelrc-flags branch from d962ff2 to 35d5d85 Compare September 20, 2025 04:15
@keith keith requested a review from fweikert as a code owner September 20, 2025 04:15
@keith
Copy link
Copy Markdown
Member Author

keith commented Sep 20, 2025

docs updated!

And this one isn't triggered by the flag?

correct. my thought was it wasn't worth gating since this couldn't have had previously functioning configs to conflict with (I think startup:foo --bar might have been accepted but never would have done anything).

I'm also hoping that in the future we can remove --enable_platform_specific_config, like an incompatible flag, if no major issues come up from having flipped the default so I didn't want to put more functionality behind it.

This enables the use of `startup:linux`, `startup:macos`, etc. This is
always enabled.

Fixes #22763

RELNOTES[inc]: Add support for `startup:linux`, `startup:macos`, etc
bazelrc options.
@keith keith force-pushed the ks/allow-platform-specific-startup-bazelrc-flags branch from 35d5d85 to d5945de Compare September 22, 2025 18:14
@meisterT
Copy link
Copy Markdown
Member

@gregestren is this good to be merged?

@keith
Copy link
Copy Markdown
Member Author

keith commented Mar 13, 2026

@gregestren friendly ping

@gregestren gregestren added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Apr 3, 2026
@fmeum
Copy link
Copy Markdown
Collaborator

fmeum commented Apr 4, 2026

@bazel-io fork 9.1.0

@copybara-service copybara-service Bot closed this in ea7b4ba Apr 7, 2026
@github-actions github-actions Bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Apr 7, 2026
iancha1992 pushed a commit to iancha1992/bazel that referenced this pull request Apr 8, 2026
This enables the use of `startup:linux`, `startup:macos`, etc. This is
always enabled.

Fixes bazelbuild#22763

RELNOTES[inc]: Add support for `startup:linux`, `startup:macos`, etc
bazelrc options.

Closes bazelbuild#26882.

PiperOrigin-RevId: 896083689
Change-Id: Id4da6e6689e337951664317755596cfd4ab52703
github-merge-queue Bot pushed a commit that referenced this pull request Apr 8, 2026
….com/baz… (#29251)

…elbuild/bazel/pull/26882)

This enables the use of `startup:linux`, `startup:macos`, etc. This is
always enabled.

Fixes #22763

RELNOTES[inc]: Add support for `startup:linux`, `startup:macos`, etc
bazelrc options.

Closes #26882.

PiperOrigin-RevId: 896083689
Change-Id: Id4da6e6689e337951664317755596cfd4ab52703

<!--
Thank you for contributing to Bazel!
Please read the contribution guidelines:
https://bazel.build/contribute.html
-->

### Description
<!--
Please provide a brief summary of the changes in this PR.
-->

### Motivation
<!--
Why is this change important? Does it fix a specific bug or add a new
feature?
If this PR fixes an existing issue, please link it here (e.g. "Fixes
#1234").
-->

### Build API Changes
<!--
Does this PR affect the Build API? (e.g. Starlark API, providers,
command-line flags, native rules)
If yes, please answer the following:
1. Has this been discussed in a design doc or issue? (Please link it)
2. Is the change backward compatible?
3. If it's a breaking change, what is the migration plan?
-->

No

### Checklist

- [ ] I have added tests for the new use cases (if any).
- [ ] I have updated the documentation (if applicable).

### Release Notes

<!--
If this is a new feature, please add 'RELNOTES[NEW]: <description>'
here.
If this is a breaking change, please add 'RELNOTES[INC]: <reason>' here.
If this change should be mentioned in release notes, please add
'RELNOTES: <reason>' here.
-->

RELNOTES: None

Commit
ea7b4ba

Co-authored-by: Keith Smiley <[email protected]>
iancha1992 added a commit to iancha1992/bazel that referenced this pull request Apr 9, 2026
….com/baz… (bazelbuild#29251)

…elbuild/bazel/pull/26882)

This enables the use of `startup:linux`, `startup:macos`, etc. This is
always enabled.

Fixes bazelbuild#22763

RELNOTES[inc]: Add support for `startup:linux`, `startup:macos`, etc
bazelrc options.

Closes bazelbuild#26882.

PiperOrigin-RevId: 896083689
Change-Id: Id4da6e6689e337951664317755596cfd4ab52703

<!--
Thank you for contributing to Bazel!
Please read the contribution guidelines:
https://bazel.build/contribute.html
-->

### Description
<!--
Please provide a brief summary of the changes in this PR.
-->

### Motivation
<!--
Why is this change important? Does it fix a specific bug or add a new
feature?
If this PR fixes an existing issue, please link it here (e.g. "Fixes
bazelbuild#1234").
-->

### Build API Changes
<!--
Does this PR affect the Build API? (e.g. Starlark API, providers,
command-line flags, native rules)
If yes, please answer the following:
1. Has this been discussed in a design doc or issue? (Please link it)
2. Is the change backward compatible?
3. If it's a breaking change, what is the migration plan?
-->

No

### Checklist

- [ ] I have added tests for the new use cases (if any).
- [ ] I have updated the documentation (if applicable).

### Release Notes

<!--
If this is a new feature, please add 'RELNOTES[NEW]: <description>'
here.
If this is a breaking change, please add 'RELNOTES[INC]: <reason>' here.
If this change should be mentioned in release notes, please add
'RELNOTES: <reason>' here.
-->

RELNOTES: None

Commit
bazelbuild@ea7b4ba

Co-authored-by: Keith Smiley <[email protected]>
github-merge-queue Bot pushed a commit that referenced this pull request Apr 9, 2026
This enables the use of `startup:linux`, `startup:macos`, etc. This is
always enabled.

Fixes #22763

RELNOTES[inc]: Add support for `startup:linux`, `startup:macos`, etc
bazelrc options.

Closes #26882.

PiperOrigin-RevId: 896083689
Change-Id: Id4da6e6689e337951664317755596cfd4ab52703

<!--
Thank you for contributing to Bazel!
Please read the contribution guidelines:
https://bazel.build/contribute.html
-->

### Description
<!--
Please provide a brief summary of the changes in this PR. -->

### Motivation
<!--
Why is this change important? Does it fix a specific bug or add a new
feature?
If this PR fixes an existing issue, please link it here (e.g. "Fixes
#1234").
-->

### Build API Changes
<!--
Does this PR affect the Build API? (e.g. Starlark API, providers,
command-line flags, native rules)
If yes, please answer the following:
1. Has this been discussed in a design doc or issue? (Please link it)
2. Is the change backward compatible?
3. If it's a breaking change, what is the migration plan? -->

No

### Checklist

- [ ] I have added tests for the new use cases (if any).
- [ ] I have updated the documentation (if applicable).

### Release Notes

<!--
If this is a new feature, please add 'RELNOTES[NEW]: <description>'
here.
If this is a breaking change, please add 'RELNOTES[INC]: <reason>' here.
If this change should be mentioned in release notes, please add
'RELNOTES: <reason>' here.
-->

RELNOTES: None

Commit

ea7b4ba

Co-authored-by: Keith Smiley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Configurability platforms, toolchains, cquery, select(), config transitions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow platform-specific startup options

4 participants