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:
#6861
#5883

RELNOTES: None.
PiperOrigin-RevId: 228175730
  • Loading branch information
hlopko authored and Copybara-Service committed Jan 7, 2019
1 parent 684cc2e commit a4529db
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,7 @@ static CcToolchainProvider getCcToolchainProvider(
attributes.getAdditionalBuildVariables()),
getBuiltinIncludes(attributes.getLibc()),
coverageEnvironment.build(),
toolchainInfo.supportsInterfaceSharedLibraries()
? attributes.getLinkDynamicLibraryTool()
: null,
attributes.getLinkDynamicLibraryTool(),
builtInIncludeDirectories,
sysroot,
fdoMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public boolean apply(Artifact artifact) {
public static final String SUPPORTS_DYNAMIC_LINKER_FEATURE =
"feature { name: '" + CppRuleClasses.SUPPORTS_DYNAMIC_LINKER + " enabled: true'}";

public static final String SUPPORTS_INTERFACE_SHARED_LIBRARIES =
"feature { name: '" + CppRuleClasses.SUPPORTS_INTERFACE_SHARED_LIBRARIES + "' enabled: true}";

/** Feature expected by the C++ rules when pic build is requested */
public static final String PIC_FEATURE =
""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.google.devtools.build.lib.analysis.RunfilesProvider;
import com.google.devtools.build.lib.analysis.util.ActionTester;
import com.google.devtools.build.lib.analysis.util.ActionTester.ActionCombinationFactory;
import com.google.devtools.build.lib.analysis.util.AnalysisMock;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
Expand Down Expand Up @@ -651,6 +652,28 @@ public void testInterfaceOutputWithoutBuildingDynamicLibraryIsError() throws Exc

@Test
public void testInterfaceOutputForDynamicLibrary() throws Exception {
AnalysisMock.get()
.ccSupport()
.setupCrosstool(
mockToolsConfig,
MockCcSupport.SUPPORTS_INTERFACE_SHARED_LIBRARIES,
"supports_interface_shared_objects: false");
useConfiguration();

scratch.file("foo/BUILD", "cc_library(name = 'foo', srcs = ['foo.cc'])");
ConfiguredTarget configuredTarget = getConfiguredTarget("//foo:foo");
assertThat(configuredTarget).isNotNull();
ImmutableList<String> inputs =
ImmutableList.copyOf(getGeneratingAction(configuredTarget, "foo/libfoo.so").getInputs())
.stream()
.map(Artifact::getExecPathString)
.collect(ImmutableList.toImmutableList());
assertThat(inputs.stream().anyMatch(i -> i.contains("tools/cpp/link_dynamic_library")))
.isTrue();
}

@Test
public void testInterfaceOutputForDynamicLibraryLegacy() throws Exception {
RuleContext ruleContext = createDummyRuleContext();

FeatureConfiguration featureConfiguration =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,30 @@ public void testLinkerParamFileIsExported() throws Exception {
}

@Test
public void testInterfaceLibraryBuildingVariablesWhenGenerationPossible() throws Exception {
public void testInterfaceLibraryBuildingVariablesWhenLegacyGenerationPossible() throws Exception {
// Make sure the interface shared object generation is enabled in the configuration
// (which it is not by default for some windows toolchains)
AnalysisMock.get()
.ccSupport()
.setupCrosstool(mockToolsConfig, "supports_interface_shared_objects: true");
useConfiguration();

verifyIfsoVariables();
}

@Test
public void testInterfaceLibraryBuildingVariablesWhenGenerationPossible() throws Exception {
// Make sure the interface shared object generation is enabled in the configuration
// (which it is not by default for some windows toolchains)
AnalysisMock.get()
.ccSupport()
.setupCrosstool(mockToolsConfig, MockCcSupport.SUPPORTS_INTERFACE_SHARED_LIBRARIES);
useConfiguration();

verifyIfsoVariables();
}

private void verifyIfsoVariables() throws Exception {
scratch.file("x/BUILD", "cc_library(name = 'foo', srcs = ['a.cc'])");
scratch.file("x/a.cc");

Expand Down

0 comments on commit a4529db

Please sign in to comment.