aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2016-10-18 13:55:12 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-10-19 08:25:39 +0000
commitaecf826aa0cd12d25a8f6d69604d721f50d940f0 (patch)
treeda33c51ecf8312377ea48dfc4f0f0ee58daeabe9 /src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
parent8256c0f6320e9d548a2048b8fb2875d12830dc6e (diff)
*** Reason for rollback *** Causes huge memory blow-up after the analysis phase in CppLinkAction (LinkCommandLine). -- MOS_MIGRATED_REVID=136467836
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java54
1 files changed, 7 insertions, 47 deletions
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 d6b2c62d94..368db93b9b 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
@@ -86,14 +86,6 @@ public class CppLinkActionBuilder {
public static final String WHOLE_ARCHIVE_LINKER_INPUT_PARAMS_VARIABLE =
"whole_archive_linker_params";
- /**
- * A build variable for flags providing object files from libraries that were supposed to go in a
- * -whole_archive block. Old MSVC linker doesn't support /WHOLEARCHIVE:[LIB] option, so we link
- * object files directly as a workaround.
- */
- public static final String WHOLE_ARCHIVE_OBJECT_FILES_PARAMS_VARIABLE =
- "whole_archive_object_files_params";
-
/** A build variable whose presence indicates that whole archive flags should be applied. */
public static final String GLOBAL_WHOLE_ARCHIVE_VARIABLE = "global_whole_archive";
@@ -1164,7 +1156,6 @@ public class CppLinkActionBuilder {
Set<String> libopts;
List<String> linkerInputParams;
List<String> wholeArchiveLinkerInputParams;
- List<String> wholeArchiveObjectFilesParams;
List<String> noWholeArchiveInputs;
public void setRpathRoot(String rPathRoot) {
@@ -1187,10 +1178,6 @@ public class CppLinkActionBuilder {
this.wholeArchiveLinkerInputParams = wholeArchiveInputParams;
}
- public void setWholeArchiveObjectFilesParams(List<String> wholeArchiveObjectFilesParams) {
- this.wholeArchiveObjectFilesParams = wholeArchiveObjectFilesParams;
- }
-
public void setNoWholeArchiveInputs(List<String> noWholeArchiveInputs) {
this.noWholeArchiveInputs = noWholeArchiveInputs;
}
@@ -1215,10 +1202,6 @@ public class CppLinkActionBuilder {
return wholeArchiveLinkerInputParams;
}
- public List<String> getWholeArchiveObjectFilesParams() {
- return wholeArchiveObjectFilesParams;
- }
-
public List<String> getNoWholeArchiveInputs() {
return noWholeArchiveInputs;
}
@@ -1312,9 +1295,6 @@ public class CppLinkActionBuilder {
buildVariables.addSequenceVariable(
WHOLE_ARCHIVE_LINKER_INPUT_PARAMS_VARIABLE,
linkArgCollector.getWholeArchiveLinkerInputParams());
- buildVariables.addSequenceVariable(
- WHOLE_ARCHIVE_OBJECT_FILES_PARAMS_VARIABLE,
- linkArgCollector.getWholeArchiveObjectFilesParams());
// global archive
if (needWholeArchive) {
@@ -1493,7 +1473,6 @@ public class CppLinkActionBuilder {
}
List<String> wholeArchiveInputParams = new ArrayList<>();
- List<String> wholeArchiveObjectFilesParams = new ArrayList<>();
List<String> standardArchiveInputParams = new ArrayList<>();
for (LinkerInput input : linkerInputs) {
@@ -1511,11 +1490,7 @@ public class CppLinkActionBuilder {
input, standardArchiveInputParams, libOpts, solibDir, rpathRoot);
} else {
addStaticInputLinkOptions(
- input,
- wholeArchiveInputParams,
- wholeArchiveObjectFilesParams,
- standardArchiveInputParams,
- ltoMap);
+ input, wholeArchiveInputParams, standardArchiveInputParams, ltoMap);
}
}
@@ -1535,10 +1510,8 @@ public class CppLinkActionBuilder {
includeRuntimeSolibDir = true;
addDynamicInputLinkOptions(input, optionsList, libOpts, solibDir, rpathRoot);
} else {
- addStaticInputLinkOptions(
- input,
+ addStaticInputLinkOptions(input,
needWholeArchive ? noWholeArchiveInputs : wholeArchiveInputParams,
- needWholeArchive ? null : wholeArchiveObjectFilesParams,
needWholeArchive ? noWholeArchiveInputs : standardArchiveInputParams,
ltoMap);
}
@@ -1559,7 +1532,6 @@ public class CppLinkActionBuilder {
linkArgCollector.setLinkerInputParams(standardArchiveInputParams);
linkArgCollector.setWholeArchiveLinkerInputParams(wholeArchiveInputParams);
- linkArgCollector.setWholeArchiveObjectFilesParams(wholeArchiveObjectFilesParams);
linkArgCollector.setNoWholeArchiveInputs(noWholeArchiveInputs);
if (ltoMap != null) {
@@ -1614,10 +1586,7 @@ public class CppLinkActionBuilder {
* be supplied for LTO final links.
*/
private void addStaticInputLinkOptions(
- LinkerInput input,
- List<String> wholeArchiveOptions,
- List<String> wholeArchiveObjectFilesOptions,
- List<String> standardOptions,
+ LinkerInput input, List<String> wholeArchiveOptions, List<String> standardOptions,
@Nullable Map<Artifact, Artifact> ltoMap) {
Preconditions.checkState(!(input.getArtifactCategory() == ArtifactCategory.DYNAMIC_LIBRARY));
// If we had any LTO artifacts, ltoMap whould be non-null. In that case,
@@ -1662,19 +1631,10 @@ public class CppLinkActionBuilder {
return;
}
- final String fakePrefix = input.isFake() ? Link.FAKE_OBJECT_PREFIX : "";
-
- options.add(fakePrefix + inputArtifact.getExecPathString());
-
- if (input.containsObjectFiles() && inputNeedsWholeArchive(input)) {
- for (Artifact objectFile : input.getObjectFiles()) {
- if (ltoMap != null && ltoMap.remove(objectFile) != null) {
- // The LTO artifacts that should be included in the final link
- // are listed in the linkerParamsFile.
- continue;
- }
- wholeArchiveObjectFilesOptions.add(fakePrefix + objectFile.getExecPathString());
- }
+ if (input.isFake()) {
+ options.add(Link.FAKE_OBJECT_PREFIX + inputArtifact.getExecPathString());
+ } else {
+ options.add(inputArtifact.getExecPathString());
}
}
}