[LLVMdev] Compiling via bitcode on Windows

Reid Kleckner rnk at google.com
Mon Feb 2 09:59:37 PST 2015


The references to _Unwind_Resume and __gxx_personality_v0 are surprising,
but the rest make sense to me. If you don't need any EH, just pass
-fno-exceptions to fix the issue. For more info, read on. :)

---

Clang has a few underlying -cc1 exception options:

-fexceptions: Indicates the presence of *any* kind of EH. Typically implied
by any of the below options. Causes emission of *all* cleanups (C++ dtor,
__attribute__((cleanup)), Obj-C @finally, etc)

-fcxx-exceptions: Enables C++ try / catch. Makes us use
__gxx_personality_v0 etc.

-fobjc-exceptions: Enables Obj-C @try / @catch / @finally. Makes us use an
Obj-C EH personality.

-fsjlj-exceptions: More of a backend option. This changes our EH lowering
strategy.

clang-cl currently turns on -fexceptions and not -fcxx-exceptions, while
clang will enable both by default. Long term, to implement the semantics of
MSVC's /EHs, we want to disable C++ dtor cleanups while leaving SEH (__try
/ __except) enabled.

On Mon, Feb 2, 2015 at 8:30 AM, Russell Wallace <russell.wallace at gmail.com>
wrote:

> I'm trying to use Clang on Windows to compile C++ to bitcode and then to
> an executable (with a view to carrying out some experiments on whole
> program optimization of the bitcode).
>
> When I use clang.exe, even with -D_HAS_EXCEPTIONS=0 -fms-compatibility
> -fms-extensions, I get errors:
>
> main-621e97.o : error LNK2019: unresolved external symbol _Unwind_Resume
> referenced in function main
> main-621e97.o : error LNK2001: unresolved external symbol
> __gxx_personality_v0
> main-621e97.o : error LNK2019: unresolved external symbol
> __cxa_call_unexpected referenced in function "public: class
> std::_Vector_iterator<class std::_Vector_val<struct
> std::_Simple_types<class std::basic_string<char,struct
> std::char_traits<char>,class std::allocator<char> > > > > __cdecl
> std::vector<class std::basic_string<char,struct
> std::char_traits<char>,class std::allocator<char> >,class
> std::allocator<class std::basic_string<char,struct
> std::char_traits<char>,class std::allocator<char> > > >::begin(void)"
> (?begin@?$vector at V?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@
> @std@@V?$allocator at V?$basic_string at DU?$char_traits at D@std@@V?$allocator at D
> @2@@std@@@2@@std@@QEAA?AV?$_Vector_iterator at V?$_Vector_val at U
> ?$_Simple_types at V?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@
> @std@@@std@@@std@@@2 at XZ)
> a.out : fatal error LNK1120: 3 unresolved externals
>
> clang-cl.exe avoids those errors and can generate an executable from C++,
> but it doesn't seem to have -emit-llvm or an equivalent option.
>
> What am I missing?
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150202/fcbaff83/attachment.html>


More information about the llvm-dev mailing list