Gdc & avr

Manu turkeyman at
Sat Feb 4 13:53:35 PST 2012

On 4 February 2012 14:47, Paulo Pinto <pjmlp at> wrote:

> So are you writting your own crt0 startup code?

Absolutely. Most microcontroller based systems will have a custom written
init routine.

Are you also creating the code that takes care to validate if there
> are atexit() handlers in need to be called after main?

main will never exit on a typical microcontroller implementation.

Are you writing the code that takes care to handle program arguments
> and passing them to main() or whatever is your program entry point?

Unlikely. Embedded systems/microcontrollers typically just begin executing
when they receive power.
You probably won't even have main, you just declare a 'void start()'
function and make sure to place it at the boot address.

> Because if you aren't, then you are using C runtime library no matter what.

I've never linked a c runtime to a microcontroller app.

All that said, some of the faster arduino systems are reasonably capable,
and have little linux kernels. They might work fine with an adapted
druntime, as long as the exe doesn't bloat, and it doesn't allocate like a
But D should at least be *capable* of producing a raw exe without any libs
either way. It's just a compiler, there's no technical reason why it
shouldn't, except a few language features that depend on intrinsic library
calls which you would have to avoid.

On 03.02.2012 20:32, Manu wrote:
>> On 3 February 2012 16:45, Paulo Pinto <pjmlp at
>> <mailto:pjmlp at>> wrote:
>>    The only language without runtime is pure assembly.
>> And C.. there's no requirement to link the CRT in a C app. In fact, in
>> many of my projects, I don't.
>> I frequently find that the ONLY function I use from the CRT is
>> sprintf... which I really should write(/copy) my own version of, so I
>> can never link a CRT again :P
>>    All high level languages require a runtime library, even C, despite
>>    what many people think.
>> Wrong, the C _language_ depends on NOTHING in the CRT. I prefer to avoid
>> linking it wherever possible. Strangely enough, I find the 'standard' C
>> library to be one of the least standard libraries out there, and avoid
>> it for that reason.
>>    Now in this case what would be nice would be the possibility to
>>    generate code that runs on top of the arduino without any
>>    real OS. This is a common use case in embedded systems and here the
>>    runtime has even an higher value as it takes the
>>    role of an OS.
>> All that's required is a toolchain that's capable of producing an exe
>> without the requirement to link any compulsory library.
>>    --
>>    Paulo
>>    "Manu" <turkeyman at <mailto:turkeyman at>> wrote in
>>    message news:mailman.312.1328277504.**25230.digitalmars-d at puremagic.**
>> com...
>>    On 3 February 2012 15:37, Alex_Dovhal <alex_dovhal at
>>    <mailto:alex_dovhal at>**> wrote:
>>        __
>>         >Andrea Fontana" <advmail at
>>        <mailto:advmail at>> wrote:
>>         >In this case can we hope for a d frontend?
>>        That depends if it's MCU or MPU. If it will be MCU(like
>>        ARM7TDMI), which means Harvard Architecture (where Program code
>>        and RAM are physically different). Also internal RAM of a few KB
>>        and no Linux.
>>        If it'll be MCU then it can have Linux OS, so theoretically it
>>        can have GDC ported.
>>    Eh? Why would GDC depend on linux at all? If you disable the GC (and
>>    dependent language functionality), and manage to do something about
>>    the horrible exe bloat, there's no reason it shouldn't be able to
>>    target anything...
>>    The obvious advantage over C is the syntax features. Clearly D as a
>>    *language* shouldn't DEPEND on the druntime, other than some
>>    language features that imply GC, like dynamic arrays/etc.
>>    Is the toolchain not capable of producing a working exe without
>>    linking any library? Surely you can write a totally raw app with no
>>    libs at all? (assuming you avoid language features that make
>>    implicit druntime calls)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Digitalmars-d mailing list