Jump to page: 1 2
Thread overview
D runtime in os x dylib
Jun 23, 2012
John Colvin
Jun 24, 2012
Jacob Carlborg
Jun 24, 2012
John Colvin
Jun 24, 2012
Jacob Carlborg
Jun 24, 2012
John Colvin
Jun 25, 2012
Jacob Carlborg
Jun 25, 2012
John Colvin
Jun 25, 2012
Jacob Carlborg
Jun 26, 2012
John Colvin
Jun 27, 2012
John Colvin
Jun 27, 2012
Jacob Carlborg
Jun 28, 2012
John Colvin
Jun 25, 2012
Martin Nowak
June 23, 2012
There seems to be a problem with starting the d runtime in a d dylib loaded in a c program. Whenever I call Runtime.initialize() i get a segfault.

C code:

    #include <stdio.h>
    #include <dlfcn.h>

    int main() {
        void *library;
        int (*fptr)();
        library = dlopen("testlib.dylib", RTLD_LAZY);
        if(library == NULL)
            puts("couldn't load the library");
        else {
            *(void **)(&fptr) = dlsym(library,"number");
            if(fptr == NULL) {
   	        puts("couldn't load function");
            }
            else {
                printf("the result is %d\n",(*fptr)());
            }
        }
        return(0);
    }

compiled with gcc, no flags.

d code:

    import core.runtime;

    extern(C) int number() {
    	Runtime.initialize();
    	return(4);
    }

compiled with dmd -shared

Backtrace:

    Program received signal EXC_BAD_ACCESS, Could not access memory.
    Reason: 13 at address: 0x0000000000000000
    0x000000010003de28 in __tls_get_addr ()
    (gdb) bt
    #0  0x000000010003de28 in __tls_get_addr ()
    #1  0x000000010003cdfc in thread_attachThis ()
    #2  0x000000010003ccb8 in thread_init ()
    #3  0x000000010003e312 in gc_init ()
    #4  0x0000000100044ff5 in rt_init ()
    #5  0x000000010003b637 in D4core7runtime7Runtime10initializeFDFC6object9ThrowableZvZb ()
    #6  0x0000000100034ee9 in number ()
    #7  0x0000000100000e84 in main ()

All compilation and debugging done in OS X 10.7

Note: if the Runtime.initialize(); line is commented out, the library is loaded and runs correctly.
June 24, 2012
On 2012-06-23 22:54, John Colvin wrote:
> There seems to be a problem with starting the d runtime in a d dylib
> loaded in a c program. Whenever I call Runtime.initialize() i get a
> segfault.

Dynamic libraries aren't properly working yet. It's being worked on.

-- 
/Jacob Carlborg
June 24, 2012
On Sunday, 24 June 2012 at 09:59:18 UTC, Jacob Carlborg wrote:
> On 2012-06-23 22:54, John Colvin wrote:
>> There seems to be a problem with starting the d runtime in a d dylib
>> loaded in a c program. Whenever I call Runtime.initialize() i get a
>> segfault.
>
> Dynamic libraries aren't properly working yet. It's being worked on.

I see that now, managed to dig up some old bug reports and threads. Is there any timeframe for this or is it on the back burner so to speak?
June 24, 2012
On 2012-06-24 13:47, John Colvin wrote:

> I see that now, managed to dig up some old bug reports and threads. Is
> there any timeframe for this or is it on the back burner so to speak?

I'm not sure of the time frame for this but Martin Nowak is working on this:

https://github.com/dawgfoto/druntime/commits/SharedRuntime

-- 
/Jacob Carlborg
June 24, 2012
Hmm, nothing in the last 3 months. Looks like i may have to abandon os x for development at least for the near future.

On Sunday, 24 June 2012 at 12:41:15 UTC, Jacob Carlborg wrote:
> On 2012-06-24 13:47, John Colvin wrote:
>
>> I see that now, managed to dig up some old bug reports and threads. Is
>> there any timeframe for this or is it on the back burner so to speak?
>
> I'm not sure of the time frame for this but Martin Nowak is working on this:
>
> https://github.com/dawgfoto/druntime/commits/SharedRuntime


June 25, 2012
On 2012-06-24 16:39, John Colvin wrote:
> Hmm, nothing in the last 3 months. Looks like i may have to abandon os x
> for development at least for the near future.

I'm not entirely sure but maybe you're having this problem:

http://d.puremagic.com/issues/show_bug.cgi?id=7995

Pull the latest source code from github and try that if you're using a release.

-- 
/Jacob Carlborg
June 25, 2012
On Monday, 25 June 2012 at 12:17:03 UTC, Jacob Carlborg wrote:
> On 2012-06-24 16:39, John Colvin wrote:
>> Hmm, nothing in the last 3 months. Looks like i may have to abandon os x
>> for development at least for the near future.
>
> I'm not entirely sure but maybe you're having this problem:
>
> http://d.puremagic.com/issues/show_bug.cgi?id=7995
>
> Pull the latest source code from github and try that if you're using a release.

I'm having a nightmare getting the runtime to compile, with MODEL=64 I get a load of these:

