From facfb550e423d2a8b8c7835bd31e9d1d6af51f14 Mon Sep 17 00:00:00 2001 From: Aaron Sky Date: Mon, 10 Jun 2024 12:19:12 -0400 Subject: [PATCH] Remove `apply_implied_frameworks` feature from `implies` action configs (#335) Fixes #334 --- crosstool/cc_toolchain_config.bzl | 9 ++-- test/linking_tests.bzl | 74 ++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 7 deletions(-) diff --git a/crosstool/cc_toolchain_config.bzl b/crosstool/cc_toolchain_config.bzl index e274cf6..c6f6708 100644 --- a/crosstool/cc_toolchain_config.bzl +++ b/crosstool/cc_toolchain_config.bzl @@ -313,7 +313,6 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new "framework_paths", "strip_debug_symbols", "apple_env", - "apply_implicit_frameworks", ], tools = [ tool( @@ -336,7 +335,6 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new "linker_param_file", "apple_env", "sysroot", - "apply_implicit_frameworks", ], tools = [ tool( @@ -571,7 +569,6 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new "framework_paths", "strip_debug_symbols", "apple_env", - "apply_implicit_frameworks", ], tools = [ tool( @@ -593,7 +590,6 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new "linker_param_file", "apple_env", "sysroot", - "apply_implicit_frameworks", ], tools = [ tool( @@ -661,7 +657,6 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new "linker_param_file", "apple_env", "sysroot", - "apply_implicit_frameworks", ], tools = [ tool( @@ -1533,6 +1528,7 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new ctx.attr.cpu == "watchos_arm64"): apply_implicit_frameworks_feature = feature( name = "apply_implicit_frameworks", + enabled = True, flag_sets = [ flag_set( actions = _DYNAMIC_LINK_ACTIONS, @@ -1549,6 +1545,7 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new ctx.attr.cpu == "darwin_arm64e"): apply_implicit_frameworks_feature = feature( name = "apply_implicit_frameworks", + enabled = True, flag_sets = [ flag_set( actions = _DYNAMIC_LINK_ACTIONS, @@ -1558,7 +1555,7 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new ], ) else: - apply_implicit_frameworks_feature = None + apply_implicit_frameworks_feature = feature(name = "apply_implicit_frameworks") random_seed_feature = feature( name = "random_seed", diff --git a/test/linking_tests.bzl b/test/linking_tests.bzl index 504a08f..9fd5dc0 100644 --- a/test/linking_tests.bzl +++ b/test/linking_tests.bzl @@ -30,6 +30,14 @@ disable_objc_test = make_action_command_line_test_rule( }, ) +disable_implicit_frameworks_test = make_action_command_line_test_rule( + config_settings = { + "//command_line_option:features": [ + "-apply_implicit_frameworks", + ], + }, +) + dsym_test = make_action_command_line_test_rule( config_settings = { "//command_line_option:apple_generate_dsym": True, @@ -43,7 +51,7 @@ def linking_test_suite(name): name: The name to be included in test names and tags. """ default_test( - name = "{}_default_apple_link_test".format(name), + name = "{}_default_apple_macos_link_test".format(name), tags = [name], expected_argv = [ "-Xlinker", @@ -51,6 +59,8 @@ def linking_test_suite(name): "-Xlinker", "2", "-ObjC", + "-framework", + "Foundation", ], not_expected_argv = [ "-g", @@ -60,6 +70,28 @@ def linking_test_suite(name): mnemonic = "ObjcLink", target_under_test = "//test/test_data:macos_binary", ) + default_test( + name = "{}_default_apple_ios_link_test".format(name), + tags = [name], + expected_argv = [ + "-Xlinker", + "-objc_abi_version", + "-Xlinker", + "2", + "-ObjC", + "-framework", + "Foundation", + "-framework", + "UIKit", + ], + not_expected_argv = [ + "-g", + "DSYM_HINT_LINKED_BINARY", + "-dead_strip", + ], + mnemonic = "ObjcLink", + target_under_test = "//test/test_data:ios_binary", + ) opt_test( name = "{}_opt_link_test".format(name), @@ -99,12 +131,52 @@ def linking_test_suite(name): "-objc_abi_version", "-Xlinker", "2", + "-framework", + "Foundation", ], not_expected_argv = ["-ObjC"], mnemonic = "ObjcLink", target_under_test = "//test/test_data:macos_binary", ) + disable_implicit_frameworks_test( + name = "{}_disable_implicit_frameworks_apple_macos_link_test".format(name), + tags = [name], + expected_argv = [ + "-Xlinker", + "-objc_abi_version", + "-Xlinker", + "2", + "-ObjC", + ], + not_expected_argv = [ + "-framework", + "Foundation", + ], + mnemonic = "ObjcLink", + target_under_test = "//test/test_data:macos_binary", + ) + + disable_implicit_frameworks_test( + name = "{}_disable_implicit_frameworks_apple_ios_link_test".format(name), + tags = [name], + expected_argv = [ + "-Xlinker", + "-objc_abi_version", + "-Xlinker", + "2", + "-ObjC", + ], + not_expected_argv = [ + "-framework", + "Foundation", + "-framework", + "UIKit", + ], + mnemonic = "ObjcLink", + target_under_test = "//test/test_data:ios_binary", + ) + dsym_test( name = "{}_generate_dsym_test".format(name), tags = [name],