From 49a6c21b32f53d7439a3c3dfb9669873f5ebcb96 Mon Sep 17 00:00:00 2001 From: hlopko Date: Mon, 11 Feb 2019 06:47:11 -0800 Subject: [PATCH] Do not use static_linking_mode for dynamic libraries and objc rules Another dark corner corner of crosstools appeared, and apparently we didn't enable MOSTLY STATIC linking mode flags for dynamic libraries or objc. This cl addresses that in the legacy fields migrator. RELNOTES: None. PiperOrigin-RevId: 233397974 --- tools/migration/legacy_fields_migration_lib.py | 8 +++++++- tools/migration/legacy_fields_migration_lib_test.py | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/migration/legacy_fields_migration_lib.py b/tools/migration/legacy_fields_migration_lib.py index a1da3cf..2b82109 100644 --- a/tools/migration/legacy_fields_migration_lib.py +++ b/tools/migration/legacy_fields_migration_lib.py @@ -46,6 +46,8 @@ NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS = ["c++-link-nodeps-dynamic-library"] TRANSITIVE_LINK_ACTIONS = ["c++-link-executable", "c++-link-dynamic-library"] +CC_LINK_EXECUTABLE = ["c++-link-executable"] + def compile_actions(toolchain): """Returns compile actions for cc or objc rules.""" @@ -403,8 +405,12 @@ def _extract_legacy_link_flag_sets_for(toolchain): feature_name, transitive_link_actions(toolchain), lmf.linker_flag, [] ]) - else: + elif mode == "MOSTLY_STATIC": result.append( + [feature_name, + CC_LINK_EXECUTABLE, lmf.linker_flag, []]) + else: + result.append( [feature_name, link_actions(toolchain), lmf.linker_flag, []]) diff --git a/tools/migration/legacy_fields_migration_lib_test.py b/tools/migration/legacy_fields_migration_lib_test.py index d6603a3..9a915e1 100644 --- a/tools/migration/legacy_fields_migration_lib_test.py +++ b/tools/migration/legacy_fields_migration_lib_test.py @@ -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 NODEPS_DYNAMIC_LIBRARY_LINK_ACTIONS from tools.migration.legacy_fields_migration_lib import TRANSITIVE_LINK_ACTIONS +from tools.migration.legacy_fields_migration_lib import CC_LINK_EXECUTABLE from tools.migration.legacy_fields_migration_lib import migrate_legacy_fields @@ -412,6 +413,7 @@ class LegacyFieldsMigrationLibTest(unittest.TestCase): # flag set for linking_mode_flags self.assertEqual(len(output.feature[0].flag_set[2].with_feature), 1) + self.assertEqual(output.feature[0].flag_set[2].action, CC_LINK_EXECUTABLE) self.assertEqual(output.feature[0].flag_set[2].with_feature[0].feature[0], "static_linking_mode") self.assertEqual(output.feature[0].flag_set[2].flag_group[0].flag, @@ -496,7 +498,7 @@ class LegacyFieldsMigrationLibTest(unittest.TestCase): self.assertEqual(output.feature[0].flag_set[1].flag_group[0].flag, ["cmf-flag-2"]) - self.assertEqual(output.feature[0].flag_set[2].action, ALL_CC_LINK_ACTIONS) + self.assertEqual(output.feature[0].flag_set[2].action, CC_LINK_EXECUTABLE) self.assertEqual(output.feature[0].flag_set[2].with_feature[0].feature[0], "static_linking_mode") self.assertEqual(output.feature[0].flag_set[2].flag_group[0].flag, @@ -550,7 +552,7 @@ class LegacyFieldsMigrationLibTest(unittest.TestCase): self.assertEqual(output.feature[0].flag_set[1].action[:], ALL_CC_LINK_ACTIONS + ALL_OBJC_LINK_ACTIONS) self.assertEqual(output.feature[0].flag_set[2].action[:], - ALL_CC_LINK_ACTIONS + ALL_OBJC_LINK_ACTIONS) + CC_LINK_EXECUTABLE) self.assertEqual(output.feature[0].flag_set[3].action[:], DYNAMIC_LIBRARY_LINK_ACTIONS) self.assertEqual(output.feature[0].flag_set[4].action[:],