This is an archive of the discontinued LLVM Phabricator instance.

[lld][MinGW] Ignore `--[no-]as-neeed` flags in MinGW driver
ClosedPublic

Authored by zero9178 on Jan 1 2022, 2:26 PM.

Details

Summary

These flags are specific to ELF, but are still accepted by GNU ld, even if it does not do anything. This patch adds them as ignored option for the sake of compatibility.

Part of https://github.com/llvm/llvm-project/issues/52947

Diff Detail

Event Timeline

zero9178 created this revision.Jan 1 2022, 2:26 PM
zero9178 requested review of this revision.Jan 1 2022, 2:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 1 2022, 2:27 PM
mstorsjo accepted this revision.Jan 1 2022, 2:32 PM

LGTM. But I'd like to see an example of a project that sets these flags for mingw builds, as I haven't run into them so far.

This revision is now accepted and ready to land.Jan 1 2022, 2:32 PM

I sadly haven't either and wouldn't consider such a build system sane. I was simply answering to the GitHub issue. Hope the user responds.

MaskRay added a subscriber: MaskRay.EditedJan 2 2022, 10:54 AM

Unless there are motivating examples that some options are incorrectly used in a prevailing way, it doesn't seem right to ignore options from another binary format which cannot be properly modeled.

Ignoring -fPIC seems fine.

Unless there are motivating examples that some options are incorrectly used in a prevailing way, it doesn't seem right to ignore options from another binary format which cannot be properly modeled.

As linking against DLL import libraries kinda works like --as-needed (only ending up with a runtime dependency if symbols actually are referenced), would you consider accepting --as-needed but omitting --no-as-needed?

Unless there are motivating examples that some options are incorrectly used in a prevailing way, it doesn't seem right to ignore options from another binary format which cannot be properly modeled.

As linking against DLL import libraries kinda works like --as-needed (only ending up with a runtime dependency if symbols actually are referenced), would you consider accepting --as-needed but omitting --no-as-needed?

Also, feel free to join in on the discsussion at https://github.com/llvm/llvm-project/issues/52947.

Unless there are motivating examples that some options are incorrectly used in a prevailing way, it doesn't seem right to ignore options from another binary format which cannot be properly modeled.

As linking against DLL import libraries kinda works like --as-needed (only ending up with a runtime dependency if symbols actually are referenced), would you consider accepting --as-needed but omitting --no-as-needed?

Then ignoring --as-needed sounds good. --no-as-needed is like an error which should not be ignored.

I don't feel strongly about --no-as-needed and it seems the user on the PR has no issue with not having support for it as well, so following this discussion I'll remove it from the ignore list.

Thanks. GNU ld lexsup.c generally ignores options not meaningful on other binary formats. Ignoring more options like it does will improve compatibility but may not be necessary when the use case is uncommon or falls more into the pilot error category.

We just hit this issue in Fedora while building wine, which uses the aarch64-windows target: https://kojipkgs.fedoraproject.org//work/tasks/3616/96253616/build.log
The issues is that we export LDFLAGS="--as-needed" to ensure it gets set for ELF.

Herald added a project: Restricted Project. · View Herald TranscriptJan 17 2023, 8:13 AM