src/core/simd.d(35): Error: base type of __vector must be a 16 byte static array, not void[32LU]
src/core/simd.d(52): Error: template instance core.simd.Vector!(void[32LU]) error instantiating
src/core/simd.d(35): Error: base type of __vector must be a 16 byte static array, not double[4LU]
src/core/simd.d(53): Error: template instance core.simd.Vector!(double[4LU]) error instantiating
src/core/simd.d(35): Error: base type of __vector must be a 16 byte static array, not float[8LU]
src/core/simd.d(54): Error: template instance core.simd.Vector!(float[8LU]) error instantiating
src/core/simd.d(35): Error: base type of __vector must be a 16 byte static array, not byte[32LU]
src/core/simd.d(55): Error: template instance core.simd.Vector!(byte[32LU]) error instantiating
src/core/simd.d(35): Error: base type of __vector must be a 16 byte static array, not ubyte[32LU]
src/core/simd.d(56): Error: template instance core.simd.Vector!(ubyte[32LU]) error instantiating
src/core/simd.d(35): Error: base type of __vector must be a 16 byte static array, not short[16LU]
src/core/simd.d(57): Error: template instance core.simd.Vector!(short[16LU]) error instantiating
src/core/simd.d(35): Error: base type of __vector must be a 16 byte static array, not ushort[16LU]
src/core/simd.d(58): Error: template instance core.simd.Vector!(ushort[16LU]) error instantiating
src/core/simd.d(35): Error: base type of __vector must be a 16 byte static array, not int[8LU]
src/core/simd.d(59): Error: template instance core.simd.Vector!(int[8LU]) error instantiating
src/core/simd.d(35): Error: base type of __vector must be a 16 byte static array, not uint[8LU]
src/core/simd.d(60): Error: template instance core.simd.Vector!(uint[8LU]) error instantiating
src/core/simd.d(35): Error: base type of __vector must be a 16 byte static array, not long[4LU]
src/core/simd.d(61): Error: template instance core.simd.Vector!(long[4LU]) error instantiating
src/core/simd.d(35): Error: base type of __vector must be a 16 byte static array, not ulong[4LU]
src/core/simd.d(62): Error: template instance core.simd.Vector!(ulong[4LU]) error instantiating

I tried MODEL=32 just in case and got the same but with "u" insteal of "LU"
June 25, 2012
On 2012-06-25 18:26, John Colvin wrote:
> On Monday, 25 June 2012 at 12:17:03 UTC, Jacob Carlborg wrote:
>> On 2012-06-24 16:39, John Colvin wrote:
>>> Hmm, nothing in the last 3 months. Looks like i may have to abandon os x
>>> for development at least for the near future.
>>
>> I'm not entirely sure but maybe you're having this problem:
>>
>> http://d.puremagic.com/issues/show_bug.cgi?id=7995
>>
>> Pull the latest source code from github and try that if you're using a
>> release.
>
> I'm having a nightmare getting the runtime to compile, with MODEL=64 I
> get a load of these:
>
> src/core/simd.d(35): Error: base type of __vector must be a 16 byte
> static array, not void[32LU]
> src/core/simd.d(52): Error: template instance
> core.simd.Vector!(void[32LU]) error instantiating
> src/core/simd.d(35): Error: base type of __vector must be a 16 byte
> static array, not double[4LU]
> src/core/simd.d(53): Error: template instance
> core.simd.Vector!(double[4LU]) error instantiating
> src/core/simd.d(35): Error: base type of __vector must be a 16 byte
> static array, not float[8LU]
> src/core/simd.d(54): Error: template instance
> core.simd.Vector!(float[8LU]) error instantiating
> src/core/simd.d(35): Error: base type of __vector must be a 16 byte
> static array, not byte[32LU]
> src/core/simd.d(55): Error: template instance
> core.simd.Vector!(byte[32LU]) error instantiating
> src/core/simd.d(35): Error: base type of __vector must be a 16 byte
> static array, not ubyte[32LU]
> src/core/simd.d(56): Error: template instance
> core.simd.Vector!(ubyte[32LU]) error instantiating
> src/core/simd.d(35): Error: base type of __vector must be a 16 byte
> static array, not short[16LU]
> src/core/simd.d(57): Error: template instance
> core.simd.Vector!(short[16LU]) error instantiating
> src/core/simd.d(35): Error: base type of __vector must be a 16 byte
> static array, not ushort[16LU]
> src/core/simd.d(58): Error: template instance
> core.simd.Vector!(ushort[16LU]) error instantiating
> src/core/simd.d(35): Error: base type of __vector must be a 16 byte
> static array, not int[8LU]
> src/core/simd.d(59): Error: template instance
> core.simd.Vector!(int[8LU]) error instantiating
> src/core/simd.d(35): Error: base type of __vector must be a 16 byte
> static array, not uint[8LU]
> src/core/simd.d(60): Error: template instance
> core.simd.Vector!(uint[8LU]) error instantiating
> src/core/simd.d(35): Error: base type of __vector must be a 16 byte
> static array, not long[4LU]
> src/core/simd.d(61): Error: template instance
> core.simd.Vector!(long[4LU]) error instantiating
> src/core/simd.d(35): Error: base type of __vector must be a 16 byte
> static array, not ulong[4LU]
> src/core/simd.d(62): Error: template instance
> core.simd.Vector!(ulong[4LU]) error instantiating
>
> I tried MODEL=32 just in case and got the same but with "u" insteal of "LU"

Are you using the latest sources of DMD?

-- 
/Jacob Carlborg
June 25, 2012
On Mon, 25 Jun 2012 14:17:01 +0200, Jacob Carlborg <doob@me.com> wrote:

> On 2012-06-24 16:39, John Colvin wrote:
>> Hmm, nothing in the last 3 months. Looks like i may have to abandon os x
>> for development at least for the near future.
>
> I'm not entirely sure but maybe you're having this problem:
>
> http://d.puremagic.com/issues/show_bug.cgi?id=7995
>
> Pull the latest source code from github and try that if you're using a release.
>

Right, it looks like that bug.
Statically linking phobos into a dylib should work otherwise.
June 26, 2012
On Monday, 25 June 2012 at 18:55:22 UTC, Jacob Carlborg wrote:

> Are you using the latest sources of DMD?

Yes I am.
« First   ‹ Prev
1 2