forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cc_shared_library to take into account indirect top level deps
The cc_shared_library implementation wraps its top level direct dependencies in whole archive because otherwise since there aren't any symbols in the shared library depending on them they would be dropped by the linker. There are instances where the target placed in the direct dep of a cc_shared_library doesn't have a linker_input or if it has it, the linker_input may not have any code to be linked statically into the shared library. When that happens, the actual code to be linked is depended on indirectly, e.g. cc_shared_library -> cc_proto_library -> proto_library. Here it is the code generated by the aspect applied on proto_library that should be linked statically. Since this dependency was indirect, that code wasn't whole-archived. Before this fix, we only tried to whole-archive cc_proto_library but the cc_proto_library target itself did not produce any linker_inputs, for this reason the code from the proto_library was dropped by the linker. This CL also adds more test coverage for the dynamic_only_roots failure triggered explicitly by the cc_shared_library implementation. RELNOTES:none PiperOrigin-RevId: 515017649 Change-Id: I022e1cb4f70fa4584893d3c34172236fdf2e5f73
- Loading branch information
1 parent
56a9efb
commit f9008f6
Showing
7 changed files
with
190 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...n/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/indirect_dep.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2023 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
int indirect_dep() { return 0; } |
15 changes: 15 additions & 0 deletions
15
.../starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/indirect_dep2.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2023 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
int indirect_dep2() { return 0; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters