[PATCH] Defaulting to -fno-use-cxa-atexit on Windows

Aaron Ballman aaron at aaronballman.com
Mon Mar 11 17:30:28 PDT 2013


When building for Windows, using cxa-atexit causes link errors.  We
already set this flag to false for Cygywin, MinGW and hexagon targets.
 This patch also sets it to false for Windows targets.

Note: to reproduce:

class c {
public:
~c() { }
};

C c;

int main() { return 0; }

On Windows when built with MSVC, this will yield:

test2-906565.o : error LNK2019: unresolved external symbol ___dso_handle referen
ced in function ___cxx_global_var_init
test2-906565.o : error LNK2019: unresolved external symbol ___cxa_atexit referen
ced in function ___cxx_global_var_init
a.out : fatal error LNK1120: 2 unresolved externals

This patch resolves it so that you do not have to pass
-fno-use-cxa-atexit in order to properly link.

~Aaron
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cxa-atexit.patch
Type: application/octet-stream
Size: 653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130311/4b14970e/attachment.obj>


More information about the cfe-commits mailing list