hmmdyl / LWDR

LightWeight D Runtime targeting ARM Cortex CPUs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

undefined reference to __aeabi_read_tp on ModuleCtors

MrcSnm opened this issue · comments

In dub.json I have:

"dflags": [
		"-mtriple=armv7a-unknown-unknown",
		"-mcpu=cortex-a9",
		"-g",
		"-float-abi=hard",
		"-O0",
		"--boundscheck=off",
		"-fthread-model=local-exec"
	],

"versions": [
		"LWDR_DynamicArray",
		"LWDR_ModuleCtors"
	],

My D code:

class Test
{
	static int[] testStaticConstructor;
	immutable(char*) getStringFromD()
	{
		return "Hello World from D! Simple Test".ptr;
	}
}

static this()
{
	for(int i = 0; i < 5; i++)
		Test.testStaticConstructor~= i;
}

So, I found the thing about the TLS thing, so I implemented the functions as this on my C code:

#define MAX_THREADS 32
thread_key_t tls_keys[MAX_THREADS];

#define CHECK_CREATE_KEY(index) if((index) > MAX_THREADS || (index) < 0) \
									assert(0); \
								if(tls_keys[index] == NULL) \
									pthread_key_create(&tls_keys[index], NULL);


void* rtosbackend_getTLSPointerCurrThread(int index)
{
	CHECK_CREATE_KEY(index);
	return pthread_getspecific(tls_keys[index]);
	//SCE -> return sceKernelGetTLSAddr(index);
}
void rtosbackend_setTLSPointerCurrThread(void* value, int index)
{
	CHECK_CREATE_KEY(index);
	pthread_setspecific(tls_keys[index], value);
}

But now I'm getting an error called Invalid relocation type

After some people said to me, I should have no Position Independent Code.

So I went and added to DFLAGS: --relocation-model=static. But nothing actually had changed

So, after putting __gshared on my class, I got rid of the error (Invalid relocation type). But, is that really the expected behaviour?

class Test
{
	__gshared static int[] testStaticConstructor;
	immutable(char*) getStringFromD()
	{
		return "Hello World from D! Simple Test".ptr;
	}
}

But my static this is not being called.
Have you implemented it? My code is unable to reference Runtime.initialize nor rt_init

Okay, it seems you have implemented that under the beta version.
Maybe we could have that under a changelog?

Okay. I found that

import lwdr;
void main()
{
     LWDR.startRuntime();
     LWDR.stopRuntime();
}

But then...:

c:/msys64/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld.exe: libDLibrary.a(rt.moduleinfo.o): in function `_D2rt10moduleinfo9sortCtorsFNbNiZ8findDepsMFNbNikPkZb':
C:\/Users\Marcelo\AppData\Local\dub\packages\lwdr-0.4.0-beta.1\lwdr\source\rt/moduleinfo.d:143: undefined reference to `_d_eh_resume_unwind'
c:/msys64/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld.exe: libDLibrary.a(rt.moduleinfo.o):(.ARM.extab+0x0): undefined reference to `_d_eh_personality'