TensorFlow is failing with Bazel@HEAD
A bisect identified [this commit](https://github.com/bazelbuild/bazel/commit/661ebef465b08697a82fc3ee4c9fd540d953dc84) to be the breaking change. That commit is intended and I thought it wouldn't affect Bazel but it looks like Tensorflow is still relying on the deprecated [legacy whole archive behavior](https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java;drc=b95ce1708b46f7f0167904108d0317c1c470c6cb;l=354). The flag `incompatible_remove_legacy_whole_archive` was already flipped many releases ago but TF unflipped it [in its bazelrc](https://cs.opensource.google/tensorflow/tensorflow/+/master:.bazelrc;drc=226b4e2efbaedfb14a3ebe0bdef6ac890a8aed87;l=127).

This behavior has to stay, without this bug fix, part of the reason for the existence of cc_shared_library disappears since one of its main goals was to avoid linking libraries into the shared object that didn't need to be linked. With the legacy whole archive behavior, anything may be linked unnecessarily.

For each error like this that you get you have two options, for both options you first have to find the cc_library that the missing symbol belongs to, then:
- Add the `cc_library` as a direct dep of `cc_shared library` to `cc_shared_library.deps` (`cc_shared_library.roots` was renamed to `cc_shared_library.deps`)
- Leave the library where it is and add `alwayslink=True`

 /cc @learning-to-play @vam-google @chsigg  @jakeharmon8 FYI Looks like `--features=-force_no_whole_archive` is an workaround for this, but TF should really migrate off depending on the old behaviour.  gentle ping. TF has been broken on Bazel CI for a month now. TensorFlow upgraded Bazel version from 5.3.0 to 6.1.0 two weeks ago. Can the Bazel team own the fix from here? How is the Bazel version upgrade relevant? In any case, I don't have the cycles to fix the TF build.

The longer TF remains broken, the harder it is to fix the breakage. TF is failing with a different error now: https://buildkite.com/bazel/bazel-at-head-plus-disabled/builds/1692#01889ec5-aa99-41a8-9e11-487dc4866b72 According to the churn policy most of the time spent on changes must be spent by the team mandating the change. TF is green at 6.1.0. It is broken at Bazel@HEAD. It seems reasonable to me that the Bazel team helps resolve the majority the issue.
CC @meteorcloudy  We have spent plenty of time to bisect TF and identify the breaking change (https://github.com/bazelbuild/bazel/commit/661ebef465b08697a82fc3ee4c9fd540d953dc84), and as @oquenchil explained, this is broken because TF still depends on the deprecated legacy feature (whole archive). 

I found a workaround for TF by adding `--features=-force_no_whole_archive` as a build option, but eventually TF needs to migrate away from depending on the legacy behaviour.

I guess we can add first apply the workaround to stop the bleed here, sent https://github.com/tensorflow/tensorflow/pull/60837 Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60508">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60508">No</a>

https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/2997#0187e4ef-95bb-43c3-84ea-7cd94dbf0b7d

Platforms : Linux and Windows

Logs :  
```
ERROR: /var/lib/buildkite-agent/builds/bk-docker-5xrg/bazel-downstream-projects/tensorflow/tensorflow/cc/BUILD:766:22: Linking tensorflow/cc/ops/functional_ops_gen_cc [for tool] failed: (Exit 1): gcc failed: error executing command (from target //tensorflow/cc:ops/functional_ops_gen_cc)
  (cd /var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/c5e474199d1c61ddf0091ab0c5156762/execroot/org_tensorflow && \
  exec env - \
    PATH=/var/lib/buildkite-agent/.cache/bazelisk/local/-tmp-tmpjryk49s9-bazel/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    PWD=/proc/self/cwd \
    ZERO_AR_DATE=1 \
  /usr/bin/gcc @bazel-out/k8-opt-exec-ST-86d428d70b9d/bin/tensorflow/cc/ops/functional_ops_gen_cc-2.params)
# Configuration: 480f85a7755fc62a440f8fbe1f9f17e1ba62abf41ed236d08b174eb7e701c839
# Execution platform: @local_execution_config_platform//:platform
bazel-out/k8-opt-exec-ST-86d428d70b9d/bin/_solib_k8/_U_S_Stensorflow_Scc_Cops_Sfunctional_Uops_Ugen_Ucc___Utensorflow/libtensorflow_framework.so.2: error: undefined reference to 'tsl::table::NewLRUCache(unsigned long)'
bazel-out/k8-opt-exec-ST-86d428d70b9d/bin/_solib_k8/_U_S_Stensorflow_Scc_Cops_Sfunctional_Uops_Ugen_Ucc___Utensorflow/libtensorflow_framework.so.2: error: undefined reference to 'tensorflow::GpuIdManager::TfToPlatformDeviceId(tsl::gtl::IntType<tsl::TfDeviceId_tag_, int>, tsl::gtl::IntType<tsl::PlatformDeviceId_tag_, int>*)'
collect2: error: ld returned 1 exit status
Target //tensorflow/tools/pip_package:build_pip_package failed to build
(04:36:51) INFO: Elapsed time: 1816.483s, 
```
Steps followed :  
```
1. git clone -v https://github.com/tensorflow/tensorflow.git
2. git reset cf9014ebbc63ae2e905930e333bde676b87f0167 --hard
3. export USE_BAZEL_VERSION=8087520b153832656695fef6f3654ed432642c98
4. bazel build //tensorflow/tools/pip_package:build_pip_package

```
CC @meteorcloudy @oquenchil 




 