Re: GDC 9 and ARM Cortex-M

2019-05-20 Thread Iain Buclaw via D.gnu
On Mon, 20 May 2019 at 20:05, Timo Sintonen via D.gnu
 wrote:
>
> On Sunday, 19 May 2019 at 18:58:09 UTC, Iain Buclaw wrote:
>
> >
> > What's the system compiler version you are using?  I've tested
> > with both gcc-9.1 and gcc-8.3, not able to reproduce.
>
> It is in the dump above (even two times ;)
>
> >> GNU D (GCC) version 9.1.0 (arm-eabi)
> >> compiled by GNU C version 8.2.0, GMP version 6.1.2,
> >> MPFR version
> >> 4.0.1, MPC version 1.1.0, isl version none
>
> I'll try to update to 9.1 and test again
>

Or even just 8.3, I guess.

-- 
Iain


Re: GDC 9 and ARM Cortex-M

2019-05-20 Thread Timo Sintonen via D.gnu

On Sunday, 19 May 2019 at 18:58:09 UTC, Iain Buclaw wrote:



What's the system compiler version you are using?  I've tested 
with both gcc-9.1 and gcc-8.3, not able to reproduce.


It is in the dump above (even two times ;)


GNU D (GCC) version 9.1.0 (arm-eabi)
compiled by GNU C version 8.2.0, GMP version 6.1.2, 
MPFR version

4.0.1, MPC version 1.1.0, isl version none


I'll try to update to 9.1 and test again




Re: stdout does not work in GDC

2019-05-20 Thread Iain Buclaw via D.gnu
On Mon, 20 May 2019 at 12:50, D_Boy via D.gnu  wrote:
>
> On Monday, 20 May 2019 at 08:01:01 UTC, D_Boy wrote:
> > I am following Ali Çehreli's book. It says that stdout.write()
> > should work the same as write()
> >
> > In DMD it works. But when trying to compile with GDC I get the
> > following error:
> >
> > gdc anApp.d -o anApp && ./anApp
> > /usr/bin/ld: /tmp/cc5zJLcW.o: in function `_Dmain':
> > anApp.d:(.text+0x32): undefined reference to
> > `_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File'
> > collect2: error: ld returned 1 exit status
> >
> >
> > Could you please tell me what could be wrong?
> >
> > I am using DMD64 2.086.0 and gdc (Ubuntu 8.3.0-6ubuntu1) 8.3.0
> > on Ubuntu 19.04/64.
>
> Update: the hello world program works fine. Problem appears when
> I add readf(" %s", )

$ gdc-8 test.d -o shared
$ nm shared  | grep
_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File
 U
_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File
$ objdump -T /usr/lib/x86_64-linux-gnu/libgphobos.so.76 | grep
_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File
0034c610  w   DF .text 0070  Base
_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File

$ gdc-8 test.d -o static -static-libphobos
ibuclaw@labs-322:~ $ nm static | grep
_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File
0002e720 W
_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File

Can't reproduce, but then again one can't second guess what code you have.

In all likelihood you're linking against the wrong library.

-- 
Iain



Re: stdout does not work in GDC

2019-05-20 Thread D_Boy via D.gnu

On Monday, 20 May 2019 at 08:01:01 UTC, D_Boy wrote:
I am following Ali Çehreli's book. It says that stdout.write() 
should work the same as write()


In DMD it works. But when trying to compile with GDC I get the 
following error:


gdc anApp.d -o anApp && ./anApp
/usr/bin/ld: /tmp/cc5zJLcW.o: in function `_Dmain':
anApp.d:(.text+0x32): undefined reference to 
`_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File'

collect2: error: ld returned 1 exit status


Could you please tell me what could be wrong?

I am using DMD64 2.086.0 and gdc (Ubuntu 8.3.0-6ubuntu1) 8.3.0 
on Ubuntu 19.04/64.


Update: the hello world program works fine. Problem appears when 
I add readf(" %s", )


