[PATCH] D19705: ELF: Add "fast link" mode.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 28 18:27:01 PDT 2016
ruiu created this revision.
ruiu added a reviewer: rafael.
ruiu added a subscriber: llvm-commits.
I'm not 100% sure if this is the right thing to do, but at least
it seems to be worth discussing. This patch adds a new command line
flag, --fast, to the linker. That flag disables costly but optional
features so that the linker produces semantically correct (but larger)
output quickly. Currently it only disables section merging.
This flag is not intended to be used for final production linking.
It is intended to be used in compile-link-test cycle.
Time to link clang with debug info is about 2x faster with the flag.
Head:
13.24 seconds
Output size: 1227189664 bytes
With this patch:
7.41 seconds
Output size: 2490281784 bytes
http://reviews.llvm.org/D19705
Files:
ELF/Config.h
ELF/Driver.cpp
ELF/InputFiles.cpp
ELF/Options.td
Index: ELF/Options.td
===================================================================
--- ELF/Options.td
+++ ELF/Options.td
@@ -65,6 +65,9 @@
def export_dynamic_symbol : Separate<["--", "-"], "export-dynamic-symbol">,
HelpText<"Put a symbol in the dynamic symbol table">;
+def fast: Flag<["--", "-"], "fast">,
+ HelpText<"Disable slow linker features; may produce larger output">;
+
def fini : Separate<["-"], "fini">, MetaVarName<"<symbol>">,
HelpText<"Specify a finalizer function">;
Index: ELF/InputFiles.cpp
===================================================================
--- ELF/InputFiles.cpp
+++ ELF/InputFiles.cpp
@@ -143,6 +143,12 @@
template <class ELFT> static bool shouldMerge(const typename ELFT::Shdr &Sec) {
typedef typename ELFT::uint uintX_t;
+
+ // In fast link mode, we don't merge sections. This makes the linker
+ // about 2x faster, while it will make it produce larger output.
+ if (Config->Fast)
+ return false;
+
uintX_t Flags = Sec.sh_flags;
if (!(Flags & SHF_MERGE))
return false;
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -323,6 +323,7 @@
Config->EhFrameHdr = Args.hasArg(OPT_eh_frame_hdr);
Config->EnableNewDtags = !Args.hasArg(OPT_disable_new_dtags);
Config->ExportDynamic = Args.hasArg(OPT_export_dynamic);
+ Config->Fast = Args.hasArg(OPT_fast);
Config->GcSections = Args.hasArg(OPT_gc_sections);
Config->ICF = Args.hasArg(OPT_icf);
Config->NoGnuUnique = Args.hasArg(OPT_no_gnu_unique);
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -65,6 +65,7 @@
bool EhFrameHdr;
bool EnableNewDtags;
bool ExportDynamic;
+ bool Fast;
bool GcSections;
bool GnuHash = false;
bool ICF;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19705.55519.patch
Type: text/x-patch
Size: 1850 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160429/2296c001/attachment.bin>
More information about the llvm-commits
mailing list