[libcxx-dev] build issue on mingw gcc, need some help

Martin Storsjö via libcxx-dev libcxx-dev at lists.llvm.org
Tue Jan 8 14:21:28 PST 2019


On Tue, 8 Jan 2019, Martin Storsjö via libcxx-dev wrote:

>>> In the end, I top it off by linking the DLL with -Wl,--export-all-symbols. 
>>> Without that, for me, a number of symbols aren't exported even if they are 
>>> expected to. I believe that's a Clang-specific issue though, but I haven't 
>>> analyzed it further yet, as this hack/workaround seems to work well enough 
>>> for now.
>>>
>
> I've looked a bit closer on that matter now, and it's related to how 
> libcxx does explicit template instantiation with visibility attributes 
> (dllexport). Neither g++ nor clang in mingw mode will create dllexports 
> for symbols from an explicit template instantiation with a dllexport 
> attribute, while msvc and clang in msvc mode does. I can open a bug report 
> with full details later.

This issue is now at https://bugs.llvm.org/show_bug.cgi?id=40256, framed 
as a Clang issue. If Clang is fixed to behave like GCC with respect to 
this (which probably makes the most sense, instead of making it behave 
like MSVC even thogh operating in MinGW mode), or already now with GCC, it 
should be possible to get the necessary export directives with the 
following untested patch for libcxx:


diff --git a/include/__config b/include/__config
index b8c2c33..fc1a472 100644
--- a/include/__config
+++ b/include/__config
@@ -706,7 +706,11 @@ namespace std {
  #define _LIBCPP_EXCEPTION_ABI       _LIBCPP_DLL_VIS
  #define _LIBCPP_HIDDEN
  #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+#if defined(__MINGW32__) && defined(_LIBCPP_BUILDING_LIBRARY)
+#define _LIBCPP_TEMPLATE_VIS        _LIBCPP_DLL_VIS
+#else
  #define _LIBCPP_TEMPLATE_VIS
+#endif
  #define _LIBCPP_ENUM_VIS

  #endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)


// Martin


More information about the libcxx-dev mailing list