diff --git a/cc/private/link/finalize_link_action.bzl b/cc/private/link/finalize_link_action.bzl index eb2aef5da..943f0c1f0 100644 --- a/cc/private/link/finalize_link_action.bzl +++ b/cc/private/link/finalize_link_action.bzl @@ -98,13 +98,7 @@ def finalize_link_action( Returns: None """ - need_whole_archive = whole_archive or _need_whole_archive( - feature_configuration, - linking_mode, - link_type, - user_link_flags, - cc_toolchain._cpp_configuration, - ) + need_whole_archive = whole_archive must_keep_debug = any([lib._must_keep_debug for lib in libraries_to_link]) @@ -419,43 +413,6 @@ def _can_split_command_line( # This should be unreachable: return False -def _need_whole_archive(feature_configuration, linking_mode, link_type, linkopts, cpp_config): - """The default heuristic on whether we need to use whole-archive for the link.""" - shared_linkopts = is_dynamic_library(link_type) or "-shared" in linkopts or "-shared" in cpp_config.linkopts - - # Fasten your seat belt, the logic below doesn't make perfect sense and it's full of obviously - # missed corner cases. The world still stands and depends on this behavior, so ¯\_(ツ)_/¯. - if not shared_linkopts: - # We are not producing shared library, there is no reason to use --whole-archive with - # executable (if the executable doesn't use the symbols, nobody else will, so --whole-archive - # is not needed). - return False - - if feature_configuration.is_requested("force_no_whole_archive"): - return False - - if cpp_config.incompatible_remove_legacy_whole_archive(): - # --incompatible_remove_legacy_whole_archive has been flipped, no --whole-archive for the - # entire build. - return False - - if linking_mode != LINKING_MODE.STATIC: - # legacy whole archive only applies to static linking mode. - return False - - if feature_configuration.is_requested("legacy_whole_archive"): - # --incompatible_remove_legacy_whole_archive has not been flipped, and this target requested - # --whole-archive using features. - return True - - if cpp_config.legacy_whole_archive(): - # --incompatible_remove_legacy_whole_archive has not been flipped, so whether to - # use --whole-archive depends on --legacy_whole_archive. - return True - - # Hopefully future default. - return False - def _quote_replacement(s): if "\\" not in s and "$" not in s: return s diff --git a/tests/integration/cc_shared_library_tests.sh b/tests/integration/cc_shared_library_tests.sh index 437fce83e..420b9a41e 100755 --- a/tests/integration/cc_shared_library_tests.sh +++ b/tests/integration/cc_shared_library_tests.sh @@ -100,7 +100,6 @@ cc_shared_library( EOF bazel build \ - --noincompatible_remove_legacy_whole_archive \ --experimental_cc_shared_library \ //foo:foo_shared >& "${TEST_log}" || fail "Expected build to succeed"