mirror of https://github.com/bazelbuild/rules_cc
Fix migrator to correctly migrate dynamic linking mode linker_flags
This would have not introduced the osx crosstool bug in 2d0e27e8bc
which was then fixed in unknown commit.
RELNOTES: None.
PiperOrigin-RevId: 238699176
This commit is contained in:
parent
b844e0c4b8
commit
10f38e16da
|
@ -44,6 +44,8 @@ DYNAMIC_LIBRARY_LINK_ACTIONS = [
|
||||||
|
|
||||||
NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS = ["c++-link-nodeps-dynamic-library"]
|
NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS = ["c++-link-nodeps-dynamic-library"]
|
||||||
|
|
||||||
|
TRANSITIVE_DYNAMIC_LIBRARY_LINK_ACTIONS = ["c++-link-dynamic-library"]
|
||||||
|
|
||||||
TRANSITIVE_LINK_ACTIONS = ["c++-link-executable", "c++-link-dynamic-library"]
|
TRANSITIVE_LINK_ACTIONS = ["c++-link-executable", "c++-link-dynamic-library"]
|
||||||
|
|
||||||
CC_LINK_EXECUTABLE = ["c++-link-executable"]
|
CC_LINK_EXECUTABLE = ["c++-link-executable"]
|
||||||
|
@ -329,9 +331,14 @@ def _add_flag_sets(feature, flag_sets):
|
||||||
actions = flag_set[1]
|
actions = flag_set[1]
|
||||||
flags = flag_set[2]
|
flags = flag_set[2]
|
||||||
expand_if_all_available = flag_set[3]
|
expand_if_all_available = flag_set[3]
|
||||||
|
not_feature = None
|
||||||
|
if len(flag_set) >= 5:
|
||||||
|
not_feature = flag_set[4]
|
||||||
flag_set = feature.flag_set.add()
|
flag_set = feature.flag_set.add()
|
||||||
if with_feature is not None:
|
if with_feature is not None:
|
||||||
flag_set.with_feature.add().feature[:] = [with_feature]
|
flag_set.with_feature.add().feature[:] = [with_feature]
|
||||||
|
if not_feature is not None:
|
||||||
|
flag_set.with_feature.add().not_feature[:] = [not_feature]
|
||||||
flag_set.action[:] = actions
|
flag_set.action[:] = actions
|
||||||
flag_group = flag_set.flag_group.add()
|
flag_group = flag_set.flag_group.add()
|
||||||
flag_group.expand_if_all_available[:] = expand_if_all_available
|
flag_group.expand_if_all_available[:] = expand_if_all_available
|
||||||
|
@ -413,6 +420,13 @@ def _extract_legacy_link_flag_sets_for(toolchain):
|
||||||
if mode == "DYNAMIC":
|
if mode == "DYNAMIC":
|
||||||
result.append(
|
result.append(
|
||||||
[None, NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS, lmf.linker_flag, []])
|
[None, NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS, lmf.linker_flag, []])
|
||||||
|
result.append([
|
||||||
|
None,
|
||||||
|
TRANSITIVE_DYNAMIC_LIBRARY_LINK_ACTIONS,
|
||||||
|
lmf.linker_flag,
|
||||||
|
[],
|
||||||
|
"static_link_cpp_runtimes",
|
||||||
|
])
|
||||||
result.append([
|
result.append([
|
||||||
feature_name,
|
feature_name,
|
||||||
transitive_link_actions(toolchain), lmf.linker_flag, []
|
transitive_link_actions(toolchain), lmf.linker_flag, []
|
||||||
|
|
|
@ -9,6 +9,7 @@ from tools.migration.legacy_fields_migration_lib import ALL_OBJC_LINK_ACTIONS
|
||||||
from tools.migration.legacy_fields_migration_lib import DYNAMIC_LIBRARY_LINK_ACTIONS
|
from tools.migration.legacy_fields_migration_lib import DYNAMIC_LIBRARY_LINK_ACTIONS
|
||||||
from tools.migration.legacy_fields_migration_lib import NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS
|
from tools.migration.legacy_fields_migration_lib import NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS
|
||||||
from tools.migration.legacy_fields_migration_lib import TRANSITIVE_LINK_ACTIONS
|
from tools.migration.legacy_fields_migration_lib import TRANSITIVE_LINK_ACTIONS
|
||||||
|
from tools.migration.legacy_fields_migration_lib import TRANSITIVE_DYNAMIC_LIBRARY_LINK_ACTIONS
|
||||||
from tools.migration.legacy_fields_migration_lib import CC_LINK_EXECUTABLE
|
from tools.migration.legacy_fields_migration_lib import CC_LINK_EXECUTABLE
|
||||||
from tools.migration.legacy_fields_migration_lib import migrate_legacy_fields
|
from tools.migration.legacy_fields_migration_lib import migrate_legacy_fields
|
||||||
|
|
||||||
|
@ -510,23 +511,31 @@ class LegacyFieldsMigrationLibTest(unittest.TestCase):
|
||||||
self.assertEqual(output.feature[0].flag_set[3].action,
|
self.assertEqual(output.feature[0].flag_set[3].action,
|
||||||
NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS)
|
NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS)
|
||||||
|
|
||||||
self.assertEqual(output.feature[0].flag_set[4].with_feature[0].feature[0],
|
self.assertEqual(
|
||||||
"dynamic_linking_mode")
|
output.feature[0].flag_set[4].with_feature[0].not_feature[0],
|
||||||
|
"static_link_cpp_runtimes")
|
||||||
self.assertEqual(output.feature[0].flag_set[4].flag_group[0].flag,
|
self.assertEqual(output.feature[0].flag_set[4].flag_group[0].flag,
|
||||||
["lmf-dynamic-flag-4"])
|
["lmf-dynamic-flag-4"])
|
||||||
self.assertEqual(output.feature[0].flag_set[4].action,
|
self.assertEqual(output.feature[0].flag_set[4].action,
|
||||||
|
TRANSITIVE_DYNAMIC_LIBRARY_LINK_ACTIONS)
|
||||||
|
|
||||||
|
self.assertEqual(output.feature[0].flag_set[5].with_feature[0].feature[0],
|
||||||
|
"dynamic_linking_mode")
|
||||||
|
self.assertEqual(output.feature[0].flag_set[5].flag_group[0].flag,
|
||||||
|
["lmf-dynamic-flag-4"])
|
||||||
|
self.assertEqual(output.feature[0].flag_set[5].action,
|
||||||
TRANSITIVE_LINK_ACTIONS)
|
TRANSITIVE_LINK_ACTIONS)
|
||||||
|
|
||||||
self.assertEqual(output.feature[0].flag_set[5].flag_group[0].flag,
|
self.assertEqual(output.feature[0].flag_set[6].flag_group[0].flag,
|
||||||
["dl-flag-5"])
|
["dl-flag-5"])
|
||||||
self.assertEqual(output.feature[0].flag_set[5].action,
|
self.assertEqual(output.feature[0].flag_set[6].action,
|
||||||
DYNAMIC_LIBRARY_LINK_ACTIONS)
|
DYNAMIC_LIBRARY_LINK_ACTIONS)
|
||||||
|
|
||||||
self.assertEqual(output.feature[0].flag_set[6].flag_group[0].flag,
|
self.assertEqual(output.feature[0].flag_set[7].flag_group[0].flag,
|
||||||
["to-flag-6"])
|
["to-flag-6"])
|
||||||
self.assertEqual(output.feature[0].flag_set[6].action, ALL_CC_LINK_ACTIONS)
|
self.assertEqual(output.feature[0].flag_set[7].action, ALL_CC_LINK_ACTIONS)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
output.feature[0].flag_set[6].flag_group[0].expand_if_all_available,
|
output.feature[0].flag_set[7].flag_group[0].expand_if_all_available,
|
||||||
["is_cc_test"])
|
["is_cc_test"])
|
||||||
|
|
||||||
def test_all_linker_flag_objc_actions(self):
|
def test_all_linker_flag_objc_actions(self):
|
||||||
|
|
Loading…
Reference in New Issue