This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [MinGW] Ignore the --[no-]allow-shlib-undefined option
Needs RevisionPublic

Authored by mstorsjo on Jul 13 2020, 2:28 PM.

Details

Summary

GNU ld does accept this option when targeting PE-COFF, even though PE images clearly don't support leaving undefined symbols in a linked image.

Meson has earlier had issues where it tried to unconditionally pass this option when targeting a unix style linker (including the mingw target, which uses unix style options); currently meson tries to detect whether the option is supported and pass it.

For compatibility with GNU ld, just ignore this option, as there may be other projects out there that also blindly pass this option to the linker, even though it makes no sense for a windows target.

Diff Detail

Event Timeline

mstorsjo created this revision.Jul 13 2020, 2:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2020, 2:28 PM
Herald added a subscriber: dang. · View Herald Transcript

I don't have enough background here, so I'll defer to the decision of other reviewers whether this makes sense. @ruiu ?

mstorsjo added a subscriber: rnk.Jul 14 2020, 1:42 PM

I don't have enough background here, so I'll defer to the decision of other reviewers whether this makes sense. @ruiu ?

Not sure how active @ruiu is these days either (and @rnk is on leave as well)...

GNU ld silently accepts these options when targeting windows (and they have no effect), so therefore we probably should (even though the options themselves are nonsensical for PE-COFF), just to reduce unnecessary differences that one can run into.

MaskRay requested changes to this revision.Jul 14 2020, 1:51 PM
MaskRay added a subscriber: MaskRay.

For compatibility with GNU ld, just ignore this option, as there may be other projects out there that also blindly pass this option to the linker, even though it makes no sense for a windows target.

This is because GNU ld handles most options in one getopt_long/getopt_long_only. Many ELF specific options are handled by non-ELF ports and ignored. Some newer options use -z which is only handled by its ELF ports.

--allow-shlib-undefined is so rare that we should ask the projects to fix their build systems.

This revision now requires changes to proceed.Jul 14 2020, 1:51 PM

This is because GNU ld handles most options in one getopt_long/getopt_long_only. Many ELF specific options are handled by non-ELF ports and ignored. Some newer options use -z which is only handled by its ELF ports.

--allow-shlib-undefined is so rare that we should ask the projects to fix their build systems.

Ok, fair enough. So far, Meson is the only one I've encountered setting this one, and it was fixed once, then regressed, then refixed at a later point. But I guess I should set up continuous testing of the latest version of that to make sure it doesn't regress again.