[cfe-dev] Fwd: Weird linking problem on Windows

Reid Kleckner rnk at google.com
Wed Feb 18 09:40:59 PST 2015


The GCC-style clang++ driver defaults to enabling C++ exceptions, but those
aren't really supported on Windows. Disable them with -fno-exceptions, and
the __cxa_call_unexpected error should go away. clang-cl doesn't have this
problem because it disables exceptions by default. This is a change in
behavior since 3.5, but it's a regression in a not-yet supported
configuration, so I don't consider it a release blocker.

The operator delete missing symbol has to do with some sized operator
delete C++14 dust that hasn't settled yet. We used to emit an implicit weak
definition of sized operator delete, but that caused ELF linkers to pull in
more static archive members causing link failures, so we recently stopped
doing it. We should probably revert the default back to emitting a weak
definition.

On Tue, Feb 17, 2015 at 10:20 AM, İsmail Dönmez <ismail at donmez.ws> wrote:

> Sent to wrong list :/
>
>
> ---------- Forwarded message ----------
> From: İsmail Dönmez <ismail at donmez.ws>
> Date: Tue, Feb 17, 2015 at 5:59 PM
> Subject: Weird linking problem on Windows
> To: "cfe-commits at cs.uiuc.edu" <cfe-commits at cs.uiuc.edu>
>
>
> This is a possible regression:
>
> [~]> clang++ -std=c++14 -D_HAS_EXCEPTIONS=0 auto_ptr.cpp
> auto_ptr-556ebb.o : error LNK2019: unresolved external symbol "void
> __cdecl operator delete(void *,unsigned __int64)" (??3 at YAXPEAX_K@Z)
> referenced in function main
> auto_ptr-556ebb.o : error LNK2019: unresolved external symbol
> __cxa_call_unexpected referenced in function "public: __cdecl
> std::basic_ostream<char,struct std::char_traits<char>
> >::sentry::~sentry(void)"
> (??1sentry@?$basic_ostream at DU?$char_traits at D@std@@@std@@QEAA at XZ)
> a.exe : fatal error LNK1120: 2 unresolved externals
> clang++.exe: error: linker command failed with exit code 1120 (use -v
> to see invocation)
>
> [~]> clang++ -v
> clang version 3.7.0 (http://llvm.org/git/clang.git
> d9d3dee4581c591ac65c759df275139ddd4cfa0c)
> (http://llvm.org/git/llvm.git
> 2a43652f3b8a97e67251d80a749d5227667ff5b1)
> Target: x86_64-pc-windows-msvc
> Thread model: posix
>
> [~]> cat auto_ptr.cpp
> #include <memory>
> #include <iostream>
>
> class Foo {
> public:
>     Foo(){};
>     ~Foo() { std::cout << "Destructor called." << std::endl; };
>
>     void echo() { std::cout << "Echo!" << std::endl; };
> };
>
> int main()
> {
>     std::auto_ptr<Foo> foo(new Foo);
>     foo->echo();
>
>     std::auto_ptr<Foo> bar(foo);
>
>     bar->echo();
>     return 0;
> }
>
> If I drop -std=c++14 then the delete symbol works:
>
> [~]> clang++ -D_HAS_EXCEPTIONS=0 auto_ptr.cpp
> auto_ptr-64308e.o : error LNK2019: unresolved external symbol
> __cxa_call_unexpected referenced in function "public: __cdecl
> std::basic_ostream<char,struct std::char_traits<char>
> >::sentry::~sentry(void)"
> (??1sentry@?$basic_ostream at DU?$char_traits at D@std@@@std@@QEAA at XZ)
> a.exe : fatal error LNK1120: 1 unresolved externals
> clang++.exe: error: linker command failed with exit code 1120 (use -v
> to see invocation)
>
> Also, clang-cl works fine.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150218/e1f3f7e7/attachment.html>


More information about the cfe-dev mailing list