[M3devel] C/C++ interop/linking thoughts?

Jay jayk123 at hotmail.com
Mon Dec 31 21:29:59 CET 2007


C/C++ interop/linking thoughts?
What are people's thoughts on interop with and C and C++?
In particular, that of static linking C and C++ with Modula-3, in the same .dll/.so/.exe?Or that of loading a Modula-3 .dll/.so into a process that is otherwise just C and C++?
I ask for NOT the most important of reasons.
The Modula-3 dependency on the C runtime on Windows is pretty light, and it is in fact mostly for the startup code. The startup code doesn't do much. Mainly it runs C++ constructors/destructors. And C code can have initializers/cleanup.
I think it might be interesting to drive this dependency to zero, but it depends on expectations of C and C++ statically linked into a Modula-3 .dll/.so/.exe working.
I know there is C code in the system already. It is light. It works without the startup  code in my experience.
I already changed Modula-3 .dlls to build with /noentry..exes take a bit more.It's in the config file.
 
There are comments in the config file about it, including the contrary point of a C generating back end
.
On a very related note, I almost forgot..on Mac OS X, there is shared or static libgcc.
The man pages say roughly this:
   g++ and gcj (Java) specify shared libgcc by default 
   gcc specifies static libgcc by default 
C++ and Java favor shared in order to enable throwing/catching exceptions across .dll/.so boundaries.
"Pure" Modula-3 code wouldn't care about that. Modula-3 code linking with C++ might.
Perhaps in these scenarios, the "build system" and linking will tend to escape cm3 anyway?Make Modula-3 static .libs/.a with cm3 but not link the final file with it?
 
I think the current config file links .dylibs(.dll/.so, but usually .dylib in this context, at least by convention) with static libgcc and executables with shared.
I found in groveling over the results that, there were four or six functions imported from shared libgcc, little math helpers for division or such.
It seems not worth depending on another file for just a few small functions.
 
Just use static?
 
On a less related note, for anyone who likes to go down such paths, I concluded that calling ld directly on Mac OS X is not a great idea, best stick to calling gcc (or g++/whatever) to do the linking, as the current files do.
 
 - Jay
_________________________________________________________________
i’m is proud to present Cause Effect, a series about real people making a difference.
http://im.live.com/Messenger/IM/MTV/?source=text_Cause_Effect
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20071231/d383d265/attachment-0001.html>


More information about the M3devel mailing list