[dmd-internals] Making druntime a shared library on linux

Leandro Lucarella luca at llucax.com.ar
Mon Mar 25 16:05:54 PDT 2013


Walter Bright, el 25 de March a las 12:46 me escribiste:
> If you're making a D shared library, you'll need to use a shared
> library version of druntime for both the executable and your shared
> library. Otherwise, there will be two instances of druntime, and
> There Can Be Only One.
> 
> I have 3 pull requests in to do this:
> 
> https://github.com/D-Programming-Language/druntime/pull/462
> https://github.com/D-Programming-Language/phobos/pull/1223
> https://github.com/D-Programming-Language/dmd/pull/1798
> 
> What these do is:
> 
> 1. build druntime as a shared library, need -defaultlib= to do that
> 
> 2. split libdruntime.a off from libphobos2.a, so now the following
> flags must be passed to the link step:
> 
>      -lphobos2 -ldruntime
> 
> 3. add the ability to link to the shared library version of druntime
> instead, with -shared-druntime flag to dmd:
> 
>     -lphobos2 -ldruntimeso
> 
> I couldn't find a linker flag to prefer libdruntime.so over
> libdruntime.a, or vice versa, so I named the shared library
> libdruntimeso.so. Ugh. If there's a better way, please let me know.

ld will always pick the shared one when available. To force using the
static one the only way I know is to pass it as another file to the
linker instead of using -ldruntime (or using -static but that makes the
whole program be statically linked).

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Wenn ist das nunstück git und slotermeyer? Ja!
Beiherhund das oder die Flipperwaldt gersput!
	-- Monty Python (no leer si sabés alemán)


More information about the dmd-internals mailing list