Skip to content

Commit

Permalink
Don't rely on supports_interface_shared_objects for toolchain inputs
Browse files Browse the repository at this point in the history
    Progress towards:
    bazelbuild/bazel#6861
    bazelbuild/bazel#5883

    RELNOTES: None.
    PiperOrigin-RevId: 228175730
  • Loading branch information
Luca Di Grazia committed Sep 4, 2022
1 parent acbef70 commit 4e88855
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,7 @@ static CcToolchainProvider getCcToolchainProvider(
return null;
}

if (fdoMode != FdoMode.OFF
&& fdoMode != FdoMode.XBINARY_FDO
&& cppConfiguration.getXFdoProfileLabel() != null) {
if (fdoMode != FdoMode.XBINARY_FDO && cppConfiguration.getXFdoProfileLabel() != null) {
ruleContext.throwWithRuleError("--xbinary_fdo cannot accept profile input other than *.xfdo");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ public static PackageIdentifier getMockCrosstoolsTop() {
PathFragment.create(TestConstants.MOCK_CC_CROSSTOOL_PATH));
} catch (LabelSyntaxException e) {
Verify.verify(false);
throw new AssertionError(e);
throw new AssertionError();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,8 @@ public void testCompilesDynamicModeTestSourcesWithoutFeatureIntoDynamicLibrary()
}
scratch.file(
"x/BUILD",
"cc_test(name='a', srcs=['a.cc'], features=['-static_link_test_srcs'])",
"cc_binary(name='b', srcs=['a.cc'])",
"cc_test(name='c', srcs=['a.cc'], features=['-static_link_test_srcs'], linkstatic=1)");
"cc_test(name = 'a', srcs = ['a.cc'], features = ['-static_link_test_srcs'])",
"cc_binary(name = 'b', srcs = ['a.cc'])");
scratch.file("x/a.cc", "int main() {}");
useConfiguration("--force_pic");

Expand All @@ -312,13 +311,6 @@ public void testCompilesDynamicModeTestSourcesWithoutFeatureIntoDynamicLibrary()
runfilesProvider = configuredTarget.getProvider(RunfilesProvider.class);
assertThat(artifactsToStrings(runfilesProvider.getDefaultRunfiles().getArtifacts()))
.containsExactly("bin x/b");

configuredTarget = getConfiguredTarget("//x:c");
linkAction = (CppLinkAction) getGeneratingAction(configuredTarget, "x/c");
assertThat(artifactsToStrings(linkAction.getInputs())).contains("bin x/_objs/c/a.pic.o");
runfilesProvider = configuredTarget.getProvider(RunfilesProvider.class);
assertThat(artifactsToStrings(runfilesProvider.getDefaultRunfiles().getArtifacts()))
.containsExactly("bin x/c");
}

@Test
Expand Down Expand Up @@ -413,7 +405,7 @@ public Action generate(ImmutableSet<NonStaticAttributes> attributesToFlip)
? dynamicOutputFile
: staticOutputFile,
toolchain,
toolchain.getFdoContext(),
toolchain.getFdoProvider(),
featureConfiguration,
MockCppSemantics.INSTANCE) {};
if (attributesToFlip.contains(NonStaticAttributes.OUTPUT_FILE)) {
Expand Down Expand Up @@ -471,7 +463,7 @@ public Action generate(ImmutableSet<StaticKeyAttributes> attributes)
? staticOutputFile
: dynamicOutputFile,
toolchain,
toolchain.getFdoContext(),
toolchain.getFdoProvider(),
featureConfiguration,
MockCppSemantics.INSTANCE) {};
builder.setLinkType(
Expand Down Expand Up @@ -503,7 +495,7 @@ public void testCommandLineSplitting() throws Exception {
ruleContext,
output,
toolchain,
toolchain.getFdoContext(),
toolchain.getFdoProvider(),
FeatureConfiguration.EMPTY,
MockCppSemantics.INSTANCE);
builder.setLinkType(LinkTargetType.STATIC_LIBRARY);
Expand Down Expand Up @@ -597,7 +589,7 @@ private CppLinkActionBuilder createLinkBuilder(
.getBinDirectory(ruleContext.getRule().getRepository())),
ruleContext.getConfiguration(),
toolchain,
toolchain.getFdoContext(),
toolchain.getFdoProvider(),
featureConfiguration,
MockCppSemantics.INSTANCE)
.addObjectFiles(nonLibraryInputs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ private void assertStripBinaryVariableIsPresent(
}

@Test
public void testIsUsingFissionVariableUsingLegacyFields() throws Exception {
public void testIsUsingFissionVariable() throws Exception {
scratch.file("x/BUILD",
"cc_binary(name = 'foo', srcs = ['foo.cc'])");
scratch.file("x/foo.cc");
Expand All @@ -411,29 +411,6 @@ public void testIsUsingFissionVariableUsingLegacyFields() throws Exception {
.isTrue();
}

@Test
public void testIsUsingFissionVariable() throws Exception {
scratch.file("x/BUILD", "cc_binary(name = 'foo', srcs = ['foo.cc'])");
scratch.file("x/foo.cc");

AnalysisMock.get()
.ccSupport()
.setupCrosstool(mockToolsConfig, MockCcSupport.PER_OBJECT_DEBUG_INFO_CONFIGURATION);

useConfiguration("--fission=no");
ConfiguredTarget target = getConfiguredTarget("//x:foo");
CcToolchainVariables variables = getLinkBuildVariables(target, LinkTargetType.EXECUTABLE);
assertThat(variables.isAvailable(LinkBuildVariables.IS_USING_FISSION.getVariableName()))
.isFalse();

useConfiguration("--fission=yes");
ConfiguredTarget fissionTarget = getConfiguredTarget("//x:foo");
CcToolchainVariables fissionVariables =
getLinkBuildVariables(fissionTarget, LinkTargetType.EXECUTABLE);
assertThat(fissionVariables.isAvailable(LinkBuildVariables.IS_USING_FISSION.getVariableName()))
.isTrue();
}

@Test
public void testSysrootVariable() throws Exception {
AnalysisMock.get()
Expand Down

0 comments on commit 4e88855

Please sign in to comment.