Building LDC runtime for a microcontroller

Remi remigillig at
Thu Sep 17 19:17:40 UTC 2020

On Thursday, 17 September 2020 at 09:53:57 UTC, Remi wrote:
> [snip]
> My problem here is mostly understanding the __initZ symbol and 
> where it comes from. I mostly want classes and the bare minimum 
> of std like you did for Tetris in WebAssembly for example. My 
> project is OpenGL/SDL2 so there's a lot of glue code but just 
> ruinning a simple example gives me problems I want to 
> understand first.

Well... I just found out that it wasn't an issue with the code 
but rather the order of files as given to the compiler:

     (ldc-1.23.0)speps:~/dlang/wasm/webassembly$ ldc2 -i=. -i=std 
-Iarsd-webassembly/ -L-allow-undefined -oftetris.wasm 
-mtriple=wasm32-unknown-unknown-wasm arsd-webassembly/object.d 
arsd-webassembly/object.d(112): Error: Global variable type does 
not match previous declaration with same mangled name: 
arsd-webassembly/object.d(112):        Previous IR type: 
%object.TypeInfo_Array = type { [1 x i8*]*, i8*, 
%object.TypeInfo* }, mutable, non-thread-local
arsd-webassembly/object.d(112):        New IR type:      
%object.TypeInfo_Ai = type { [1 x i8*]*, i8*, %object.TypeInfo* 
}, const, non-thread-local
     (ldc-1.23.0)speps:~/dlang/wasm/webassembly$ ldc2 -i=. -i=std 
-Iarsd-webassembly/ -L-allow-undefined -oftetris.wasm 
-mtriple=wasm32-unknown-unknown-wasm tetris.d 

If object.d is passed after tetris.d, everything works as 
expected. Otherwise you get issues with __initZ. It also means 
that I might have no control over what dub does with the order of 
files and I can't use dub to build my WASM project.

More information about the Digitalmars-d-learn mailing list