Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit 639ecfa

Browse files
allevatoswiple-rules-gardener
authored andcommitted
Don't propagate an empty module map for {cc,objc}_library targets that don't have any headers (and that don't specify an explicit module map using the module_map attribute).
This is typically the case for libraries that group other libraries via their `deps`. Users mistakenly import these thinking they're required to use the underlying declarations, but they do nothing (except make more work for the compiler). PiperOrigin-RevId: 332246632
1 parent 74f3f87 commit 639ecfa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

swift/internal/swift_clang_module_aspect.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ def _module_info_for_target(
179179
if not aspect_ctx.rule.kind == "objc_library":
180180
return None, module_maps[0]
181181

182+
# If an `objc_library` doesn't have any headers (and doesn't specify an
183+
# explicit module map), then don't generate or propagate a module map
184+
# for it. Such modules define nothing and only waste space on the
185+
# compilation command line and add more work for the compiler.
186+
if not getattr(attr, "module_map", None) and not (
187+
compilation_context.direct_headers or
188+
compilation_context.direct_textual_headers
189+
):
190+
return None, None
191+
182192
module_name = getattr(attr, "module_name", None)
183193
if not module_name:
184194
module_name = derive_module_name(target.label)

0 commit comments

Comments
 (0)