Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow linking C++ #48

Merged
merged 3 commits into from
Apr 22, 2020
Merged

Allow linking C++ #48

merged 3 commits into from
Apr 22, 2020

Conversation

dra27
Copy link
Member

@dra27 dra27 commented Dec 6, 2017

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 added 3 commits December 6, 2017 11:29
reloc displays the names of default libraries as they're scanned, but not
other imported libraries, which was confusing.

Signed-off-by: David Allsopp <[email protected]>
As per GCC spec strings, if -lgcc is given, so should -lgcc_eh.

Signed-off-by: David Allsopp <[email protected]>
reloc maps __imp_X to _X but didn't have the reverse case, which appears
to be necessary when linking C++ applications.

Signed-off-by: David Allsopp <[email protected]>
@dra27
Copy link
Member Author

dra27 commented Mar 17, 2018

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
Copy link

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.

@dra27 dra27 mentioned this pull request Jun 21, 2018
bryphe added a commit to bryphe/flexdll that referenced this pull request Sep 18, 2018
@dra27 dra27 force-pushed the linking-c++ branch 2 times, most recently from a9e0564 to 5f1b82f Compare April 21, 2020 20:10
@dra27 dra27 merged commit bd636de into ocaml:master Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants