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

Add and flip --incompatible_locations_prefers_executable #24690

Closed
wants to merge 1 commit into from

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Dec 13, 2024

Work towards #11820
Fixes #20038
Fixes #23200
Fixes #24613

RELNOTES: Extra targets provided to ctx.expand_location now expand to their executable (if any) instead of resulting in an error if they provide a number of files different from one.

RELNOTES[INC]: The --incompatible_locations_prefers_executable flag has been added and enabled, which makes it so that ctx.expand_location expands $(locations :x) to the executable of an extra target :x if it provides one and the number of files provided by it is not one.

@fmeum fmeum requested review from a team and lberki as code owners December 13, 2024 16:58
@fmeum fmeum requested review from katre and removed request for a team December 13, 2024 16:58
@github-actions github-actions bot added team-Configurability platforms, toolchains, cquery, select(), config transitions team-Rules-ObjC Issues for Objective-C maintainers awaiting-review PR is awaiting review from an assigned reviewer labels Dec 13, 2024
@fmeum fmeum requested review from brandjon and removed request for lberki and katre December 13, 2024 16:58
RELNOTES: Extra targets provided to `ctx.expand_location` now expand to their executable (if any) instead of resulting in an error if they provide a number of files different from one.
RELNOTES[INC]: The `--incompatible_locations_prefers_executable` flag has been added and enabled, which makes it so that `ctx.expand_location` expands `$(locations :x)` to the executable of an extra target `:x` if it provides one and the number of files provided by it is not one.
@fmeum fmeum force-pushed the 24613-incompatible branch from 8667744 to 755b7d3 Compare December 13, 2024 16:59
@fmeum
Copy link
Collaborator Author

fmeum commented Dec 13, 2024

@brandjon Yun and I agreed that a minor incompatible change would be acceptable even for 8.0.1. Based on that, I personally find this to be the less surprising (and simpler) solution to the linked issues (most importantly the regression #24613) than the fully backwards compatible change that only modifies the behavior of $(location ...) but not $(locations ...).

An alternative could be to always prefer the executable, even over a single file, as is the case for location expansion on the hardcoded list of attributes. I could see this being much more breaking, e.g. thinking of a WASM binary that sets its executable to an interpreter that runs the actual artifact.

Your opinion and ideas would be very welcome!

@brandjon
Copy link
Member

Delegating to @comius as this is more analysis-time rule logic than loading phase stuff.

@brandjon brandjon requested review from comius and removed request for brandjon December 13, 2024 19:18
@Wyverald
Copy link
Member

Wyverald commented Jan 8, 2025

@comius do you think it's a good idea to get this in soon (within the week)? If not, we should take this off the 8.0.1 blocker list.

@comius comius 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 Jan 8, 2025
@copybara-service copybara-service bot closed this in 457d248 Jan 9, 2025
@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 Jan 9, 2025
fmeum added a commit to fmeum/bazel that referenced this pull request Jan 9, 2025
Work towards bazelbuild#11820
Fixes bazelbuild#20038
Fixes bazelbuild#23200
Fixes bazelbuild#24613

RELNOTES: Extra targets provided to `ctx.expand_location` now expand to their executable (if any) instead of resulting in an error if they provide a number of files different from one.

RELNOTES[INC]: The `--incompatible_locations_prefers_executable` flag has been added and enabled, which makes it so that `ctx.expand_location` expands `$(locations :x)` to the executable of an extra target `:x` if it provides one and the number of files provided by it is not one.

Closes bazelbuild#24690.

PiperOrigin-RevId: 713453768
Change-Id: I0d6e052bc70deea029554ab722feb544f9597a23
(cherry picked from commit 457d248)
github-merge-queue bot pushed a commit that referenced this pull request Jan 9, 2025
…24874)

Work towards #11820
Fixes #20038
Fixes #23200
Fixes #24613

RELNOTES: Extra targets provided to `ctx.expand_location` now expand to
their executable (if any) instead of resulting in an error if they
provide a number of files different from one.

RELNOTES[INC]: The `--incompatible_locations_prefers_executable` flag
has been added and enabled, which makes it so that `ctx.expand_location`
expands `$(locations :x)` to the executable of an extra target `:x` if
it provides one and the number of files provided by it is not one.

Closes #24690.

PiperOrigin-RevId: 713453768
Change-Id: I0d6e052bc70deea029554ab722feb544f9597a23 
(cherry picked from commit 457d248)

Fixes #24646
@fmeum fmeum deleted the 24613-incompatible branch January 10, 2025 08:18
@thesayyn
Copy link
Contributor

Thank you @fmeum for the patch, i really wanted to contribute this myself but you beat me to it :)

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 team-Rules-ObjC Issues for Objective-C maintainers
Projects
None yet
5 participants