Skip to content

Allow linking C++#48

Merged
dra27 merged 3 commits intoocaml:masterfrom
dra27:linking-c++
Apr 22, 2020
Merged

Allow linking C++#48
dra27 merged 3 commits intoocaml:masterfrom
dra27:linking-c++

Conversation

@dra27
Copy link
Copy Markdown
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 <david.allsopp@metastack.com>
As per GCC spec strings, if -lgcc is given, so should -lgcc_eh.

Signed-off-by: David Allsopp <david.allsopp@metastack.com>
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 <david.allsopp@metastack.com>
@dra27
Copy link
Copy Markdown
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
Copy Markdown

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