[PATCH] D44543: [AsmPrinter] Emit .weak directive for weak linkage on COFF

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 15 22:11:15 PDT 2018


smeenai added a comment.

@rnk, does that make sense to you?

I'm not very familiar with this part of LLVM; I ran into this issue because an internal user needed `__attribute__((weak))` semantics on COFF, and having inline assembly with a manual `.weak` directive for a gigantic mangled C++ name isn't the greatest workaround (though it does work). I'm happy to follow through if there's agreement on how to proceed here though.

I do have a question though. `linkonce` doesn't appear to do anything by itself on COFF right now. E.g. if I have

  define linkonce void @f() {
    ret void
  }

and run `bin/llc -mtriple=x86_64-windows-msvc` on it, the object file produced is the same both with and without the `linkonce`. Is that expected? As in, `linkonce` by itself only has meaningful semantics as far as IR is concerned, not at the object file level?

(For inline functions and such, it looks like the `linkonce` is always paired with a comdat, which is what provides the actual COMDAT semantics at the object file level.)


Repository:
  rL LLVM

https://reviews.llvm.org/D44543





More information about the llvm-commits mailing list