Skip to content

Commit 661ebef

Browse files
oquenchilcopybara-github
authored andcommitted
Disallow whole archive for cc_shared_library
RELNOTES:none PiperOrigin-RevId: 513219096 Change-Id: I75571974cd71622a4fac1cf837bd7db5b36fa75d
1 parent c06f93f commit 661ebef

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,11 @@ private static boolean needWholeArchive(
10771077
// is not needed).
10781078
return false;
10791079
}
1080+
if (featureConfiguration
1081+
.getRequestedFeatures()
1082+
.contains(CppRuleClasses.FORCE_NO_WHOLE_ARCHIVE)) {
1083+
return false;
1084+
}
10801085
if (cppConfig.removeLegacyWholeArchive()) {
10811086
// --incompatible_remove_legacy_whole_archive has been flipped, no --whole-archive for the
10821087
// entire build.

src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ public static ToolchainTypeRequirement ccToolchainTypeRequirement(RuleDefinition
461461
/** A feature marking that the target needs to link its deps in --whole-archive block. */
462462
public static final String LEGACY_WHOLE_ARCHIVE = "legacy_whole_archive";
463463

464+
/** A feature for force disabling whole-archive on a per target and per rule type basis. */
465+
public static final String FORCE_NO_WHOLE_ARCHIVE = "force_no_whole_archive";
466+
464467
/**
465468
* A feature marking that the target generates libraries that should not be put in a
466469
* --whole-archive block.

src/main/starlark/builtins_bzl/common/cc/experimental_cc_shared_library.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def _cc_shared_library_impl(ctx):
398398
feature_configuration = cc_common.configure_features(
399399
ctx = ctx,
400400
cc_toolchain = cc_toolchain,
401-
requested_features = ctx.features,
401+
requested_features = ctx.features + ["force_no_whole_archive"],
402402
unsupported_features = ctx.disabled_features,
403403
)
404404

0 commit comments

Comments
 (0)