Open llvmbot opened 13 years ago
Sorry, closed wrong bug.
To reproduce, build clang on Windows with Visual Studio 2010 using the instructions at http://clang.llvm.org/get_started.html, then compile this program:
class A { public: ~A() { } } a;
int main() { return 0; }
the output:
c:> clang++ t.cpp t-031021.o : error LNK2019: unresolved external symbol _dsohandle referenced in function cxx_global_var_init t-031021.o : error LNK2019: unresolved external symbol _cxaatexit referenced in function cxx_global_var_init a.out : fatal error LNK1120: 2 unresolved externals clang++: error: linker command failed with exit code 1120 (use -v to see invocation)
Extended Description
http://llvm.org/bugs/show_bug.cgi?id=7276
This bug still happens for native Win32. So, C++ code causes link errors:
error LNK2019: unresolved external symbol _dsohandle referenced error LNK2019: unresolved external symbol cxa_atexit referenced
The fix would be very simple: just put '--fno-use-cxa-atexit' as default argument. Please fix "tools\clang\lib\Driver\Tools.cpp" as follows (sorry I don't have permit to commit yet):
// -fuse-cxa-atexit is default. if (KernelOrKext || !Args.hasFlag(options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit, getToolChain().getTriple().getOS() != llvm::Triple::Win32 && getToolChain().getTriple().getOS() != llvm::Triple::Cygwin && getToolChain().getTriple().getOS() != llvm::Triple::MinGW32 && getToolChain().getTriple().getOS() != llvm::Triple::MinGW64)) CmdArgs.push_back("-fno-use-cxa-atexit");