Re: How to defeat the optimizer in GDC

2019-05-20 Thread Mike Franklin via D.gnu

On Monday, 20 May 2019 at 08:21:19 UTC, Iain Buclaw wrote:

Looks like you've done a typo to me. Memory should be a 
clobber, not an input operand.


Yes, that too.




Re: How to defeat the optimizer in GDC

2019-05-20 Thread Mike Franklin via D.gnu

On Monday, 20 May 2019 at 08:11:19 UTC, Mike Franklin wrote:

But I can't get GDC to do the same:  
https://explore.dgnu.org/z/quCjhU


Is this currently possible in GDC?


Gah!! Ignore that.  `version (GNU)`, not `version(GDC)`.

This works:

void use(void* p)
{
version(LDC)
{
import ldc.llvmasm;
 __asm("", "r,~{memory}", p);
}
version(GNU)
{
asm { "" : : "r" p : "memory"; };
}
}



Re: How to defeat the optimizer in GDC

2019-05-20 Thread Iain Buclaw via D.gnu

On Monday, 20 May 2019 at 08:11:19 UTC, Mike Franklin wrote:
I'm trying to benchmark some code, but the optimizer is 
basically removing all of it, so I'm benchmarking nothing.


I'd like to do something like what Chandler Carruth does here 
to defeat the optimizer:  
https://www.youtube.com/watch?v=nXaxk27zwlk=youtu.be=2446


Here presents the following inline asm function to tell the 
optimizer that `p` is being used (at least that's how I 
understand it):

```
void escape(void* p)
{
asm volatile("" : : "g"(p) : memory);
}
```

I tried to do the same thing in D with this function:
```
void use(void* p)
{
version(LDC)
{
import ldc.llvmasm;
 __asm("", "r,~{memory}", p);
}
version(GDC)
{
asm { "" : : "g"(p), "memory"; }
}
}
```

The LDC version seems to work fine:  
https://d.godbolt.org/z/qbg54J


But I can't get GDC to do the same:  
https://explore.dgnu.org/z/quCjhU


Is this currently possible in GDC?



Looks like you've done a typo to me. Memory should be a clobber, 
not an input operand.


--
Iain


How to defeat the optimizer in GDC

2019-05-20 Thread Mike Franklin via D.gnu
I'm trying to benchmark some code, but the optimizer is basically 
removing all of it, so I'm benchmarking nothing.


I'd like to do something like what Chandler Carruth does here to 
defeat the optimizer:  
https://www.youtube.com/watch?v=nXaxk27zwlk=youtu.be=2446


Here presents the following inline asm function to tell the 
optimizer that `p` is being used (at least that's how I 
understand it):

```
void escape(void* p)
{
asm volatile("" : : "g"(p) : memory);
}
```

I tried to do the same thing in D with this function:
```
void use(void* p)
{
version(LDC)
{
import ldc.llvmasm;
 __asm("", "r,~{memory}", p);
}
version(GDC)
{
asm { "" : : "g"(p), "memory"; }
}
}
```

The LDC version seems to work fine:  
https://d.godbolt.org/z/qbg54J


But I can't get GDC to do the same:  
https://explore.dgnu.org/z/quCjhU


Is this currently possible in GDC?

Mike


stdout does not work in GDC

2019-05-20 Thread D_Boy via D.gnu
I am following Ali Çehreli's book. It says that stdout.write() 
should work the same as write()


In DMD it works. But when trying to compile with GDC I get the 
following error:


gdc anApp.d -o anApp && ./anApp
/usr/bin/ld: /tmp/cc5zJLcW.o: in function `_Dmain':
anApp.d:(.text+0x32): undefined reference to 
`_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File'

collect2: error: ld returned 1 exit status


Could you please tell me what could be wrong?

I am using DMD64 2.086.0 and gdc (Ubuntu 8.3.0-6ubuntu1) 8.3.0 on 
Ubuntu 19.04/64.