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

[Retry] Fix transitive framework import in opt build #718

Merged

Conversation

qyang-nj
Copy link
Contributor

@qyang-nj qyang-nj commented May 10, 2023

Retry merging PR #570, which solves issue #569. The original PR got reverted because of issue #712.

Original description

apple_*_(xc)framework_import provides _SwiftInteropInfo instead of SwiftInfo. In apple_framework_packaging, when we merge the SwiftInfo, the info from the framework import get lost there.

To fix the problem, we can add swift_clang_module_aspect to the transitive_deps attribute of apple_framework_packaging, which converts _SwiftInteropInfo to SwiftInfo. swift_library does this for deps as well.

@mattrobmattrob @thiagohmcruz

@qyang-nj qyang-nj force-pushed the qing--retry-framework-aspect branch from e368674 to a85465c Compare May 10, 2023 19:27
@qyang-nj qyang-nj changed the title Retry #570 [Retry] Fix transitive framework import in opt build May 10, 2023
cc_info = objc_provider_utils.merge_cc_info_providers(
cc_info_providers = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep],
)
additional_providers.append(cc_info)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This custom merging logic caused a problematic modulemap is generated. I'm not sure why we are merging CcInfo differently depending on whether VFS is used, but all CI jobs are passed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll be able to look at this change more in depth a bit later in the week or early next; a lot of times we can't rely on "green" CI status for most of this logic. There was some reasons to do this on Bazel 4; which I'm not sure exist still..

Is there a way that you'd add an example of how you're using a transitive import that wasn't working incase we need to fix that in a different way?

Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to though right? If we can't rely on CI being 🟢 here then I think we should look into it and make CI start checking for whatever is necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I have the repro example in the issue #569 and the repro code here. I thought about adding it to CI tests, but realized we don't have any tests run under --compilation_mode=opt. Maybe we can add that.

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM! Yeah it'd be nice to improve the coverage for the things we can, I can dig more into this early next week.

@qyang-nj qyang-nj marked this pull request as ready for review May 10, 2023 20:57
@mattrobmattrob
Copy link
Collaborator

Running an integration test in our repo now. Do you mind doing the same when you have time, @thiagohmcruz?

Copy link
Collaborator

@mattrobmattrob mattrobmattrob left a comment

Choose a reason for hiding this comment

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

LGTM in our project. Let's let the Square/Block folks give it a test in their codebase before we merge though. 🙏

@@ -55,29 +55,9 @@ def _merge_dynamic_framework_providers(dynamic_framework_providers):

return apple_common.new_dynamic_framework_provider(**fields)

def _merge_cc_info_providers(cc_info_providers, merge_keys = [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this is not used anywhere else.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok I just found out we use this internally and this removal broke things for us. Was it necessary to remove it to unblock your intended change? If not can we put it back for now while we discuss where this code should live?

Ideally we would add a test that exercises this then, maybe this shouldn't be an internal util if the intent is to load it on the consumer side.

cc @jerrymarino I see you added it originally, would you be able to add a test case that exercises this code path specifically?

Copy link
Contributor

Choose a reason for hiding this comment

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

Overall this is "internal" but this overall utility module clearly has many useful functions none the less - we should clarify API contracts with this code.

Copy link
Collaborator

@jszumski jszumski left a comment

Choose a reason for hiding this comment

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

This worked for Cash 👍

@mattrobmattrob
Copy link
Collaborator

We can merge this and revert if Block folks have any issues. Thanks for fixing the previous problem, @qyang-nj!

@mattrobmattrob mattrobmattrob merged commit 30422ce into bazel-ios:master May 11, 2023
@thiagohmcruz
Copy link
Contributor

We can merge this and revert if Block folks have any issues. Thanks for fixing the previous problem, @qyang-nj!

+1 thx for the PR @qyang-nj, sorry about the delay I'm intermittently available this week, will try to run some tests on this sometime this week

Copy link
Contributor

@jerrymarino jerrymarino left a comment

Choose a reason for hiding this comment

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

Thanks for the PR - left a comment inline and will be able to followup on this at a later day if necessary!

cc_info = objc_provider_utils.merge_cc_info_providers(
cc_info_providers = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep],
)
additional_providers.append(cc_info)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll be able to look at this change more in depth a bit later in the week or early next; a lot of times we can't rely on "green" CI status for most of this logic. There was some reasons to do this on Bazel 4; which I'm not sure exist still..

Is there a way that you'd add an example of how you're using a transitive import that wasn't working incase we need to fix that in a different way?

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.

5 participants