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

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 19 23:30:04 PDT 2021


mstorsjo added a comment.

In D44543#2956262 <https://reviews.llvm.org/D44543#2956262>, @MaskRay wrote:

> `} else if (MAI->avoidWeakIfComdat() && GV->hasComdat()) {` in AsmPrinter.cpp makes the comdat leader symbol unconditionally `.globl`.
> Will it be possible to allow `.weak` leader?

I'm not sure...

> If allowed, `clang -fprofile-instr-generate a.c` can place the weak `__profc_weak` in an associative comdat (`comdat nodeduplicate`) for the following code:
>
>   __attribute__((weak)) void foo() {}
>
> and not getting "duplicate definition error" with `lld-link -lldmingw`.

Can you elaborate on the issue? Right now I can successfully build and link code that uses `__attribute__((weak))` with `-fprofile-instr-generate` in mingw mode with clang+lld. Or is the situation relating to the upcoming state after some other patches? (I'm entirely unfamiliar with the internals of the PGO implementation.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44543



More information about the llvm-commits mailing list