www.digitalmars.com         C & C++   DMDScript  

D.gnu - DMD and GDC static libraries are incompatible on Linux?

reply "Jeremy DeHaan" <dehaan.jeremiah gmail.com> writes:
I'm pretty sure I already know the answer to this, however I just 
wanted to ask to make sure.

I was talking with someone the other day. They were using Linux 
and tried to link static libraries built with DMD during a build 
with GDC. I thought this would work due to both DMD and GDC using 
GCC on Linux, but GDC wouldn't find any of the symbols in the DMD 
static libraries. Is this normal?
Feb 09 2015
next sibling parent reply ketmar <ketmar ketmar.no-ip.org> writes:
On Mon, 09 Feb 2015 17:56:53 +0000, Jeremy DeHaan wrote:

 I'm pretty sure I already know the answer to this, however I just wanted
 to ask to make sure.
=20
 I was talking with someone the other day. They were using Linux and
 tried to link static libraries built with DMD during a build with GDC. I
 thought this would work due to both DMD and GDC using GCC on Linux, but
 GDC wouldn't find any of the symbols in the DMD static libraries. Is
 this normal?
DMD is not using GCC, only 'ld' from binutils. so yes, this is normal.=20 actually, you can't expect this to work, as object code representation is=20 not specified by the language, and generated code too. mixing compiled=20 libraries from dmd and gdc can have alot of unexpected effects, 'cause=20 even runtime is not similar.=
Feb 09 2015
next sibling parent "Jeremy DeHaan" <dehaan.jeremiah gmail.com> writes:
On Monday, 9 February 2015 at 18:56:44 UTC, ketmar wrote:
 DMD is not using GCC, only 'ld' from binutils. so yes, this is 
 normal.
Oh, interesting. I didn't realize this. Thanks for the info, guys. I thought as much.
Feb 09 2015
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2015-02-09 19:56, ketmar wrote:

 DMD is not using GCC, only 'ld' from binutils.
Actually, DMD _is_ using GCC to link. -- /Jacob Carlborg
Feb 10 2015
parent reply ketmar <ketmar ketmar.no-ip.org> writes:
On Tue, 10 Feb 2015 09:07:14 +0100, Jacob Carlborg wrote:

 On 2015-02-09 19:56, ketmar wrote:
=20
 DMD is not using GCC, only 'ld' from binutils.
=20 Actually, DMD _is_ using GCC to link.
yes. sorry for misinformation, i was sure that it calls 'ld' directly.=
Feb 10 2015
parent reply Leandro Lucarella <luca llucax.com.ar> writes:
ketmar, el 10 de February a las 11:44 me escribiste:
 On Tue, 10 Feb 2015 09:07:14 +0100, Jacob Carlborg wrote:
 
 On 2015-02-09 19:56, ketmar wrote:
 
 DMD is not using GCC, only 'ld' from binutils.
Actually, DMD _is_ using GCC to link.
yes. sorry for misinformation, i was sure that it calls 'ld' directly.
But GCC only behaves as a wrapper of ld to link. :) -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- una vez mas voy a arrastrar mi alma por el suelo y no me importa sentirme mal, si es lo que quiero tragando polvo, llorando sangre, anocheciendo una vez mas voy a cerrar mis ojos para siempre
Feb 14 2015
parent ketmar <ketmar ketmar.no-ip.org> writes:
On Sun, 15 Feb 2015 06:09:33 +0100, Leandro Lucarella wrote:

 ketmar, el 10 de February a las 11:44 me escribiste:
 On Tue, 10 Feb 2015 09:07:14 +0100, Jacob Carlborg wrote:
=20
 On 2015-02-09 19:56, ketmar wrote:
=20
 DMD is not using GCC, only 'ld' from binutils.
=20 Actually, DMD _is_ using GCC to link.
=20 yes. sorry for misinformation, i was sure that it calls 'ld' directly.
=20 But GCC only behaves as a wrapper of ld to link. :)
yes, but it passes some funny options like linker script, path to system=20 libraries and so on. and i'm so used to this that i was always thinking=20 about this phase as "calling 'ld'", completely forgetting about gcc=20 wrapper. ;-)=
Feb 15 2015
prev sibling parent reply "Iain Buclaw via D.gnu" <d.gnu puremagic.com> writes:
On 9 February 2015 at 17:56, Jeremy DeHaan via D.gnu
<d.gnu puremagic.com> wrote:
 I'm pretty sure I already know the answer to this, however I just wanted to
 ask to make sure.

 I was talking with someone the other day. They were using Linux and tried to
 link static libraries built with DMD during a build with GDC. I thought this
 would work due to both DMD and GDC using GCC on Linux, but GDC wouldn't find
 any of the symbols in the DMD static libraries. Is this normal?
