dynamic library building and loading

Johannes Pfau nospam at example.com
Fri Sep 28 04:14:07 PDT 2012


Am Fri, 28 Sep 2012 02:04:11 +0200
schrieb "Rob T" <rob at ucora.com>:

> 
> So if I read this right, I can build phobos/druntime with -fPIC 
> from the source code and it will work OK? If so, then why was 
> this not done with the latest distrubution package, or is this 
> only possible after a certain version number?
> 
> --rt

It shouldn't compile on x86 (32bit) with -fPIC because there's some
incompatible asm code in druntime and phobos. If dmd doesn't warn in
these cases, this code will fail as soon as it's called.

GDC used to warn about these errors, but as we dropped the D inline
assembler that code doesn't affect us anymore and there are no more
warnings.

The fix for this issue is simple: Do not modify the EBX register, or at
least save & restore it.

Old patch, which shows what needs to be done:
https://bitbucket.org/goshawk/gdc/issue/166/add-shared-lib-support#comment-648329

Example asm code which probably doesn't work:
https://github.com/D-Programming-Language/druntime/blob/master/src/core/cpuid.d#L432


I just tried building a shared druntime & phobos with gdc:
Druntime seems to be working, Phobos doesn't link here because
something's wrong with the fstat64 symbol. I haven't done any real
testing and we probably need some additional support in the runtime, but
the compiler part seems to be OK with gdc.
http://gdcproject.org/wiki/SharedRuntime
https://github.com/D-Programming-GDC/gdc/pull/32


More information about the Digitalmars-d mailing list