Andrew Kelley via llvm-dev
2017-Oct-16 01:45 UTC
[llvm-dev] LLD COFF not closing mmaps to input files?
I've got a patched LLD 5.0.0 like this: diff --git a/deps/lld/COFF/Driver.cpp b/deps/lld/COFF/Driver.cpp index 854c3e69..8bab1c11 100644 --- a/deps/lld/COFF/Driver.cpp +++ b/deps/lld/COFF/Driver.cpp @@ -1030,7 +1030,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { if (!Args.hasArgNoClaim(OPT_INPUT)) { fixupExports(); createImportLibrary(/*AsLib=*/true); - exit(0); + return; } // Handle /delayload @@ -1172,9 +1172,6 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { // Write the result. writeResult(&Symtab); - - // Call exit to avoid calling destructors. - exit(0); } } // namespace coff I'm getting this error from LLVM: unable to write object file c:\msys64\home\andy\zig\zig-cache\compiler_rt.obj: The requested operation cannot be performed on a file with a user-mapped section open. The same process calls LLD with this .obj as a linker input file, then tries to write to the same .obj file later. I believe LLD is mmapping the .obj file and then not cleaning it up. Can I have some guidance as to where in the code I could discover this and clean it up? Regards, Andrew http://ziglang.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171015/7176b54e/attachment.html>
Andrew Kelley via llvm-dev
2017-Oct-16 01:57 UTC
[llvm-dev] LLD COFF not closing mmaps to input files?
I believe this line is the culprit: COFF/Driver.cpp:102: make<std::unique_ptr<MemoryBuffer>>(std::move(MB)); // take ownership Patch forthcoming. On Sun, Oct 15, 2017 at 9:45 PM, Andrew Kelley <superjoe30 at gmail.com> wrote:> I've got a patched LLD 5.0.0 like this: > > diff --git a/deps/lld/COFF/Driver.cpp b/deps/lld/COFF/Driver.cpp > index 854c3e69..8bab1c11 100644 > --- a/deps/lld/COFF/Driver.cpp > +++ b/deps/lld/COFF/Driver.cpp > @@ -1030,7 +1030,7 @@ void LinkerDriver::link(ArrayRef<const char *> > ArgsArr) { > if (!Args.hasArgNoClaim(OPT_INPUT)) { > fixupExports(); > createImportLibrary(/*AsLib=*/true); > - exit(0); > + return; > } > > // Handle /delayload > @@ -1172,9 +1172,6 @@ void LinkerDriver::link(ArrayRef<const char *> > ArgsArr) { > > // Write the result. > writeResult(&Symtab); > - > - // Call exit to avoid calling destructors. > - exit(0); > } > > } // namespace coff > > > I'm getting this error from LLVM: > unable to write object file c:\msys64\home\andy\zig\zig-cache\compiler_rt.obj: > The requested operation cannot be performed on a file with a user-mapped > section open. > > The same process calls LLD with this .obj as a linker input file, then > tries to write to the same .obj file later. > > I believe LLD is mmapping the .obj file and then not cleaning it up. > > Can I have some guidance as to where in the code I could discover this and > clean it up? > > Regards, > Andrew > http://ziglang.org/ >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171015/7847f6ba/attachment.html>
Rui Ueyama via llvm-dev
2017-Oct-16 01:59 UTC
[llvm-dev] LLD COFF not closing mmaps to input files?
I think you want to call freeArena() before returning from lld::coff::link. On Sun, Oct 15, 2017 at 6:57 PM, Andrew Kelley via llvm-dev < llvm-dev at lists.llvm.org> wrote:> I believe this line is the culprit: > > COFF/Driver.cpp:102: > make<std::unique_ptr<MemoryBuffer>>(std::move(MB)); // take ownership > > Patch forthcoming. > > > On Sun, Oct 15, 2017 at 9:45 PM, Andrew Kelley <superjoe30 at gmail.com> > wrote: > >> I've got a patched LLD 5.0.0 like this: >> >> diff --git a/deps/lld/COFF/Driver.cpp b/deps/lld/COFF/Driver.cpp >> index 854c3e69..8bab1c11 100644 >> --- a/deps/lld/COFF/Driver.cpp >> +++ b/deps/lld/COFF/Driver.cpp >> @@ -1030,7 +1030,7 @@ void LinkerDriver::link(ArrayRef<const char *> >> ArgsArr) { >> if (!Args.hasArgNoClaim(OPT_INPUT)) { >> fixupExports(); >> createImportLibrary(/*AsLib=*/true); >> - exit(0); >> + return; >> } >> >> // Handle /delayload >> @@ -1172,9 +1172,6 @@ void LinkerDriver::link(ArrayRef<const char *> >> ArgsArr) { >> >> // Write the result. >> writeResult(&Symtab); >> - >> - // Call exit to avoid calling destructors. >> - exit(0); >> } >> >> } // namespace coff >> >> >> I'm getting this error from LLVM: >> unable to write object file c:\msys64\home\andy\zig\zig-cache\compiler_rt.obj: >> The requested operation cannot be performed on a file with a user-mapped >> section open. >> >> The same process calls LLD with this .obj as a linker input file, then >> tries to write to the same .obj file later. >> >> I believe LLD is mmapping the .obj file and then not cleaning it up. >> >> Can I have some guidance as to where in the code I could discover this >> and clean it up? >> >> Regards, >> Andrew >> http://ziglang.org/ >> > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171015/a3995687/attachment.html>
Apparently Analagous Threads
- LLD COFF not closing mmaps to input files?
- LLD: patch to fix libCOFF calling exit() on success in a library function
- LLD: patch to fix libCOFF calling exit() on success in a library function
- LLD COFF library: crashes when lld::coff::link is called twice
- LLD COFF library: crashes when lld::coff::link is called twice