This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Look for libfoo.a if foo.lib is specified, for MinGW
ClosedPublic

Authored by mstorsjo on Oct 9 2018, 1:26 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Oct 9 2018, 1:26 AM

As long as this is mostly intended for system libraries, we can skip the .dll.a part, and don't need to think about any static flag.

mstorsjo updated this revision to Diff 168872.Oct 9 2018, 2:16 PM
mstorsjo retitled this revision from [LLD] [COFF] Look for libfoo.a and libfoo.dll.a, if foo.lib is specified as defaultlibrary, for MinGW to [LLD] [COFF] Look for libfoo.a if foo.lib is specified, for MinGW.
mstorsjo edited the summary of this revision. (Show Details)

Simplified it to only care about the case of system libraries for now. As this feature isn't available in ld.bfd and therefore not in use in the general mingw ecosystem, it might be ok to limit it to this case for now, for use with sanitizers?

rnk added inline comments.Oct 9 2018, 2:21 PM
COFF/Driver.cpp
377 ↗(On Diff #168757)

I guess this could be has_extension, probably with Style::windows, as well.

383–385 ↗(On Diff #168757)

How about llvm::sys::path::replace_extension?

386 ↗(On Diff #168757)

Eh, saving a library name for every -defaultlib: we find in an object file is kind of a waste of memory. They're everywhere. But, this is a pre-existing problem that needs fixing, so I won't push to fix it now.

mstorsjo added inline comments.Oct 9 2018, 2:24 PM
COFF/Driver.cpp
383–385 ↗(On Diff #168757)

I actually just changed it to use that, in the version I updated a few minutes earlier.

rnk accepted this revision.Oct 9 2018, 2:30 PM

lgtm

This revision is now accepted and ready to land.Oct 9 2018, 2:30 PM
ruiu added inline comments.Oct 9 2018, 2:30 PM
COFF/Driver.cpp
380 ↗(On Diff #168872)

Please add a comment to explain this mingw-specific behavior. It might be a good thing to separate this code as a new function.

This revision was automatically updated to reflect the committed changes.
mstorsjo added inline comments.Oct 10 2018, 2:20 AM
COFF/Driver.cpp
380 ↗(On Diff #168872)

Ok, I added more comments and split this to a separate function, before pushing.