Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,26 @@ public abstract static class BazelBuildGraveyardOptions extends BuildGraveyardOp
help = "Deprecated no-op.")
public abstract boolean getDisableLegacyCcProvider();

@Deprecated
@Option(
name = "legacy_whole_archive",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.NO_OP},
metadataTags = {OptionMetadataTag.DEPRECATED},
help = "Deprecated no-op.")
public abstract boolean getLegacyWholeArchive();

@Deprecated
@Option(
name = "incompatible_remove_legacy_whole_archive",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.NO_OP},
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE, OptionMetadataTag.DEPRECATED},
help = "Deprecated no-op.")
public abstract boolean getRemoveLegacyWholeArchive();

@Option(
name = "python_path",
defaultValue = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public boolean experimentalLinkStaticLibrariesOnce() {
@StarlarkMethod(name = "legacy_whole_archive", documented = false, useStarlarkThread = true)
public boolean legacyWholeArchiveForStarlark(StarlarkThread thread) throws EvalException {
CcModule.checkPrivateStarlarkificationAllowlist(thread);
return cppOptions.getLegacyWholeArchive();
return true;
}

@StarlarkMethod(
Expand All @@ -495,7 +495,7 @@ public boolean legacyWholeArchiveForStarlark(StarlarkThread thread) throws EvalE
useStarlarkThread = true)
public boolean removeLegacyWholeArchiveForStarlark(StarlarkThread thread) throws EvalException {
CcModule.checkPrivateStarlarkificationAllowlist(thread);
return cppOptions.getRemoveLegacyWholeArchive();
return true;
}

public boolean getInmemoryDotdFiles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,24 +361,6 @@ public String getTypeDescription() {
converter = LabelConverter.class)
public abstract Label getCustomMalloc();

// @Deprecated
// TODO(https://github.com/bazelbuild/bazel/pull/26854): figure out how to deprecate
// this without warning spam because of a globally set bazelrc.
@Option(
name = "legacy_whole_archive",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.ACTION_COMMAND_LINES, OptionEffectTag.AFFECTS_OUTPUTS},
metadataTags = {OptionMetadataTag.HIDDEN},
help =
"Deprecated, superseded by --incompatible_remove_legacy_whole_archive "
+ "(see https://github.com/bazelbuild/bazel/issues/7362 for details). "
+ "When on, use --whole-archive for cc_binary rules that have "
+ "linkshared=True and either linkstatic=True or '-static' in linkopts. "
+ "This is for backwards compatibility only. "
+ "A better alternative is to use alwayslink=1 where required.")
public abstract boolean getLegacyWholeArchive();

@Option(
name = "strip",
defaultValue = "sometimes",
Expand Down Expand Up @@ -825,17 +807,6 @@ public Label getMemProfProfileLabelValue() {
help = "This flag is a noop and scheduled for removal.")
public abstract boolean getRequireCtxInConfigureFeatures();

@Option(
name = "incompatible_remove_legacy_whole_archive",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
help =
"If true, Bazel will not link library dependencies as whole archive by default "
+ "(see https://github.com/bazelbuild/bazel/issues/7362 for migration instructions).")
public abstract boolean getRemoveLegacyWholeArchive();

@Option(
name = "incompatible_enable_cc_toolchain_resolution",
defaultValue = "true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ bazel_fragments["CppOptions"] = fragment(
"//command_line_option:start_end_lib",
"//command_line_option:experimental_inmemory_dotd_files",
"//command_line_option:incompatible_enable_cc_toolchain_resolution",
"//command_line_option:incompatible_remove_legacy_whole_archive",
"//command_line_option:incompatible_dont_enable_host_nonhost_crosstool_features",
"//command_line_option:incompatible_require_ctx_in_configure_features",
"//command_line_option:incompatible_make_thinlto_command_lines_standalone",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public void testLinkoptsAndLibSrcsAreInCorrectOrder() throws Exception {
}

@Test
public void testLegacyWholeArchiveHasNoEffectOnDynamicModeDynamicLibraries() throws Exception {
public void testDynamicModeDynamicLibrariesDoNotUseWholeArchive() throws Exception {
getAnalysisMock()
.ccSupport()
.setupCcToolchainConfig(
Expand All @@ -224,7 +224,6 @@ public void testLegacyWholeArchiveHasNoEffectOnDynamicModeDynamicLibraries() thr
linkstatic = 0,
)
""");
useConfiguration("--legacy_whole_archive");
assertThat(getLibfooArguments()).doesNotContain("-Wl,-whole-archive");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ private void assertLinkopts(SpawnAction linkAction, String... optionPatterns) th
}

@Test
public void testGeneratedLib() throws Exception {
public void testGeneratedLibraryLinkedWithoutWholeArchive() throws Exception {
getAnalysisMock()
.ccSupport()
.setupCcToolchainConfig(
mockToolsConfig,
CcToolchainConfig.builder().withFeatures(CppRuleClasses.SUPPORTS_DYNAMIC_LINKER));

useConfiguration(
"--platforms=" + TestConstants.PLATFORM_LABEL,
"--noincompatible_remove_legacy_whole_archive");
useConfiguration("--platforms=" + TestConstants.PLATFORM_LABEL);
ConfiguredTarget genlib =
scratchConfiguredTarget(
"genrule",
Expand All @@ -79,9 +77,7 @@ public void testGeneratedLib() throws Exception {
"-shared",
"-o",
analysisMock.getProductName() + "-out/.+/genrule/thebinary.so",
"-Wl,-whole-archive",
analysisMock.getProductName() + "-out/.+/genrule/genlib.a",
"-Wl,-no-whole-archive");
analysisMock.getProductName() + "-out/.+/genrule/genlib.a");
}

/**
Expand Down