ddmd gdc

Iain Buclaw ibuclaw at gdcproject.org
Mon Oct 12 23:59:15 UTC 2020


On Monday, 12 October 2020 at 18:03:39 UTC, Ola Fosheim Grøstad 
wrote:
> On Monday, 12 October 2020 at 17:26:22 UTC, Iain Buclaw wrote:
>> I'm tracking the "master" branch of DMD, as the "merge master 
>> into stable" commits are huge and tend to come with many 
>> implementation regressions.
>
> Maybe it is better to wait for an official gdc/gcc release then.
>

I won't be pushing anything unless everything passes, so no need 
to worry about that.

>> git init
>> git remote add users/ibuclaw git://gcc.gnu.org/git/gcc.git
>> git config --replace-all remote.users/ibuclaw.fetch 
>> "+refs/users/ibuclaw/heads/*:refs/remotes/users/ibuclaw/*"
>> git fetch users/ibuclaw
>> git checkout -b gdc-mainline users/ibuclaw/gdc
>>
>> The assumption is you already know how to build gcc from here.
>
> Ok, thanks. I will give it a spin in a few days and see what 
> happens. What I'd like to try out is AVR/Arduino as a target, 
> but I see that avr-gcc is a separate project. Maybe not 
> compatible with gdc.
>
> Expressions should default to 16 bit integers for performance, 
> but that only affects the standard library I think. So it could 
> work with the better-C subset… Although for a start one could 
> use 32 bit (with slow performance). Actually, I would be 
> excited just to see a LED blinking... :P

I've just given it a whirl using avr-gcc and simulavr (from 
ubuntu focal), and a simplified example program from here 
http://www.nongnu.org/simulavr/simple_ex.html.

     # Also set AS_FOR_TARGET and others just to be sure...
     $ ../configure --prefix=/usr/lib --bindir=/usr/bin 
--libexecdir=/usr/lib --libdir=/usr/lib --enable-language=d 
--target=avr --with-as=/usr/lib/avr/bin/as 
--with-ld=/usr/lib/avr/bin/ld
     $ make -j$(nproc)
     $ DESTDIR=$PWD/avr-gdc make install -j$(nproc)

     $ echo 'module object;' > object.d
     $ echo 'module core.volatile;
nothrow: @safe: @nogc:
void volatileStore(ubyte * ptr, ubyte  value);
ubyte volatileLoad(ubyte * ptr);
' > volatile.d
     $ echo 'module main;
import core.volatile;
// This port corresponds to the "-W 0x20,-" command line option.
enum stdout = cast(ubyte *)0x20;
// This port corresponds to the "-R 0x22,-" command line option.
enum stdin = cast(ubyte *)0x22;
// Poll the specified string out the debug port.
void debug_puts(const(char)[] str) {
     foreach (c; str)
         volatileStore(stdout, c);
}
extern (C) int main() {
     debug_puts("\nHello " ~ __VENDOR__ ~ " " ~ 
__VERSION__.stringof ~ " on AVR\n\n");
     return 0;
}
' > main.d

     # Extra -L and -B wouldn't be necessary if I installed it in 
the system, or
     # avr-libc was installed in same directory.
     $ ./avr-gdc/usr/bin/avr-gdc -fno-druntime main.d volatile.d 
-O2 -mmcu=attiny2313 -L/usr/lib/avr/lib 
-L/usr/lib/avr/lib/avr25/tiny-stack 
-B/usr/lib/avr/lib/avr25/tiny-stack

     $ simulavr -d attiny2313 -f a.out -W 0x20,- -R 0x22,- -T exit

Hello GNU D 2094L on AVR

SystemClock::Endless stopped
number of cpu cycles simulated: 442




More information about the D.gnu mailing list