October 20, 2012
On Thu, 18 Oct 2012 13:36:45 +0200, Timo Sintonen <t.sintonen@luukku.com> wrote:

> I have written programs with C for Arm Cortex controller boards. I think that D might be an interesting nut simple enough oo language. So far I have a working gdc for my target, but I can not compile the runtime library because of too many os related assertions.
> With my own makefile I can compile part of the library, so I know tha compiler is working. Is there a way to make a minimum library? Embedded systems do not have file systems or streams or many other things that operating systems have. There would be no need for the whole libaray, but the compiler needs at least the Object class.
> So is it possible to configure a minimum library or should I just look at every file and remove everything that is not needed?
>

I recently did a project on the STM32F0-Discovery board.
After having used a nice arm-none-eabi-*/openocd toolchain I wonder what is needed to build a cross-gdc.
As these devices are really short on Flash and RAM I would've only translated the peripheral headers
without using any runtime.
Not sure though if you can get classes without full typeinfos support.

martin
October 20, 2012
On Saturday, 20 October 2012 at 14:35:44 UTC, Martin Nowak wrote:
> I recently did a project on the STM32F0-Discovery board.
> After having used a nice arm-none-eabi-*/openocd toolchain I wonder what is needed to build a cross-gdc.
> As these devices are really short on Flash and RAM I would've only translated the peripheral headers
> without using any runtime.
> Not sure though if you can get classes without full typeinfos support.
>
Object is a parent for all classes so nothing can be compiled without it. One test I made shows that object and typeinfo would take 16-20 kb flash. In addition we need some libc code and application code. STM32F0 may be too small. My target is STM32F4


October 20, 2012
Am Sat, 20 Oct 2012 17:27:33 +0200
schrieb "Timo Sintonen" <t.sintonen@luukku.com>:

> On Saturday, 20 October 2012 at 14:35:44 UTC, Martin Nowak wrote:
> > I recently did a project on the STM32F0-Discovery board.
> > After having used a nice arm-none-eabi-*/openocd toolchain I
> > wonder what is needed to build a cross-gdc.
> > As these devices are really short on Flash and RAM I would've
> > only translated the peripheral headers
> > without using any runtime.
> > Not sure though if you can get classes without full typeinfos
> > support.
> >
> Object is a parent for all classes so nothing can be compiled without it. One test I made shows that object and typeinfo would take 16-20 kb flash. In addition we need some libc code and application code. STM32F0 may be too small. My target is STM32F4
> 
> 

