mirror of https://github.com/bazelbuild/rules_cc
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
This commit is contained in:
parent
dfb180b486
commit
49a6c21b32
|
@ -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, []])
|
||||
|
||||
|
|
|
@ -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[:],
|
||||
|
|
Loading…
Reference in New Issue