This is an archive of the discontinued LLVM Phabricator instance.

[lld] Accept -flavor FLAVOR anywhere on the command line
AbandonedPublic

Authored by gkm on May 18 2020, 10:19 PM.

Details

Summary

While developing the new MachO port of lld, we wish to select it via clang -Wl,-flavor,darwinnew .... The compiler driver does not place -Wl,... args at the front of the lld command line, so lld must accept it at locations beyond argv[1]

Diff Detail

Unit TestsFailed

Event Timeline

gkm created this revision.May 18 2020, 10:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2020, 10:19 PM
gkm added a comment.May 18 2020, 10:24 PM
This comment was removed by gkm.
grimar added a subscriber: grimar.May 19 2020, 2:10 AM
gkm updated this revision to Diff 264941.May 19 2020, 9:07 AM
gkm removed a subscriber: grimar.

Add lld Driver tests

gkm added a subscriber: grimar.May 19 2020, 9:09 AM

I think the problem here is that we should give thew new Darwin port a symlink like ld.lld, wasm-ld and lld-link.
Then we can teach clang to support -fuse-ld=foobar by locating the executable foobar (not ld.foobar as hard-coded by -fuse-ld=bfd -fuse-ld=gold -fuse-ld=lld) for non-ELF platforms. This requires a clang driver change.

I actually have a GCC patch sitting there for a while. https://gcc.gnu.org/pipermail/gcc-patches/2020-April/543324.html
I need to finish it.

gkm added a comment.May 19 2020, 10:59 AM

True--this is no substitute for clang integration.
But meanwhile, is there harm in proceeding with this fix?

gkm updated this revision to Diff 264973.May 19 2020, 11:04 AM

loosen expected output pattern for tests

In D80184#2044576, @gkm wrote:

True--this is no substitute for clang integration.
But meanwhile, is there harm in proceeding with this fix?

There is some little harm. In GNU ld, -flavor means --auxillary lavor.

I think using -Wl,-flavor,* to change the linker is weird. Let's see if -fuse-ld= can be fixed (D80225).

gkm added a comment.May 19 2020, 12:01 PM

Fair enough.
How shall we name the new MachO lld?

gkm abandoned this revision.May 28 2020, 3:46 PM

We will fix the clang driver to invoke the proper alias for lld so that -flavor is unnecessary.