diff options
author | Googler <noreply@google.com> | 2018-01-19 21:10:09 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-19 21:12:03 -0800 |
commit | c193fc40c2f6f11e30d18cb6191b17810aeda9c5 (patch) | |
tree | 51feb1685032cb5e068d7dfd3e9d3f13ccc62f13 /src/main/java/com/google/devtools/build | |
parent | dd17d9fd7329954210e86b82798ff012cb34ebd2 (diff) |
Non functional changes.
Just shuffling code in the build() method to simplify future review.
1. Reuse result of getRootRelativePath()
2. Delay linkerInputs generation
3. allowLtoIndexing ? thinltoParamFile : null -> thinltoParamFile
it must be null if indexing is not allowed
RELNOTES: None
PiperOrigin-RevId: 182626938
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java | 31 |
1 files changed, 16 insertions, 15 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 31e287a4cd..63e9e0336d 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 @@ -806,17 +806,6 @@ public class CppLinkActionBuilder { } final Iterable<Artifact> objectArtifacts = LinkerInputs.toLibraryArtifacts(objectFileInputs); - final Iterable<LinkerInput> linkerInputs = - IterablesChain.<LinkerInput>builder() - .add(objectFileInputs) - .add( - ImmutableIterable.from( - Link.mergeInputsCmdLine( - uniqueLibraries, - needWholeArchive, - CppHelper.getArchiveType(cppConfiguration, toolchain)))) - .build(); - final LibraryToLink outputLibrary = linkType.isExecutable() ? null @@ -839,6 +828,7 @@ public class CppLinkActionBuilder { /* sharedNonLtoBackends= */ null); @Nullable Artifact thinltoParamFile = null; + PathFragment outputRootPath = output.getRootRelativePath(); if (allowLtoIndexing && allLtoArtifacts != null) { // Create artifact for the file that the LTO indexing step will emit // object file names into for any that were included in the link as @@ -847,8 +837,7 @@ public class CppLinkActionBuilder { // Note that the paths emitted into this file will have their prefixes // replaced with the final output directory, so they will be the paths // of the native object files not the input bitcode files. - PathFragment linkerParamFileRootPath = - ParameterFile.derivePath(output.getRootRelativePath(), "lto-final"); + PathFragment linkerParamFileRootPath = ParameterFile.derivePath(outputRootPath, "lto-final"); thinltoParamFile = linkArtifactFactory.create(ruleContext, configuration, linkerParamFileRootPath); } @@ -872,11 +861,22 @@ public class CppLinkActionBuilder { symbolCounts); } + final Iterable<LinkerInput> linkerInputs = + IterablesChain.<LinkerInput>builder() + .add(objectFileInputs) + .add( + ImmutableIterable.from( + Link.mergeInputsCmdLine( + uniqueLibraries, + needWholeArchive, + CppHelper.getArchiveType(cppConfiguration, toolchain)))) + .build(); + ImmutableList<LinkerInput> runtimeLinkerInputs = ImmutableList.copyOf(LinkerInputs.simpleLinkerInputs(runtimeInputs, runtimeType)); PathFragment paramRootPath = - ParameterFile.derivePath(output.getRootRelativePath(), (isLtoIndexing) ? "lto-index" : "2"); + ParameterFile.derivePath(outputRootPath, (isLtoIndexing) ? "lto-index" : "2"); @Nullable final Artifact paramFile = @@ -887,6 +887,7 @@ public class CppLinkActionBuilder { // Add build variables necessary to template link args into the crosstool. Variables.Builder buildVariablesBuilder = new Variables.Builder(toolchain.getBuildVariables()); Preconditions.checkState(!isLtoIndexing || allowLtoIndexing); + Preconditions.checkState(allowLtoIndexing || thinltoParamFile == null); CppLinkVariablesExtension variablesExtension = isLtoIndexing ? new CppLinkVariablesExtension( @@ -909,7 +910,7 @@ public class CppLinkActionBuilder { runtimeLinkerInputs, output, paramFile, - allowLtoIndexing ? thinltoParamFile : null, + thinltoParamFile, /* ltoOutputRootPrefix= */ PathFragment.EMPTY_FRAGMENT, allowLtoIndexing, toolchain.getInterfaceSoBuilder(), |