Skip to content

Commit

Permalink
Disallow whole archive for cc_shared_library
Browse files Browse the repository at this point in the history
RELNOTES:none
PiperOrigin-RevId: 513219096
Change-Id: I75571974cd71622a4fac1cf837bd7db5b36fa75d
  • Loading branch information
oquenchil authored and copybara-github committed Mar 1, 2023
1 parent c06f93f commit 661ebef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,11 @@ private static boolean needWholeArchive(
// is not needed).
return false;
}
if (featureConfiguration
.getRequestedFeatures()
.contains(CppRuleClasses.FORCE_NO_WHOLE_ARCHIVE)) {
return false;
}
if (cppConfig.removeLegacyWholeArchive()) {
// --incompatible_remove_legacy_whole_archive has been flipped, no --whole-archive for the
// entire build.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ public static ToolchainTypeRequirement ccToolchainTypeRequirement(RuleDefinition
/** A feature marking that the target needs to link its deps in --whole-archive block. */
public static final String LEGACY_WHOLE_ARCHIVE = "legacy_whole_archive";

/** A feature for force disabling whole-archive on a per target and per rule type basis. */
public static final String FORCE_NO_WHOLE_ARCHIVE = "force_no_whole_archive";

/**
* A feature marking that the target generates libraries that should not be put in a
* --whole-archive block.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def _cc_shared_library_impl(ctx):
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
requested_features = ctx.features + ["force_no_whole_archive"],
unsupported_features = ctx.disabled_features,
)

Expand Down

0 comments on commit 661ebef

Please sign in to comment.