This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Always pass `-mcpu` to the `lld` linker
ClosedPublic

Authored by jhuber6 on Jun 27 2023, 12:20 PM.

Details

Summary

Currently, AMDGPU more or less only supports linking with LTO. If the
user does not either pass -flto or -Wl,-plugin-opt=mcpu= manually
linking will fail because the architecture's aren't compatible. THis
patch simply passes -mcpu by default if it was specified. Should be a
no-op if it's not actually used.

Diff Detail

Event Timeline

jhuber6 created this revision.Jun 27 2023, 12:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2023, 12:20 PM
jhuber6 requested review of this revision.Jun 27 2023, 12:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2023, 12:20 PM

I thought lld did the right thing if you pass it raw IR, without specifying an arch, but on reflection it might just be silently miscompiling things. The test doesn't seem to involve a specific type of input file, does clang foo.ll -o a.out pass a mcpu flag along?

It's a bit weird that the architecture doesn't seem to be embedded in the IR file (e.g. you have to pass it to llc) but that's out of scope here

I thought lld did the right thing if you pass it raw IR, without specifying an arch, but on reflection it might just be silently miscompiling things. The test doesn't seem to involve a specific type of input file, does clang foo.ll -o a.out pass a mcpu flag along?

It's a bit weird that the architecture doesn't seem to be embedded in the IR file (e.g. you have to pass it to llc) but that's out of scope here

it markedly does not work without it. I don't think there's currently facilities to define a module-wide architecture, there's only function-level metadata.

yaxunl accepted this revision.Jun 28 2023, 6:41 AM

LGTM. Thanks

This revision is now accepted and ready to land.Jun 28 2023, 6:41 AM
This revision was landed with ongoing or failed builds.Jun 28 2023, 6:52 AM
This revision was automatically updated to reflect the committed changes.