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

Remove objc_library transition #16870

Open
keith opened this issue Nov 28, 2022 · 11 comments
Open

Remove objc_library transition #16870

keith opened this issue Nov 28, 2022 · 11 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-ObjC Issues for Objective-C maintainers type: feature request

Comments

@keith
Copy link
Member

keith commented Nov 28, 2022

Through the discussion on this issue it came up that we might want to remove the objc_library transition. I also think this might be a blocker to some changes like this where we would like to change the transition in rules_apple to support this case, but a similar transition is duplicated here and likely needs to be kept roughly in sync.

We heard at bazelcon that some folks at google might be looking into removing this, so I wanted to file this tracking issue for discussion

@keith
Copy link
Member Author

keith commented Nov 28, 2022

I started looking at providing an incompatible flag for removing this, but unsurprisingly it breaks some tests, I haven't started debugging since I figure the real blocker will be making google compatible, in which case I'm not sure how feasible this is to do from the outside

@keith
Copy link
Member Author

keith commented Nov 28, 2022

@katre
Copy link
Member

katre commented Nov 28, 2022

@trybka This is relevant to your interests.

@trybka
Copy link
Contributor

trybka commented Nov 28, 2022

It's not terrible to fix internally, but not trivial, either.
I'd really like to get rid of this, but at the moment it's mostly just difficult to justify the time/effort for said depot-wide cleanup.

Most issues were fairly straightforward: like migrating from a build_test like rule to one which does the transition (e.g. ios_build_test).

There were some harder ones where folks are doing clever things with the unconfigured target graph and expecting objc_library to not break, but don't need anything from it either. In those cases, the top-level target might not be appropriate to transition itself. I think it would be sufficient to allow the target to analyze as it would not be needing the result.

I was considering some kind of tristate where the transition is either on/soft-off/hard-off. For soft/hard, it either reports an error if it cannot configure, say, objc-compile actions, or silently returns an empty CcInfo provider. This would allow us to get errors to find build tests that need fixing, and maybe we can force our build test rules to hard error once the migration is complete, and we can leave these other things that just "happen to" depend on objc_library to silently just not configure their actions.

WDYT?

@keith
Copy link
Member Author

keith commented Nov 28, 2022

I guess that solution is at a slightly different level that what I was thinking about in the transition itself, which I was mostly just making a no-op with the incompatible flag. At what point would the starlark implementation know enough about whether or not it would be configurable to be able to make the decision of soft/hard fail?

@trybka
Copy link
Contributor

trybka commented Nov 28, 2022

I was being somewhat imprecise there.
Making the transition a no-op (optionally) is a good first step (that would control one piece).

Then, in the Starlark rule impl, we can just check to see whether the action is enabled or not.

Something like this:

    if not cc_common.action_is_enabled(
        feature_configuration = feature_configuration,
        action_name = "objc-compile",
    ):  
        if ctx.fragments.objc.enable_unconfigured_library():
            return [CcInfo()]
        else:
            fail("objc_library is not configured for this platform.")

@sgowroji sgowroji added type: feature request untriaged team-Rules-ObjC Issues for Objective-C maintainers labels Nov 29, 2022
@gregestren
Copy link
Contributor

Whatever the details, I think when the phrase "depot cleanup" comes up it's perfectly reasonable to flag-gate functionality and allow Bazel and Google to migrate on their own timelines. Depot cleanups are often involved, long, and by nature org-specific. I'm still struggling with this for config_setting visibility.

For Bazel, we'd have to similarly check we don't get downstream breakages?

@sventiffe
Copy link
Contributor

@meteorcloudy for Greg's question about downstream breakages

@meteorcloudy
Copy link
Member

For Bazel, we'd have to similarly check we don't get downstream breakages?

If this change can be enabled by a flag, you can follow our breaking change process to test it in https://buildkite.com/bazel/bazelisk-plus-incompatible-flags.

You can also run a downstream testing against your custom version of Bazel: https://github.com/bazelbuild/continuous-integration/blob/master/docs/downstream-testing.md

keith added a commit to keith/bazel that referenced this issue Aug 15, 2023
This is a migration for bazelbuild#16870

Users who rely on the current behavior should instead wrap their library
in a target from [rules_apple](https://github.com/bazelbuild/rules_apple).
@keith
Copy link
Member Author

keith commented Aug 15, 2023

I submitted a flag for an incompatible change here #19256

and actually @trybka in the change moving the toolchain to apple_support I did something similar as you mention above, so I think we've already solved that case.

def _check_toolchain_supports_objc_compile(ctx, cc_toolchain):
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
language = "objc",
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
)
if not cc_common.action_is_enabled(
feature_configuration = feature_configuration,
action_name = "objc-compile",
):
fail("Compiling objc_library targets requires the Apple CC toolchain " +
"which can be found here: https://github.com/bazelbuild/apple_support#toolchain-setup")

keith added a commit to keith/bazel that referenced this issue Aug 22, 2023
This is a migration for bazelbuild#16870

Users who rely on the current behavior should instead wrap their library
in a target from [rules_apple](https://github.com/bazelbuild/rules_apple).
keith added a commit to keith/bazel that referenced this issue Aug 25, 2023
This is a migration for bazelbuild#16870

Users who rely on the current behavior should instead wrap their library
in a target from [rules_apple](https://github.com/bazelbuild/rules_apple).
copybara-service bot pushed a commit that referenced this issue Aug 30, 2023
This is a migration for #16870

Users who rely on the current behavior should instead wrap their library in a target from [rules_apple](https://github.com/bazelbuild/rules_apple).

Fixes #19204

Closes #19256.

PiperOrigin-RevId: 561253613
Change-Id: I1b1b24a08caa33e86881bfe376a525060c9887a9
keith added a commit to keith/bazel that referenced this issue Sep 1, 2023
This is a migration for bazelbuild#16870

Users who rely on the current behavior should instead wrap their library in a target from [rules_apple](https://github.com/bazelbuild/rules_apple).

Fixes bazelbuild#19204

Closes bazelbuild#19256.

PiperOrigin-RevId: 561253613
Change-Id: I1b1b24a08caa33e86881bfe376a525060c9887a9
(cherry picked from commit 0f34e76)
@erikmchut
Copy link

Thanks for working on this change. I use a custom toolchain for objc compilation, and the built-in apple transition causes unexpected configuration changes that are difficult to work around.

keith added a commit to keith/bazel that referenced this issue Sep 6, 2023
This is a migration for bazelbuild#16870

Users who rely on the current behavior should instead wrap their library in a target from [rules_apple](https://github.com/bazelbuild/rules_apple).

Fixes bazelbuild#19204

Closes bazelbuild#19256.

PiperOrigin-RevId: 561253613
Change-Id: I1b1b24a08caa33e86881bfe376a525060c9887a9
(cherry picked from commit 0f34e76)
iancha1992 pushed a commit that referenced this issue Sep 6, 2023
This is a migration for #16870

Users who rely on the current behavior should instead wrap their library
in a target from
[rules_apple](https://github.com/bazelbuild/rules_apple).

Closes #19383.

PiperOrigin-RevId: 561253613
Change-Id: I1b1b24a08caa33e86881bfe376a525060c9887a9 (cherry picked from
commit 0f34e76)
@keith keith added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-ObjC Issues for Objective-C maintainers type: feature request
Projects
None yet
Development

No branches or pull requests

8 participants