Skip to content

Commit aaec040

Browse files
committed
Allow disabling -dead_strip in opt builds
Fixes #308
1 parent e490d95 commit aaec040

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

crosstool/cc_toolchain_config.bzl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,11 +1059,6 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new
10591059
),
10601060
],
10611061
),
1062-
flag_set(
1063-
actions = _DYNAMIC_LINK_ACTIONS,
1064-
flag_groups = [flag_group(flags = ["-dead_strip"])],
1065-
with_features = [with_feature_set(features = ["opt"])],
1066-
),
10671062
],
10681063
)
10691064

@@ -2077,6 +2072,18 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new
20772072
],
20782073
)
20792074

2075+
dead_strip_opt_feature = feature(
2076+
name = "dead_strip_opt",
2077+
enabled = True,
2078+
flag_sets = [
2079+
flag_set(
2080+
actions = _DYNAMIC_LINK_ACTIONS,
2081+
flag_groups = [flag_group(flags = ["-dead_strip"])],
2082+
with_features = [with_feature_set(features = ["opt"])],
2083+
),
2084+
],
2085+
)
2086+
20802087
oso_prefix_feature = feature(
20812088
name = "oso_prefix_is_pwd",
20822089
enabled = True,
@@ -2582,6 +2589,7 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new
25822589
default_link_flags_feature,
25832590
no_deduplicate_feature,
25842591
dead_strip_feature,
2592+
dead_strip_opt_feature,
25852593
apply_implicit_frameworks_feature,
25862594
link_cocoa_feature,
25872595
apply_simulator_compiler_flags_feature,

test/linking_tests.bzl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ opt_test = make_action_command_line_test_rule(
1313
},
1414
)
1515

16+
opt_dead_strip_disabled_test = make_action_command_line_test_rule(
17+
config_settings = {
18+
"//command_line_option:compilation_mode": "opt",
19+
"//command_line_option:features": [
20+
"-dead_strip_opt",
21+
],
22+
},
23+
)
24+
1625
dead_strip_requested_test = make_action_command_line_test_rule(
1726
config_settings = {
1827
"//command_line_option:compilation_mode": "fastbuild",
@@ -76,6 +85,23 @@ def linking_test_suite(name):
7685
target_under_test = "//test/test_data:macos_binary",
7786
)
7887

88+
opt_dead_strip_disabled_test(
89+
name = "{}_opt_dead_strip_disabled_test".format(name),
90+
tags = [name],
91+
expected_argv = [
92+
"-Xlinker",
93+
"-objc_abi_version",
94+
"-Xlinker",
95+
"2",
96+
"-ObjC",
97+
],
98+
not_expected_argv = [
99+
"-dead_strip",
100+
],
101+
mnemonic = "ObjcLink",
102+
target_under_test = "//test/test_data:macos_binary",
103+
)
104+
79105
dead_strip_requested_test(
80106
name = "{}_dead_strip_requested_test".format(name),
81107
tags = [name],

0 commit comments

Comments
 (0)