-
Notifications
You must be signed in to change notification settings - Fork 159
[repro] module maps created for or on objc_library do not propagate to transitive objc_library #1532
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
base: main
Are you sure you want to change the base?
[repro] module maps created for or on objc_library do not propagate to transitive objc_library #1532
Conversation
|
i think this is related to #1174 |
|
My understanding is that this is "working as intended" from the point of view of Bazel core -- module maps are only used for importing clang modules into Swift. Even if you had I'm trying to use this intermediate rule (which pulls out the aspect-generated module map and kind of misuses
I would support fixing this in |
|
So, within Google we've "fixed" this by having a tool that runs post-compile and rewrites the Unfortunately since this tool depends on LLVM/Clang's source tree to load the modules and collect the headers within them, and because it uses some internal libraries on top of that, we can't easily open-source it. There's also a semi-recent Swift compiler flag, |
…o transitive objc_library this is a repro of an issue i've identified while trying to move to `mixed_language_library` from our custom macro. Regardless of how `module_map` is hinted in `swift_interop_info`, generated, or otherwise attached to an `objc_library`, out-of-the-box these module maps are not propagated to downstream `objc_library` in a `objc -> swift -> objc` arrangement. this is especially problematic in scenarios where PrintAsClang, going by its own uncontrollable heuristics, inserts an `@import` line for the upstream objc library in a generated header. this is something that needs to change in either `swift_clang_module_aspect` or `objc_library` to discover or otherwise propagate the upstream module maps, as this simple example does not work without customization of the rules or introducing manual dependencies on modulemaps (which isn't possible if relying on the generated modulemaps from the aspect).
50e44f2 to
1b92609
Compare
…ap or creates one if absent
|
@jschear curious what you think of the (note: doesn't support Bazel 7, and it appears to have some issues under Bazel 9 😭) |
|
Amazing! I saw Keith's post on rule extensions and was thinking that might be applicable here, neat. Definitely nice to not pollute the build graph with unnecessary targets. I was hoping it would be possible to re-use the action generated by the |
|
I can definitely play around with that to see if I can get the solution slightly cleaner. The implementation of the action in the aspect very clearly covers more edge cases that make it more robust than what I've copied here. That said, for as common of a paper cut as this is, I have no idea where I'd actually want to land this code if we were ready to commit to it. 😂 Probably worth a discussion with the other maintainers once I get to that point. |
|
Okay I've fixed for last_green, and for 7.x you need to set |
Maybe easier to land after we drop Bazel 7 support? |
|
I guess rules_swift_package_manager also reimplements module map generation, it isn't the end of the world to duplicate it again 😄 |
|
|
||
| for provider in providers: | ||
| if type(provider) == "CcInfo" or \ | ||
| (type(provider) == "struct" and hasattr(provider, "compilation_context")): # NOTE: Will require an update when this provider moves to starlark |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was printing out the list of providers and noticed this too... subtle!
And we did internally as well. We should make it public API by now... |
this is a repro of an issue i've identified while trying to move to
mixed_language_libraryfrom our custom macro. Regardless of howmodule_mapis hinted inswift_interop_info, generated, or otherwise attached to anobjc_library, out-of-the-box these module maps are not propagated to downstreamobjc_libraryin aobjc -> swift -> objcarrangement. this is especially problematic in scenarios where PrintAsClang, going by its own uncontrollable heuristics (in this case, the addition of a lightweight generic in a public-facing objc type), inserts an@importline for the upstream objc library in a generated header.this is something that needs to change in either
swift_clang_module_aspectorobjc_libraryto discover or otherwise propagate the upstream module maps, as this simple example does not work without customization of the rules or introducing manual dependencies on modulemaps (which isn't possible if relying on the generated modulemaps from the aspect).