Skip to content

Commit

Permalink
Fix merge conflicts and remove const values gating
Browse files Browse the repository at this point in the history
  • Loading branch information
luispadron committed Sep 18, 2024
1 parent fe26e20 commit 3704684
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 73 deletions.
9 changes: 1 addition & 8 deletions swift/internal/compiling.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ load(
"SWIFT_FEATURE_USE_EXPLICIT_SWIFT_MODULE_MAP",
"SWIFT_FEATURE_VFSOVERLAY",
"SWIFT_FEATURE__NUM_THREADS_0_IN_SWIFTCOPTS",
"SWIFT_FEATURE__SUPPORTS_CONST_VALUE_EXTRACTION",
"SWIFT_FEATURE__WMO_IN_SWIFTCOPTS",
)
load(
Expand Down Expand Up @@ -492,13 +491,7 @@ def compile(
feature_name = SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO,
)

if is_feature_enabled(
feature_configuration = feature_configuration,
feature_name = SWIFT_FEATURE__SUPPORTS_CONST_VALUE_EXTRACTION,
):
const_protocols_to_gather_file = swift_toolchain.const_protocols_to_gather
else:
const_protocols_to_gather_file = []
const_protocols_to_gather_file = swift_toolchain.const_protocols_to_gather

compile_outputs, other_outputs = _declare_compile_outputs(
srcs = srcs,
Expand Down
5 changes: 0 additions & 5 deletions swift/internal/feature_names.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,6 @@ SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO = "swift.emit_swiftsourceinfo"
# multiple frameworks with different target name, but same module name.
SWIFT_FEATURE_ADD_TARGET_NAME_TO_OUTPUT = "swift.add_target_name_to_output"

# A private feature that is set by the toolchain if it supports constant values
# extraction (Swift 5.8 and above). Users should never manually enable, disable, or query this
# feature.
SWIFT_FEATURE__SUPPORTS_CONST_VALUE_EXTRACTION = "swift._supports_const_value_extraction"

# Enable thin LTO and update output-file-map correctly
SWIFT_FEATURE_THIN_LTO = "swift.thin_lto"

Expand Down
29 changes: 0 additions & 29 deletions swift/internal/swift_autoconfiguration.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ load(
"SWIFT_FEATURE_USE_AUTOLINK_EXTRACT",
"SWIFT_FEATURE_USE_MODULE_WRAP",
"SWIFT_FEATURE_USE_OLD_DRIVER",
"SWIFT_FEATURE__SUPPORTS_MACROS",
)

def _scratch_file(repository_ctx, temp_dir, name, content = ""):
Expand Down Expand Up @@ -154,30 +153,6 @@ def _write_swift_version(repository_ctx, swiftc_path):
repository_ctx.file(filename, contents, executable = False)
return filename

def _fetch_supported_features(repository_ctx, swiftc_path):
"""Fetch the json config of supported features from Swift
This can be used to flip rules specific features
Args:
repository_ctx: The repository context.
swiftc_path: The `path` to the `swiftc` executable.
Returns:
The list of supported features, or an empty array if it fails
"""
repository_ctx.file("empty.swift")
result = repository_ctx.execute([
swiftc_path,
"-frontend",
"-emit-supported-features",
"empty.swift",
])
if result.return_code == 0:
return json.decode(result.stdout.strip()).get("SupportedArguments", [])

return []

def _compute_feature_values(repository_ctx, swiftc_path):
"""Computes a list of supported/unsupported features by running checks.
Expand Down Expand Up @@ -259,10 +234,6 @@ def _create_linux_toolchain(repository_ctx):
feature_values.append(SWIFT_FEATURE_USE_AUTOLINK_EXTRACT)
feature_values.append(SWIFT_FEATURE_USE_MODULE_WRAP)

swift_features_config = _fetch_supported_features(repository_ctx, path_to_swiftc)
if "load-plugin-executable" in swift_features_config:
feature_values.append(SWIFT_FEATURE__SUPPORTS_MACROS)

repository_ctx.file(
"BUILD",
"""
Expand Down
7 changes: 0 additions & 7 deletions swift/swift_compiler_plugin.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ load(
load(
"@build_bazel_rules_swift//swift/internal:feature_names.bzl",
"SWIFT_FEATURE_ADD_TARGET_NAME_TO_OUTPUT",
"SWIFT_FEATURE__SUPPORTS_MACROS",
)
load("//swift/internal:features.bzl", "is_feature_enabled")
load(
Expand Down Expand Up @@ -59,12 +58,6 @@ def _swift_compiler_plugin_impl(ctx):
unsupported_features = ctx.disabled_features,
)

if not is_feature_enabled(
feature_configuration = feature_configuration,
feature_name = SWIFT_FEATURE__SUPPORTS_MACROS,
):
fail("Swift compiler plugins require Swift 5.9+")

deps = ctx.attr.deps
srcs = ctx.files.srcs
module_contexts = []
Expand Down
2 changes: 0 additions & 2 deletions swift/toolchains/config/compile_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ load(
"SWIFT_FEATURE_USE_PCH_OUTPUT_DIR",
"SWIFT_FEATURE_VFSOVERLAY",
"SWIFT_FEATURE__NUM_THREADS_0_IN_SWIFTCOPTS",
"SWIFT_FEATURE__SUPPORTS_CONST_VALUE_EXTRACTION",
"SWIFT_FEATURE__WMO_IN_SWIFTCOPTS",
)
load(":action_config.bzl", "ActionConfigInfo", "ConfigResultInfo", "add_arg")
Expand Down Expand Up @@ -253,7 +252,6 @@ def compile_action_configs(
ActionConfigInfo(
actions = [SWIFT_ACTION_COMPILE],
configurators = [_constant_value_extraction_configurator],
features = [SWIFT_FEATURE__SUPPORTS_CONST_VALUE_EXTRACTION],
),

# Link Time Optimization (LTO).
Expand Down
5 changes: 4 additions & 1 deletion swift/toolchains/xcode_swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ load(
"SWIFT_FEATURE_OBJC_LINK_FLAGS",
"SWIFT_FEATURE_OPT_USES_WMO",
"SWIFT_FEATURE_REMAP_XCODE_PATH",
"SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX",
"SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE",
"SWIFT_FEATURE__FORCE_ALWAYSLINK_TRUE",
)
Expand Down Expand Up @@ -695,14 +696,16 @@ def _xcode_swift_toolchain_impl(ctx):
SWIFT_FEATURE_CACHEABLE_SWIFTMODULES,
SWIFT_FEATURE_COVERAGE_PREFIX_MAP,
SWIFT_FEATURE_DEBUG_PREFIX_MAP,
SWIFT_FEATURE_DISABLE_SYSTEM_INDEX,
SWIFT_FEATURE_EMIT_SWIFTDOC,
SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO,
SWIFT_FEATURE_ENABLE_BATCH_MODE,
SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES,
SWIFT_FEATURE_DISABLE_SYSTEM_INDEX,
SWIFT_FEATURE_FILE_PREFIX_MAP,
SWIFT_FEATURE_OBJC_LINK_FLAGS,
SWIFT_FEATURE_OPT_USES_WMO,
SWIFT_FEATURE_REMAP_XCODE_PATH,
SWIFT_FEATURE_SUPPORTS_BARE_SLASH_REGEX,
SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE,
])

Expand Down
21 changes: 0 additions & 21 deletions test/const_values_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ load(

const_values_test = make_action_command_line_test_rule()

no_const_values_test = make_action_command_line_test_rule(
config_settings = {
"//command_line_option:features": [
"-swift._supports_const_value_extraction",
],
},
)

const_values_wmo_test = make_provider_test_rule(
config_settings = {
str(Label("@build_bazel_rules_swift//swift:copt")): [
Expand Down Expand Up @@ -98,19 +90,6 @@ def const_values_test_suite(name, tags = []):
target_under_test = "@build_bazel_rules_swift//test/fixtures/basic:first",
)

no_const_values_test(
name = "{}_not_expected_argv".format(name),
not_expected_argv = [
"-Xfrontend -const-gather-protocols-file",
"-Xfrontend swift/toolchains/config/const_protocols_to_gather.json",
"-emit-const-values-path",
"first.swift.swiftconstvalues",
],
mnemonic = "SwiftCompile",
tags = all_tags,
target_under_test = "@build_bazel_rules_swift//test/fixtures/basic:first",
)

native.test_suite(
name = name,
tags = all_tags,
Expand Down

0 comments on commit 3704684

Please sign in to comment.