It's sad that we don't have a documentation about features which require runtime support. If you manage to get this working please make some notes about what features need the runtime (You can use the gdc wiki, gdcproject.org/wiki or the d wiki: http://prowiki.org/wiki4d/wiki.cgi?FrontPage )

BTW: Here's the dmd commit which introduced betterc: https://github.com/D-Programming-Language/dmd/commit/707949edc30f245a68145bef619f6f02b85e39ab

but right now it only disables moduleinfo generation, afaics.

You probably already noticed that you can compile stuff without druntime support just fine (compile with -nophoboslib), as long as you only use c functions:
-----------------------------
import core.stdc.stdio;

extern(C) in main(int argc, const char* argv[])
{
    printf("Hello World!\n".ptr);
    return 0;
}
-----------------------------

As soon as a feature requires runtime support you'll get linker errors.
October 20, 2012
It's also sad that druntime is so difficult to port to other platforms because of the version(platformdependent) all over the place. Would there be a way to cleanly seperate platform-dependent stuff with platform-independent stuff (so a no-os or android version would be easier to make).
October 21, 2012
On Saturday, 20 October 2012 at 18:40:51 UTC, Johannes Pfau wrote:

>
> BTW: Here's the dmd commit which introduced betterc:
> https://github.com/D-Programming-Language/dmd/commit/707949edc30f245a68145bef619f6f02b85e39ab
> but right now it only disables moduleinfo generation, afaics.

This is only in dmd. Gdc does not have this. (d-glue.cc line 2827, I think)

> You probably already noticed that you can compile stuff without druntime
> support just fine (compile with -nophoboslib), as long as you only use c functions:

It seems that cross compilers does not use standard includes and libraries by default. I have my own linker script anyway, because I have fixed addresses and my own program to load the code to the controller. When I get that far, I have to check the extra sections the compiler generates, whether they are needed or not.

I naturally want to use classes. A test of a simple class:
class mytest
{
  int atest(int m) { return m; }
}

This makes 6 calls to Object and 5-6 calls to other druntime classes or to functions druntime wants from os.


October 21, 2012
On 20 October 2012 19:40, Johannes Pfau <nospam@example.com> wrote:
> Am Sat, 20 Oct 2012 17:27:33 +0200
> schrieb "Timo Sintonen" <t.sintonen@luukku.com>:
>
>> On Saturday, 20 October 2012 at 14:35:44 UTC, Martin Nowak wrote:
>> > I recently did a project on the STM32F0-Discovery board.
>> > After having used a nice arm-none-eabi-*/openocd toolchain I
>> > wonder what is needed to build a cross-gdc.
>> > As these devices are really short on Flash and RAM I would've
>> > only translated the peripheral headers
>> > without using any runtime.
>> > Not sure though if you can get classes without full typeinfos
>> > support.
>> >
>> Object is a parent for all classes so nothing can be compiled without it. One test I made shows that object and typeinfo would take 16-20 kb flash. In addition we need some libc code and application code. STM32F0 may be too small. My target is STM32F4
>>
>>
>
> It's sad that we don't have a documentation about features which require runtime support. If you manage to get this working please make some notes about what features need the runtime (You can use the gdc wiki, gdcproject.org/wiki or the d wiki: http://prowiki.org/wiki4d/wiki.cgi?FrontPage )
>
> BTW: Here's the dmd commit which introduced betterc: https://github.com/D-Programming-Language/dmd/commit/707949edc30f245a68145bef619f6f02b85e39ab
>
> but right now it only disables moduleinfo generation, afaics.
>
> You probably already noticed that you can compile stuff without druntime support just fine (compile with -nophoboslib), as long as you only use c functions:
> -----------------------------
> import core.stdc.stdio;
>
> extern(C) in main(int argc, const char* argv[])
> {
>     printf("Hello World!\n".ptr);
>     return 0;
> }
> -----------------------------
>
> As soon as a feature requires runtime support you'll get linker errors.


What an awful name for a flag... (I suppose I better use -ffreestanding / -fhosted to map to that then).


-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
October 23, 2012
On Saturday, 20 October 2012 at 15:27:34 UTC, Timo Sintonen wrote:

> STM32F0 may be too small.

Yeah probably. Are there any patches required to build a
cross-gdc?

October 23, 2012
On 23 October 2012 17:37, Martin Nowak <dawg@dawgfoto.de> wrote:
> On Saturday, 20 October 2012 at 15:27:34 UTC, Timo Sintonen wrote:
>
>> STM32F0 may be too small.
>
>
> Yeah probably. Are there any patches required to build a cross-gdc?
>

Nope - building a cross-compiler should be available in the gcc make infrastructure.  The issue most people get with them is that the toolchain/environment for the cross-compiler is broken somewhere....

-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
October 24, 2012
On Tuesday, 23 October 2012 at 16:37:11 UTC, Martin Nowak wrote:
>  Are there any patches required to build a
> cross-gdc?

Before compiling gcc-package there should be binutils and libc for the target installed. Binutils is the gnu binutils package and as libc I have used newlib, which is a lighter version than gnu libc. Both are easy to compile with: configure --target=arm-eabi    (or whatever the target is)

for gcc I use this:
../gcc/configure --disable-bootstrap \
--enable-languages=c,c++,d  --disable-nls --target=arm-eabi \
--without-headers  --with-newlib --without-isl --without-cloog

( i have gcc sources in /usr/local/src/gcc and this script is in /usr/local/src/build-gcc)
You should first compile and install only c compiler (enable-langugages=c). If this works, then add c++ and if this works, then add d.

If you want to make it for Cortex, one small patch is needed in gcc/config/arm/t-arm-elf to get a working libgcc.a for thumb code. You do not necessary need this for simple programs.

The d compilation fails currently to make the d runtime library and I am working on this.

As suggested, we could start a wiki page for gdc cross compilers. So for the wiki maintainer: please create the page and add link to the front page
November 03, 2012
I have started to make a minimum libdruntime. First I compiled object and now I am adding files one by one when needed.
The compiler generates lots of library calls. So far I have found these flags to get the code smaller and to reduce library calls: -fno-assert -fno-invariants and -fno-bouns-check.
Is there any other options that would make the executable more simple?