<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 23, 2017 at 2:48 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I just wanted to help you because it seems easy for me to make a change because I know a lot about lld, and you seems to be busy on Zig language itself. I'll update your patch and send it to you for review.</div></blockquote><div><br></div><div>Thanks Rui, I appreciate that very much.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 23, 2017 at 11:40 AM, Andrew Kelley <span dir="ltr"><<a href="mailto:superjoe30@gmail.com" target="_blank">superjoe30@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Mon, Oct 23, 2017 at 2:30 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">If you are not particularly interested in doing it yourself, I can do that for you based on your patch.</div></blockquote><div><br></div></span><div>Sorry for the delay. I've been trying to get a moment to test and submit the revision.</div><div><br></div><div>If you're willing to do it, that's easiest for me.</div><div><div class="m_8579992970014347192h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_8579992970014347192m_-4449149472465297735HOEnZb"><div class="m_8579992970014347192m_-4449149472465297735h5"><div class="gmail_extra"><br><div class="gmail_quote">On Oct 21, 2017 4:40 PM, "Rui Ueyama" <<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Thank you for doing this.</div><div class="gmail_quote"><br></div><div class="gmail_quote">Can you take a look at ELF/Driver.cpp? elf::link has `CanExitEarly` parameter. We should add the same parameter to coff::link so that two functions have the same interface.</div><div class="gmail_quote"><br></div><div class="gmail_quote">On Sat, Oct 21, 2017 at 12:45 PM, Andrew Kelley via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:12.8px">Previously, the COFF driver would call exit(0) when called as</div><div style="font-size:12.8px">a library. Now there is a global function setLibraryMode()</div><div style="font-size:12.8px">which causes link() to return on success.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Furthermore, link() calls freeArena() before returning, to</div><div style="font-size:12.8px">clean up resources.</div><div style="font-size:12.8px">---</div><div style="font-size:12.8px"> lld/COFF/Driver.cpp | 27 +++++++++++++++++++++++----</div><div style="font-size:12.8px"> lld/COFF/Driver.h   |  2 ++</div><div style="font-size:12.8px"> 2 files changed, 25 insertions(+), 4 deletions(-)</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><div>diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp</div><div>index c039740715c..a769196e8b8 100644</div><div>--- a/lld/COFF/Driver.cpp</div><div>+++ b/lld/COFF/Driver.cpp</div><div>@@ -46,6 +46,12 @@ using llvm::sys::Process;</div><div> namespace lld {</div><div> namespace coff {</div><div> </div><div>+</div><div>+static bool IsLibraryMode = false;</div><div>+void setLibraryMode(void) {</div><div>+  IsLibraryMode = true;</div><div>+}</div><div>+</div><div> Configuration *Config;</div><div> LinkerDriver *Driver;</div><div> </div><div>@@ -65,6 +71,7 @@ bool link(ArrayRef<const char *> Args, raw_ostream &Diag) {</div><div> </div><div>   Driver = make<LinkerDriver>();</div><div>   Driver->link(Args);</div><div>+  freeArena();</div><div>   return !ErrorCount;</div><div> }</div><div> </div><div>@@ -1077,7 +1084,11 @@ void LinkerDriver::link(ArrayRef<co<wbr>nst char *> ArgsArr) {</div><div>   if (!Args.hasArg(OPT_INPUT)) {</div><div>     fixupExports();</div><div>     createImportLibrary(/*AsLib=*<wbr>/true);</div><div>-    exit(0);</div><div>+    if (IsLibraryMode) {</div><div>+      return;</div><div>+    } else {</div><div>+      exit(0);</div><div>+    }</div><div>   }</div><div> </div><div>   // Handle /delayload</div><div>@@ -1169,7 +1180,11 @@ void LinkerDriver::link(ArrayRef<co<wbr>nst char *> ArgsArr) {</div><div>   // This is useful because MSVC link.exe can generate complete PDBs.</div><div>   if (Args.hasArg(OPT_msvclto)) {</div><div>     invokeMSVC(Args);</div><div>-    exit(0);</div><div>+    if (IsLibraryMode) {</div><div>+      return;</div><div>+    } else {</div><div>+      exit(0);</div><div>+    }</div><div>   }</div><div> </div><div>   // Do LTO by compiling bitcode input files to a set of native COFF files then</div><div>@@ -1267,8 +1282,12 @@ void LinkerDriver::link(ArrayRef<co<wbr>nst char *> ArgsArr) {</div><div>   if (ErrorCount)</div><div>     return;</div><div> </div><div>-  // Call exit to avoid calling destructors.</div><div>-  exit(0);</div><div>+  if (IsLibraryMode) {</div><div>+    return</div><div>+  } else {</div><div>+    // Call exit to avoid calling destructors.</div><div>+    exit(0);</div><div>+  }</div><div> }</div><div> </div><div> } // namespace coff</div><div>diff --git a/lld/COFF/Driver.h b/lld/COFF/Driver.h</div><div>index df54fc1e45e..c1c0f36b011 100644</div><div>--- a/lld/COFF/Driver.h</div><div>+++ b/lld/COFF/Driver.h</div><div>@@ -35,6 +35,8 @@ using llvm::COFF::MachineTypes;</div><div> using llvm::COFF::WindowsSubsystem;</div><div> using llvm::Optional;</div><div> </div><div>+void setLibraryMode(void);</div><div>+</div><div> // Implemented in MarkLive.cpp.</div><div> void markLive(const std::vector<Chunk *> &Chunks);</div></div></div>
<br>______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div></div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>