diff --git a/crosstool/cc_toolchain_config.bzl b/crosstool/cc_toolchain_config.bzl index d66a956..bc0fbcb 100644 --- a/crosstool/cc_toolchain_config.bzl +++ b/crosstool/cc_toolchain_config.bzl @@ -1059,11 +1059,6 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new ), ], ), - flag_set( - actions = _DYNAMIC_LINK_ACTIONS, - flag_groups = [flag_group(flags = ["-dead_strip"])], - with_features = [with_feature_set(features = ["opt"])], - ), ], ) @@ -2077,6 +2072,18 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new ], ) + dead_strip_opt_feature = feature( + name = "dead_strip_opt", + enabled = True, + flag_sets = [ + flag_set( + actions = _DYNAMIC_LINK_ACTIONS, + flag_groups = [flag_group(flags = ["-dead_strip"])], + with_features = [with_feature_set(features = ["opt"])], + ), + ], + ) + oso_prefix_feature = feature( name = "oso_prefix_is_pwd", enabled = True, @@ -2582,6 +2589,7 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new default_link_flags_feature, no_deduplicate_feature, dead_strip_feature, + dead_strip_opt_feature, apply_implicit_frameworks_feature, link_cocoa_feature, apply_simulator_compiler_flags_feature, diff --git a/test/linking_tests.bzl b/test/linking_tests.bzl index 504a08f..31144e7 100644 --- a/test/linking_tests.bzl +++ b/test/linking_tests.bzl @@ -13,6 +13,15 @@ opt_test = make_action_command_line_test_rule( }, ) +opt_dead_strip_disabled_test = make_action_command_line_test_rule( + config_settings = { + "//command_line_option:compilation_mode": "opt", + "//command_line_option:features": [ + "-dead_strip_opt", + ], + }, +) + dead_strip_requested_test = make_action_command_line_test_rule( config_settings = { "//command_line_option:compilation_mode": "fastbuild", @@ -76,6 +85,23 @@ def linking_test_suite(name): target_under_test = "//test/test_data:macos_binary", ) + opt_dead_strip_disabled_test( + name = "{}_opt_dead_strip_disabled_test".format(name), + tags = [name], + expected_argv = [ + "-Xlinker", + "-objc_abi_version", + "-Xlinker", + "2", + "-ObjC", + ], + not_expected_argv = [ + "-dead_strip", + ], + mnemonic = "ObjcLink", + target_under_test = "//test/test_data:macos_binary", + ) + dead_strip_requested_test( name = "{}_dead_strip_requested_test".format(name), tags = [name],