ocaml / flexdll

a dlopen-like API for Windows
Other
97 stars 30 forks source link

Allow linking C++ #48

Closed dra27 closed 4 years ago

dra27 commented 6 years ago

At least for mingw64! These two changes together have allowed me to link applications using the ocaml-mccs C++ stubs.

I'm reasonably confident that the change to add -lgcc_eh is correct (because we already add -lgcc). I'm not so totally confident about the change in Reloc.needed, although I am confident that this only changes the behaviour for symbols which previously would have caused linker errors.

dra27 commented 6 years ago

Buried in the quite sensible refactoring in https://github.com/cygwinports/flexdll/blob/master/0.34-cygwin.patch is a change in the Cygwin default libs which is related to this, as -lgcc_s is added.

@yselkowitz - why do you do -lgcc_s -lgcc rather than -lgcc -lgcc_eh? (or, put another way, if we add -lgcc_eh, would you still need to patch it to have -lgcc_s instead?)

yselkowitz commented 6 years ago

While on other targets, -lgcc_s (aka -shared-libgcc) is limited to C++ usage, it is the default on Cygwin even with C (when not linking with -static, of course), in order to support throwing exceptions across DLL boundaries.