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

Shoaib Meenai via libcxx-dev libcxx-dev at lists.llvm.org
Tue Jan 8 16:08:54 PST 2019


I believe you'd want to modify _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS and _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS instead, since they're applied to explicit instantiation declarations and definitions, respectively. _LIBCPP_TEMPLATE_VIS is applied to class templates in general, not explicit instantiations specifically.

From: libcxx-dev <libcxx-dev-bounces at lists.llvm.org> on behalf of Martin Storsjö via libcxx-dev <libcxx-dev at lists.llvm.org>
Reply-To: Martin Storsjö <martin at martin.st>
Date: Tuesday, January 8, 2019 at 2:21 PM
To: Maarten Verhage <m_r_verhage at hotmail.com>
Cc: "libcxx-dev at lists.llvm.org" <libcxx-dev at lists.llvm.org>
Subject: Re: [libcxx-dev] build issue on mingw gcc, need some help

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://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D40256&d=DwIDaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=Xzf_1sBH1qmEq7dOB681bB7Kr5aEKtioAROquk-WdDE&s=mHBeLiIFp-vzhV1dFYbBMX_JCqbeV7Ta9C13XFNjHW0&e=, 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-dev/attachments/20190109/8e797c1d/attachment-0001.html>


More information about the libcxx-dev mailing list