<div dir="auto"><div>That sounds good to me<br><div class="gmail_extra"><br><div class="gmail_quote">On Sep 1, 2017 5:20 PM, "Rui Ueyama" <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think I prefer adding CanExitEarly flag to COFF lld just like ELF lld. We call `exit` at the end of link() because exiting without calling destructors of globallly-allocated objects makes the linker noticeably faster, so I don't want to replace it with return.</div><div class="elided-text"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 31, 2017 at 3:16 PM, 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">Correct, I am using libCOFF, libELF, and libMACHO all as a library. Ideally all cases would return and report an error and clean up memory, etc, instead of calling exit. However this is sufficient for my needs for now. It is ok for LLD to crash if I supply an invalid command line argument, I won't do that.<div><div class="m_2069882682655569769h5"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 31, 2017 at 5:47 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">COFF lld uses exit() unlike ELF lld due to lack of user needs, but are you trying to use it as a library? If so, I believe you need to fix other places where exit() is called on success or for a trivial error (such as invalid command line argument) as well.</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_2069882682655569769m_-2691178015881642718h5">On Thu, Aug 31, 2017 at 10:45 AM, Andrew Kelley via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_2069882682655569769m_-2691178015881642718h5"><div dir="ltr"><div>I believe that LLD is not supposed to call exit on success when you call lld::coff::link.</div><div><br></div><div>From downstream fork of LLD: <a href="https://github.com/zig-lang/zig/commit/41da9fdb69065082f57c604b12eb02ca166cb18d" target="_blank">https://github.com/zig-la<wbr>ng/zig/commit/41da9fdb69065082<wbr>f57c604b12eb02ca166cb18d</a></div><div><br></div><div><br></div><div>diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp</div><div>index 854c3e69098..8b17f039870 100644</div><div>--- a/lld/COFF/Driver.cpp</div><div>+++ b/lld/COFF/Driver.cpp</div><div>@@ -1030,7 +1030,7 @@ void LinkerDriver::link(ArrayRef<co<wbr>nst char *> ArgsArr) {</div><div> if (!Args.hasArgNoClaim(OPT_INPUT<wbr>)) {</div><div> fixupExports();</div><div> createImportLibrary(/*AsLib=*<wbr>/true);</div><div>- exit(0);</div><div>+ return;</div><div> }</div><div> </div><div> // Handle /delayload</div><div>@@ -1122,7 +1122,7 @@ 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>+ return;</div><div> }</div><div> </div><div> // Do LTO by compiling bitcode input files to a set of native COFF files then</div><div>@@ -1173,8 +1173,7 @@ void LinkerDriver::link(ArrayRef<co<wbr>nst char *> ArgsArr) {</div><div> // Write the result.</div><div> writeResult(&Symtab);</div><div> </div><div>- // Call exit to avoid calling destructors.</div><div>- exit(0);</div><div>+ return;</div><div> }</div><div> </div><div> } // namespace coff</div><div><br></div></div>
<br></div></div>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>
</div></blockquote></div><br></div></div></div>