GDC and DMD are not ABI compatible. There are many reasons why this is so, but the one that is likely affecting you is because DMD emits references to symbols that do not exist in GDC's runtime library. Iain.
Feb 09 2015
parent reply "Jeremy DeHaan" <dehaan.jeremiah gmail.com> writes:
On Monday, 9 February 2015 at 19:24:22 UTC, Iain Buclaw wrote:
 GDC and DMD are not ABI compatible.  There are many reasons why 
 this
 is so, but the one that is likely affecting you is because DMD 
 emits
 references to symbols that do not exist in GDC's runtime 
 library.

 Iain.
I was thinking about this today and I had another question. What about shared libraries? If I were to release a library on Linux in shared library form, would it be compatible between compilers?
Feb 18 2015
next sibling parent reply ketmar <ketmar ketmar.no-ip.org> writes:
On Wed, 18 Feb 2015 22:13:04 +0000, Jeremy DeHaan wrote:

 On Monday, 9 February 2015 at 19:24:22 UTC, Iain Buclaw wrote:
 GDC and DMD are not ABI compatible.  There are many reasons why this is
 so, but the one that is likely affecting you is because DMD emits
 references to symbols that do not exist in GDC's runtime library.

 Iain.
=20 I was thinking about this today and I had another question. What about shared libraries? If I were to release a library on Linux in shared library form, would it be compatible between compilers?
nope, if it using D API. only `extern(C)` is allowed, and you must own=20 all your GC-allocated objects, and you can't mix DMD and GDC libraries=20 (ah, well, you can't even build shared phobos with GDC yet), and... nope.=
Feb 18 2015
parent reply "Iain Buclaw via D.gnu" <d.gnu puremagic.com> writes:
On 18 February 2015 at 22:31, ketmar via D.gnu <d.gnu puremagic.com> wrote:
 (ah, well, you can't even build shared phobos with GDC yet), and...
True story, GDC got there first with shared library support before D2 was released. *Then* D2 came out with TLS on by default for all static data. Shared libraries suddenly because a problem because the GC was no longer aware of TLS allocations without some magic data section hackery.
Feb 18 2015
parent ketmar <ketmar ketmar.no-ip.org> writes:
On Wed, 18 Feb 2015 22:40:16 +0000, Iain Buclaw via D.gnu wrote:

 On 18 February 2015 at 22:31, ketmar via D.gnu <d.gnu puremagic.com>
 wrote:
 (ah, well, you can't even build shared phobos with GDC yet), and...
True story, GDC got there first with shared library support before D2 was released. *Then* D2 came out with TLS on by default for all static data. Shared libraries suddenly because a problem because the GC was no longer aware of TLS allocations without some magic data section hackery.
and gdc is *almost* there now, with some problems unsolved. i'm not=20 saying that gdc is bad ;-), it just need a helping hand. alas, my hands=20 are mounted to the wrong mount point. ;-)=
Feb 18 2015
prev sibling parent reply "Iain Buclaw via D.gnu" <d.gnu puremagic.com> writes:
On 18 February 2015 at 22:13, Jeremy DeHaan via D.gnu
<d.gnu puremagic.com> wrote:
 On Monday, 9 February 2015 at 19:24:22 UTC, Iain Buclaw wrote:
 GDC and DMD are not ABI compatible.  There are many reasons why this
 is so, but the one that is likely affecting you is because DMD emits
 references to symbols that do not exist in GDC's runtime library.

 Iain.
I was thinking about this today and I had another question. What about shared libraries? If I were to release a library on Linux in shared library form, would it be compatible between compilers?
The answer would still be no because of calling convention differences - another reason why GDC and DMD are not ABI compatible. However, if you used an extern(C) API, then that should be at least some guarantee of shared library compatibility. Iain.
Feb 18 2015
parent "Daniel Murphy" <yebbliesnospam gmail.com> writes:
"Iain Buclaw via D.gnu"  wrote in message 
news:mailman.6598.1424298906.9932.d.gnu puremagic.com...

 The answer would still be no because of calling convention differences
 - another reason why GDC and DMD are not ABI compatible.

 However, if you used an extern(C) API, then that should be at least
 some guarantee of shared library compatibility.
How different are we on linux these days?
Feb 19 2015