aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-03-16 08:46:01 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-16 08:47:50 -0700
commit435fde772d284cdb5b73a88c3c02f7aa94a01ec1 (patch)
treeaf92b160aaaeb1e841e9ec8346787ce37f6c4e61 /src/main/java/com/google/devtools
parentb892a9a8d2d3d1f923c0032ee08908179cfbf276 (diff)
Pass all TreeArtifacts to the ParameterWriteFileAction so they're expanded by the time the action runs.
Tested: custom_blaze build experimental/users/kmensah/cc_proto_library:libnon_android_example.so --config android_x86 -s RELNOTES: Properly handle tree artifacts on the link command line coming from a cc_library dependency. PiperOrigin-RevId: 189344192
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java43
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java20
2 files changed, 23 insertions, 40 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java
index a63712ee65..0477aef97a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java
@@ -1394,61 +1394,47 @@ public class CcToolchainFeatures implements Serializable {
}
private final String name;
- private final Artifact directory;
- private final ImmutableList<String> objectFiles;
+ private final ImmutableList<Artifact> objectFiles;
private final boolean isWholeArchive;
private final Type type;
public static LibraryToLinkValue forDynamicLibrary(String name) {
return new LibraryToLinkValue(
- Preconditions.checkNotNull(name), null, null, false, Type.DYNAMIC_LIBRARY);
+ Preconditions.checkNotNull(name), null, false, Type.DYNAMIC_LIBRARY);
}
public static LibraryToLinkValue forVersionedDynamicLibrary(
String name) {
return new LibraryToLinkValue(
- Preconditions.checkNotNull(name), null, null, false, Type.VERSIONED_DYNAMIC_LIBRARY);
+ Preconditions.checkNotNull(name), null, false, Type.VERSIONED_DYNAMIC_LIBRARY);
}
public static LibraryToLinkValue forInterfaceLibrary(String name) {
return new LibraryToLinkValue(
- Preconditions.checkNotNull(name), null, null, false, Type.INTERFACE_LIBRARY);
+ Preconditions.checkNotNull(name), null, false, Type.INTERFACE_LIBRARY);
}
public static LibraryToLinkValue forStaticLibrary(String name, boolean isWholeArchive) {
return new LibraryToLinkValue(
- Preconditions.checkNotNull(name), null, null, isWholeArchive, Type.STATIC_LIBRARY);
+ Preconditions.checkNotNull(name), null, isWholeArchive, Type.STATIC_LIBRARY);
}
public static LibraryToLinkValue forObjectFile(String name, boolean isWholeArchive) {
return new LibraryToLinkValue(
- Preconditions.checkNotNull(name), null, null, isWholeArchive, Type.OBJECT_FILE);
+ Preconditions.checkNotNull(name), null, isWholeArchive, Type.OBJECT_FILE);
}
public static LibraryToLinkValue forObjectFileGroup(
- ImmutableList<String> objects, boolean isWholeArchive) {
+ ImmutableList<Artifact> objects, boolean isWholeArchive) {
Preconditions.checkNotNull(objects);
Preconditions.checkArgument(!objects.isEmpty());
- return new LibraryToLinkValue(null, null, objects, isWholeArchive, Type.OBJECT_FILE_GROUP);
- }
-
- public static LibraryToLinkValue forObjectDirectory(
- Artifact directory, boolean isWholeArchive) {
- Preconditions.checkNotNull(directory);
- Preconditions.checkArgument(directory.isTreeArtifact());
- return new LibraryToLinkValue(
- null, directory, null, isWholeArchive, Type.OBJECT_FILE_GROUP);
+ return new LibraryToLinkValue(null, objects, isWholeArchive, Type.OBJECT_FILE_GROUP);
}
@VisibleForSerialization
LibraryToLinkValue(
- String name,
- Artifact directory,
- ImmutableList<String> objectFiles,
- boolean isWholeArchive,
- Type type) {
+ String name, ImmutableList<Artifact> objectFiles, boolean isWholeArchive, Type type) {
this.name = name;
- this.directory = directory;
this.objectFiles = objectFiles;
this.isWholeArchive = isWholeArchive;
this.type = type;
@@ -1462,17 +1448,14 @@ public class CcToolchainFeatures implements Serializable {
return new StringValue(name);
} else if (OBJECT_FILES_FIELD_NAME.equals(field) && type.equals(Type.OBJECT_FILE_GROUP)) {
ImmutableList.Builder<String> expandedObjectFiles = ImmutableList.builder();
- if (objectFiles != null) {
- expandedObjectFiles.addAll(objectFiles);
- } else if (directory != null) {
- if (expander != null) {
+ for (Artifact objectFile : objectFiles) {
+ if (objectFile.isTreeArtifact() && (expander != null)) {
List<Artifact> artifacts = new ArrayList<>();
- expander.expand(directory, artifacts);
-
+ expander.expand(objectFile, artifacts);
expandedObjectFiles.addAll(
Iterables.transform(artifacts, artifact -> artifact.getExecPathString()));
} else {
- expandedObjectFiles.add(directory.getExecPathString());
+ expandedObjectFiles.add(objectFile.getExecPathString());
}
}
return new StringSequence(expandedObjectFiles.build());
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
index 317e808da1..cb6776b25f 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
@@ -1188,18 +1188,17 @@ public class CppLinkActionBuilder {
if (linkCommandLine.getParamFile() != null) {
inputsBuilder.add(ImmutableList.of(linkCommandLine.getParamFile()));
// Pass along tree artifacts, so they can be properly expanded.
- ImmutableSet<Artifact> expandedNonLibraryTreeArtifactInputs =
- ImmutableSet.<Artifact>builder()
- .addAll(objectArtifacts)
- .addAll(linkstampObjectArtifacts)
- .build()
+ ImmutableSet<Artifact> paramFileActionInputs =
+ ImmutableSet.<LinkerInput>copyOf(linkerInputs)
.stream()
+ .map(LinkerInput::getArtifact)
.filter(a -> a.isTreeArtifact())
.collect(ImmutableSet.toImmutableSet());
+
Action parameterFileWriteAction =
new ParameterFileWriteAction(
getOwner(),
- expandedNonLibraryTreeArtifactInputs,
+ paramFileActionInputs,
paramFile,
linkCommandLine.paramCmdLine(),
ParameterFile.ParameterFileType.UNQUOTED,
@@ -2221,7 +2220,7 @@ public class CppLinkActionBuilder {
if (Link.useStartEndLib(input, CppHelper.getArchiveType(cppConfiguration, toolchain))) {
Iterable<Artifact> archiveMembers = input.getObjectFiles();
if (!Iterables.isEmpty(archiveMembers)) {
- ImmutableList.Builder<String> nonLtoArchiveMembersBuilder = ImmutableList.builder();
+ ImmutableList.Builder<Artifact> nonLtoArchiveMembersBuilder = ImmutableList.builder();
for (Artifact member : archiveMembers) {
Artifact a;
if (ltoMap != null && (a = ltoMap.remove(member)) != null) {
@@ -2236,9 +2235,9 @@ public class CppLinkActionBuilder {
// instead of the bitcode object.
member = a;
}
- nonLtoArchiveMembersBuilder.add(member.getExecPathString());
+ nonLtoArchiveMembersBuilder.add(member);
}
- ImmutableList<String> nonLtoArchiveMembers = nonLtoArchiveMembersBuilder.build();
+ ImmutableList<Artifact> nonLtoArchiveMembers = nonLtoArchiveMembersBuilder.build();
if (!nonLtoArchiveMembers.isEmpty()) {
boolean inputIsWholeArchive = !isRuntimeLinkerInput && needWholeArchive;
librariesToLink.addValue(
@@ -2279,7 +2278,8 @@ public class CppLinkActionBuilder {
if (artifactCategory.equals(ArtifactCategory.OBJECT_FILE)) {
if (inputArtifact.isTreeArtifact()) {
librariesToLink.addValue(
- LibraryToLinkValue.forObjectDirectory(inputArtifact, inputIsWholeArchive));
+ LibraryToLinkValue.forObjectFileGroup(
+ ImmutableList.<Artifact>of(inputArtifact), inputIsWholeArchive));
} else {
librariesToLink.addValue(LibraryToLinkValue.forObjectFile(name, inputIsWholeArchive));
}