This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Rework LTO argument handling in the linker wrapper
Needs ReviewPublic

Authored by jhuber6 on Jul 12 2022, 11:59 AM.

Details

Summary

The clang-linker-wrapper is responsible for performing embedded
linking jobs for the offloading device. In the linker wrapper we need to
implement our own handling of LTO to account for the diverse landscape
of linkers and assemblers for accelerators. However, we end up
duplication a lot of functionality. This patch changes the argument
generation for the device to match the arguments we use for host LTO.
This will make it much easier to add extra arguments.

One thing to be careful of however, is that not all linkers will not
accept -plugin-opt arguments if there is not a corresonding -plugin.
In order to combat this we need to make sure that all -plugin-opt
arguments indented for the device's LTO are not propagated to the host
linking job if we are using a linker that does not support it.

Diff Detail

Event Timeline

jhuber6 created this revision.Jul 12 2022, 11:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2022, 11:59 AM
jhuber6 requested review of this revision.Jul 12 2022, 11:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2022, 11:59 AM

On second thought I'm not sure if overloading -plugin-opt is a good idea because we could have situations where we'd want them to be mutually exclusive, although I'd like to reuse the logic to set the arguments. I could change it to emit -offload-opt= instead or something similar to indicate it's for embedded offloading code, but that would cause some churn replacing every single --plugin-opt string in addLTOOptions. Would appreciate some feedback on this.