[llvm-dev] LLD doesn't handle globals with appending linkage

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 18 09:42:18 PST 2020


I'm /guessing/ this might be related to the COFF support specifically
(perhaps COFF has no appending linkage support - in some cases LLVM IR
supports the union of all semantics so that different formats can be fully
expressed - but it means when targeting certain formats, some features are
inherently unusable because they don't map to anything on that platform)

If I were you I'd go see if there are any examples of appending linkage
being used when targeting the COFF platform (eg: go look at places where
Clang generates IR with appending linkage, see if any of them apply to
COFF, if they do see how they work through LTO - if there are no such
examples, look for non-COFF Examples of appending linkage and see what the
IR targeting COFF looks like in those examples, perhaps a different linkage
mechanism is used that you can use too)

(added Reid for familiarity with the COFF format & Ray for familiarity with
LLD)

On Tue, Feb 18, 2020 at 12:29 AM Gleb Popov via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hello.
>
> I'm posting this question here, because there seem to be no LLD-specific
> mailing list. Sorry in advance if this is wrong one.
>
> I compile two C source with following command:
>
> clang -flto -o %name.bc %name.c
>
> LLVM is augmented with my custom pass, which amongst other things create a
> global with appending linkage:
>
> @myvar = appending constant [1 x [1 x i8]*] ...
>
> I also have another pass plugged into LTO pipeline, which turns this
> global into internal one in the final module. I was hoping that LLD would
> first link bitcodes like llvm-link, appending @myvar's from both modules
> into a single one, then run my pass, and only then perform linking at
> object level.
>
> However, LLD complains about duplicated symbol "myvar" and doesn't even
> run any passes.
>
> I've tracked the problem down to BitcodeFile::parse() function from
> https://github.com/llvm/llvm-project/blob/master/lld/COFF/InputFiles.cpp#L918
> - it doesn't take linkage type into account.
>
> Can anything be done about this problem? Or was my approach broken from
> the beginning?
>
> Thanks in advance.
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200218/2ae74ed5/attachment.html>


More information about the llvm-dev mailing list