diff options
author | Ulf Adams <ulfjack@google.com> | 2015-08-26 13:07:32 +0000 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2015-08-27 14:44:17 +0000 |
commit | 3c620c0ba325edaeefe81ef92519cd85a732e3a9 (patch) | |
tree | 44e5869f4b46d6569b430bb01016c89217a3a064 /src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java | |
parent | 8dc5fb2c70f2ff9db3f804b0bba20edf4a512f78 (diff) |
Clean up the link command action code a bit.
--
MOS_MIGRATED_REVID=101568873
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java index a64a89250a..630eb5a498 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java @@ -415,8 +415,7 @@ public final class LinkCommandLine extends CommandLine { argv.addAll( cppConfiguration.getArFlags(cppConfiguration.archiveType() == Link.ArchiveType.THIN)); argv.add(output.getExecPathString()); - addInputFileLinkOptions(argv, /*needWholeArchive=*/false, - /*includeLinkopts=*/false); + addInputFileLinkOptions(argv, /*needWholeArchive=*/false); break; default: @@ -652,7 +651,21 @@ public final class LinkCommandLine extends CommandLine { } } - addInputFileLinkOptions(argv, needWholeArchive, /*includeLinkopts=*/true); + addInputFileLinkOptions(argv, needWholeArchive); + + /* + * For backwards compatibility, linkopts come _after_ inputFiles. + * This is needed to allow linkopts to contain libraries and + * positional library-related options such as + * -Wl,--begin-group -lfoo -lbar -Wl,--end-group + * or + * -Wl,--as-needed -lfoo -Wl,--no-as-needed + * + * As for the relative order of the three different flavours of linkopts + * (global defaults, per-target linkopts, and command-line linkopts), + * we have no idea what the right order should be, or if anyone cares. + */ + argv.addAll(linkopts); // Extra toolchain link options based on the output's link staticness. if (fullyStatic) { @@ -698,8 +711,7 @@ public final class LinkCommandLine extends CommandLine { * library objects (.lo) need to be wrapped with -Wl,-whole-archive and * -Wl,-no-whole-archive. */ - private void addInputFileLinkOptions(List<String> argv, boolean globalNeedWholeArchive, - boolean includeLinkopts) { + private void addInputFileLinkOptions(List<String> argv, boolean globalNeedWholeArchive) { // The Apple ld doesn't support -whole-archive/-no-whole-archive. It // does have -all_load/-noall_load, but -all_load is a global setting // that affects all subsequent files, and -noall_load is simply ignored. @@ -860,22 +872,6 @@ public final class LinkCommandLine extends CommandLine { argv.addAll(noWholeArchiveInputs); } - if (includeLinkopts) { - /* - * For backwards compatibility, linkopts come _after_ inputFiles. - * This is needed to allow linkopts to contain libraries and - * positional library-related options such as - * -Wl,--begin-group -lfoo -lbar -Wl,--end-group - * or - * -Wl,--as-needed -lfoo -Wl,--no-as-needed - * - * As for the relative order of the three different flavours of linkopts - * (global defaults, per-target linkopts, and command-line linkopts), - * we have no idea what the right order should be, or if anyone cares. - */ - argv.addAll(linkopts); - } - if (ltoMap != null) { Preconditions.checkState( ltoMap.size() == 0, "Still have LTO objects left: " + ltoMap + ", command-line: " + argv); |