[PATCH] D138221: [HIP] Fix lld failure when devie object is empty

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 21 14:13:39 PST 2022


yaxunl marked an inline comment as done.
yaxunl added a comment.

In D138221#3942095 <https://reviews.llvm.org/D138221#3942095>, @MaskRay wrote:

> In D138221#3941173 <https://reviews.llvm.org/D138221#3941173>, @yaxunl wrote:
>
>> In D138221#3939384 <https://reviews.llvm.org/D138221#3939384>, @MaskRay wrote:
>>
>>>> Some host relocatable objects may not contain device relocatable objects, where an empty file is passed to lld, which causes lld to fail.
>>>
>>> How is an empty file (size=0) passed to lld? If a dummy relocatable object file is parsed to lld, lld can infer the machine type from `e_machine` in the ELF header.
>>> How does it work in other cases? Because a non-empty relocatable object file is used?
>>>
>>> I do not object to a new emulation which does not exist in GNU ld, but the description needs to be clarified.
>>
>> Updated description. The empty file is generated by clang-offload-bundler, which does not know how to create a dummy relocatable object file for a device target.
>
> A size=0 file is handled as a linker script, not a relocatable object file. The empty linker script has no-op.

I see. We got into a situation where all input files were empty and lld emitted the error:

lld: error: target emulation unknown: -m or at least one .o file required

adding -m fixes that.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138221/new/

https://reviews.llvm.org/D138221



More information about the cfe-commits mailing list