Skip to content

Commit ed87447

Browse files
authored
Revert "Remove the swift.no_generated_module_map feature" (#1530)
This reverts commit 68b58f7. While we have a custom `mixed_language_library` rule that doesnt match `upstream` we must maintain this feature or we get duplicate module declaration errors as the mixed language rules depend on this feature when they create their own modulemap Without this commit reverted we get: ```sh bazel-out/ios_sim_arm64-dbg-ios-sim_arm64-min16.0-applebin_ios-ST-2491983d010b/bin/Code/CoreLibraries/Contacts/Aliases/AliasesLegacy/AliasesLegacy.lib_swift_modulemap/_/module.modulemap:1:8: error: redefinition of module 'AliasesLegacy' 1 | module "AliasesLegacy" { | ^ bazel-out/ios_sim_arm64-dbg-ios-sim_arm64-min16.0-applebin_ios-ST-2491983d010b/bin/Code/CoreLibraries/Contacts/Aliases/AliasesLegacy/AliasesLegacy.lib/AliasesLegacy/module.modulemap:1:8: note: previously defined here 1 | module "AliasesLegacy" { | ^ 1 error generated. ``` Part of: bazelbuild/rules_apple#2729, we can remove this feature when we upstream the mixed language support in upstream.
1 parent 81c1342 commit ed87447

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

swift/internal/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ bzl_library(
156156
deps = [
157157
":feature_names",
158158
":package_specs",
159+
":target_triples",
159160
"@bazel_skylib//lib:collections",
160161
"@bazel_skylib//lib:new_sets",
161162
"@bazel_skylib//rules:common_settings",

swift/internal/compiling.bzl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ load(
4848
"SWIFT_FEATURE_INDEX_WHILE_BUILDING",
4949
"SWIFT_FEATURE_MODULAR_INDEXING",
5050
"SWIFT_FEATURE_MODULE_MAP_HOME_IS_CWD",
51+
"SWIFT_FEATURE_NO_GENERATED_MODULE_MAP",
5152
"SWIFT_FEATURE_OPT",
5253
"SWIFT_FEATURE_OPT_USES_WMO",
5354
"SWIFT_FEATURE_PROPAGATE_GENERATED_MODULE_MAP",
@@ -724,7 +725,10 @@ to use swift_common.compile(include_dev_srch_paths = ...) instead.\
724725

725726
# If a header and module map were generated for this Swift module, attempt
726727
# to precompile the explicit module for that header as well.
727-
if generated_header_name:
728+
if generated_header_name and not is_feature_enabled(
729+
feature_configuration = feature_configuration,
730+
feature_name = SWIFT_FEATURE_NO_GENERATED_MODULE_MAP,
731+
):
728732
compilation_context_to_compile = (
729733
compilation_context_for_explicit_module_compilation(
730734
compilation_contexts = [
@@ -1274,7 +1278,10 @@ def _declare_compile_outputs(
12741278
# trap door lets them escape the module redefinition error, with the
12751279
# caveat that certain import scenarios could lead to incorrect behavior
12761280
# because a header can be imported textually instead of modularly.
1277-
if generated_header:
1281+
if generated_header and not is_feature_enabled(
1282+
feature_configuration = feature_configuration,
1283+
feature_name = SWIFT_FEATURE_NO_GENERATED_MODULE_MAP,
1284+
):
12781285
# Collect the names of Clang modules that the module being built
12791286
# directly depends on.
12801287
dependent_module_names = sets.make()

swift/internal/feature_names.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ SWIFT_FEATURE_MODULE_MAP_NO_PRIVATE_HEADERS = (
153153
# link to any version of the ASAN runtime library.
154154
SWIFT_FEATURE_NO_ASAN_VERSION_CHECK = "swift.no_asan_version_check"
155155

156+
# If enabled, the compilation action for a library target will not generate a
157+
# module map for the Objective-C generated header. This feature is ignored if
158+
# the target is not generating a header.
159+
SWIFT_FEATURE_NO_GENERATED_MODULE_MAP = "swift.no_generated_module_map"
160+
156161
# If enabled, the parent directory of the generated module map is added to
157162
# `CcInfo.compilation_context.includes`. This allows `objc_library` to import
158163
# the Swift module. If you swap this feature between enabled and disabled, and

swift/internal/features.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ load(
3333
"SWIFT_FEATURE_FILE_PREFIX_MAP",
3434
"SWIFT_FEATURE_FULL_DEBUG_INFO",
3535
"SWIFT_FEATURE_INTERNALIZE_AT_LINK",
36+
"SWIFT_FEATURE_NO_GENERATED_MODULE_MAP",
3637
"SWIFT_FEATURE_OBJC_LINK_FLAGS",
3738
"SWIFT_FEATURE_OPT_USES_WMO",
3839
"SWIFT_FEATURE_REMAP_XCODE_PATH",
3940
"SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE",
4041
"SWIFT_FEATURE__SUPPORTS_V6",
4142
)
4243
load(":package_specs.bzl", "label_matches_package_specs")
44+
load(":target_triples.bzl", "target_triples")
4345

4446
def are_all_features_enabled(feature_configuration, feature_names):
4547
"""Returns `True` if all features are enabled in the feature configuration.
@@ -265,6 +267,12 @@ def default_features_for_toolchain(target_triple):
265267
SWIFT_FEATURE_REMAP_XCODE_PATH,
266268
])
267269

270+
# Linux specific features
271+
if target_triples.unversioned_os(target_triple) == "linux":
272+
features.extend([
273+
SWIFT_FEATURE_NO_GENERATED_MODULE_MAP,
274+
])
275+
268276
return features
269277

270278
def upcoming_and_experimental_features(feature_configuration):

0 commit comments

Comments
 (0)