<div dir="ltr">yeah, don't think there's anything builtin to handle that - likely you'll have to roll your own</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 8, 2020 at 7:37 AM John Reagan <<a href="mailto:john.reagan@vmssoftware.com">john.reagan@vmssoftware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Yes, a external declaration with no uses. No calls to it. No address<br>
taken. Just the external declaration and I want it to say around and<br>
make it into the ELF symbol table as an undefined external reference.<br>
<br>
Our BLISS language behaves that way and we have code that relies on that<br>
behavior as a way to get the linker to include a particular routine into<br>
the final image. On our other platforms, our old backend had to invent<br>
a special attribute to indicate "you must put this in the ELF symbol<br>
table regardless".<br>
<br>
I can easily create a compiler-generated static and initialize it with<br>
the address. That will do what I want at the slight expense of a static<br>
location (memory is cheap) and a relocation for the linker to process<br>
(it is already doing a ton anyway, what's one more). It isn't that<br>
common so I'm not too worried. I was just wondering if I was missing it.<br>
<br>
Thanks<br>
<br>
On 5/7/2020 9:58 PM, David Blaikie wrote:<br>
> <br>
> <br>
> On Thu, May 7, 2020 at 6:47 PM John Reagan via llvm-dev<br>
> <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a> <mailto:<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>> wrote:<br>
> <br>
> I had thought about "used", but not aware of the @llvm.used, et al.<br>
> <br>
> I wrote some test programs with __attribute__((used)) but that felt like<br>
> something you'd put on function definitions to force code to be<br>
> generated regardless.<br>
> <br>
> <br>
> Isn't that what you're asking for?<br>
> <br>
> Though I'm slightly confused by your original statement - /LLVM/ (the<br>
> middle/backend, compiler - generating object files) wouldn't discard an<br>
> external-linkage function with no calls, because the call might be in<br>
> another module. Oh, a declaration? <br>
> <br>
> You have a declaration (without a definition) of a function in an<br>
> llvm::Module and you want some remnant of that to appear in the object<br>
> file? Yeah, I don't think that's supported - how's that done on other<br>
> compilers/what's the prior art you're trying to emulate here?<br>
> <br>
> <br>
> <br>
> In the worst case, I'll do some metadata hack (I've ready had to do that<br>
> for BLISS' GLOBAL BIND feature).<br>
> <br>
> Thanks for the response. I'll let folks know what I find out.<br>
> <br>
> P.S. we're about to enter field test for OpenVMS after 2+ years of work<br>
> on the system and compilers. I can now boot it under VBox on my W10<br>
> system here at home.<br>
> <br>
> On 5/7/2020 4:16 PM, Robinson, Paul wrote:<br>
> ><br>
> ><br>
> >> -----Original Message-----<br>
> >> From: llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a><br>
> <mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>>> On Behalf Of John Reagan<br>
> >> via llvm-dev<br>
> >> Sent: Wednesday, May 6, 2020 9:29 PM<br>
> >> To: via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> <mailto:<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>><br>
> >> Subject: [llvm-dev] How to force unused external routine<br>
> declaration into<br>
> >> object<br>
> >><br>
> >> I'm defining an external function in the IR that has no uses at<br>
> all. No<br>
> >> calls, no address taken, nada.<br>
> >><br>
> >> Such an unused declaration seems to be just dropped on the floor<br>
> as not<br>
> >> needed. Seems reasonable in most cases.<br>
> >><br>
> >> However, one of my OpenVMS compilers (BLISS) has a language rule that<br>
> >> expects such definitions to get into the ELF symbol table as a way to<br>
> >> compel the linker to include certain object modules.<br>
> >><br>
> >> With our backend for our older targets, we had a "required_om_entry"<br>
> >> function attribute that told our backend to put it out regardless.<br>
> >><br>
> >> I was looking at the list of function attributes and don't see<br>
> anything<br>
> >> that would accomplish this.<br>
> >><br>
> >> I could just create a bogus variable and initialize it with the<br>
> >> function's value, but that seems unsavory.<br>
> >><br>
> >> I'm still using a way old version but I'll adapt as needed.<br>
> >><br>
> >> Any suggestions? Did I miss something?<br>
> ><br>
> > Hi John,<br>
> ><br>
> > This sounds like __attribute__((used)) which Clang turns into<br>
> > entries in the @llvm.used list. There's also @llvm.compiler.used<br>
> > and I'm not clear what the difference is, but hopefully that's<br>
> > enough of a pointer that you can get it to work for Bliss.<br>
> ><br>
> > --paulr<br>
> ><br>
> >><br>
> >> John (safely at home with sufficient food & wine)<br>
> >> _______________________________________________<br>
> >> LLVM Developers mailing list<br>
> >> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a> <mailto:<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
> >> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a> <mailto:<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
> <br>
</blockquote></div>