[libcxx-commits] [PATCH] D88843: [libcxx] Don't treat Windows specially with visibility annotations

Shoaib Meenai via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 5 11:57:11 PDT 2020


smeenai added a comment.

I think the reason for this restriction is that on Windows, `__declspec(dllimport)` changes the compiler's code generation to assume that the symbol will be imported (i.e. if the compiler sees a call to a function `X` which is marked `__declspec(dllimport)`, it'll generate an indirect call to `__imp_X` instead). If you're linking against libc++ statically, the imported version of the symbol will of course not exist, so you want to disable the `__declspec(dllimport)` annotations by default if you're building just the static library for Windows.

(IIRC, Microsoft's linker actually supports this case; it'll generate a dummy `__imp_X` for you pointing to the local `X` symbol, but it'll also give you a warning about doing so. I think LLD COFF supports that as well. It's just less clean to do it that way.)

Since this is Windows-specific behavior (or technically dllimport-specific behavior), perhaps it makes more sense to do some Windows-specific visibility macro adjustments than overloading the cross-platform `_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS` for this purpose?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88843



More information about the libcxx-commits mailing list