[cfe-dev] [libc++] Compiling with MinGW-w64

Mateusz Mikuła via cfe-dev cfe-dev at lists.llvm.org
Mon Apr 3 07:00:58 PDT 2017


 Missing mingw-w64 libs case is most likely closed but there is conflict
between libc++ and libc++abi function definitions. I've switched to
trunk as well.

The former have '_LIBCPP_FUNC_VIS' to mark them as dllexport/dllimport
but libc++abi redefines them without attributes.

Clang log: https://reviews.llvm.org/P7983

GCC log: https://reviews.llvm.org/P7982


Let's take a look at GCC-produced (Clang is still not entirely fine as
seen in log; multiple definition of ...) objects containing bad_cast
function as it is first undefined reference:

error:
CMakeFiles/cxxabi_shared.dir/objects.a(cxa_aux_runtime.cpp.obj):cxa_aux_runtime.cpp:(.text+0x17):
undefined reference to `__imp__ZNSt8bad_castC1Ev'
CMakeFiles/cxxabi_shared.dir/objects.a(cxa_aux_runtime.cpp.obj):cxa_aux_runtime.cpp:(.text+0x1e):
undefined reference to `__imp__ZNSt8bad_castD1Ev'

nm
build-x86_64-w64-mingw32/projects/libcxxabi/src/CMakeFiles/cxxabi_objects.dir/cxa_aux_runtime.cpp.obj
| grep bad_cast
0000000000000000 r .rdata$_ZTISt8bad_cast
0000000000000000 r .rdata$_ZTSSt8bad_cast
0000000000000000 T __cxa_bad_cast
                 U __imp__ZNSt8bad_castC1Ev
                 U __imp__ZNSt8bad_castD1Ev
0000000000000000 R _ZTISt8bad_cast
0000000000000000 R _ZTSSt8bad_cast

nm
build-x86_64-w64-mingw32/projects/libcxxabi/src/CMakeFiles/cxxabi_objects.dir/stdlib_typeinfo.cpp.obj
| grep bad_cast
0000000000000000 r .rdata$_ZTISt8bad_cast
0000000000000000 r .rdata$_ZTSSt8bad_cast
0000000000000000 r .rdata$_ZTVSt8bad_cast
                 U __imp__ZTVSt8bad_cast
0000000000000000 T _ZNKSt8bad_cast4whatEv
00000000000000e0 T _ZNSt8bad_castC1Ev
00000000000000e0 T _ZNSt8bad_castC2Ev
0000000000000040 T _ZNSt8bad_castD0Ev
0000000000000020 T _ZNSt8bad_castD1Ev
0000000000000020 T _ZNSt8bad_castD2Ev
0000000000000000 R _ZTISt8bad_cast
0000000000000000 R _ZTSSt8bad_cast
0000000000000000 R _ZTVSt8bad_cast

I was not able to fix it by myself so I'm asking for help again.
Should I add someone to this discussion?


Regards,

Mateusz


------ Original Message ------
Subject: Re: [cfe-dev] [libc++] Compiling with MinGW-w64
Date: Wed, 22 Mar 2017 19:04:42 -0600
To: Mateusz Mikuła, Cfe-dev
From: Eric Fiselier
>
>
> On Fri, Mar 17, 2017 at 4:34 PM, Mateusz Mikuła via cfe-dev
> <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
>
>     Hello,
>
>     I'm planing to get libc++ compiling with MinGW-w64, right now
>     without patches it fails with:
>
>         CMake Error at projects/libcxx/CMakeLists.txt:396 (message):
>           C++11 or greater is required but the compiler does not
>         support c++11
>
>     It is caused by adding `-nodefaultlibs` flag (it passes it's own
>     check [1]
>     <https://github.com/llvm-mirror/libcxx/blob/master/cmake/config-ix.cmake#L27>).
>     However many following checks fail due to undefined references,
>     results with gcc [2] <https://reviews.llvm.org/P7975> and clang
>     [3] <https://reviews.llvm.org/P7976>.
>
> CMake seems to be adding system libraries automagically. Specifically
> it adds -lgcc_s -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32
> -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32.
> I'm guessing that these libraries are where the undefined symbols are
> coming from, and I suspect the correct fix is to somehow prevent CMake
> from adding them.
>
>
>
>     Hard-coding 0 for LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG allows it go
>     finish configuration and fail during build (that's another story).
>
>     `-nodefaultlibs` appears several times in libc++ and libc++abi
>     code and I'm not sure about cleanest way to fix/workaround it.
>
>     Any suggestions?
>
>
>     [1]
>     https://github.com/llvm-mirror/libcxx/blob/master/cmake/config-ix.cmake#L27
>     <https://github.com/llvm-mirror/libcxx/blob/master/cmake/config-ix.cmake#L27>
>
>     [2] https://reviews.llvm.org/P7975
>
>     [3] https://reviews.llvm.org/P7976
>
>
>     Thanks,
>
>     Mateusz
>
>
>     _______________________________________________
>     cfe-dev mailing list
>     cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
>     http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>     <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170403/4cd81dd8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170403/4cd81dd8/attachment.sig>


More information about the cfe-dev mailing list