Can't implement conformant memset/memcpy without compiler -ffreestanding support

Mike Franklin slavo5150 at yahoo.com
Wed Jul 25 09:40:55 UTC 2018


On Wednesday, 25 July 2018 at 08:57:41 UTC, Zheng (Vic) Luo wrote:

> gcc and clang provides an option "-ffreestanding" to bypass 
> optimizations that need libc support. Although we can hack 
> around this issue by making our implementation complicated 
> enough/using assembly to bypass the optimizer, it would be 
> better to provide a standard flag like "-ffreestanding" for all 
> compilers to disable such optimizations, so that developers 
> won't have to hack around different compiler implementations.

I ran into this with LDC and discussed it at 
https://forum.dlang.org/post/kchsryntrrnfaohjfqfw@forum.dlang.org 
  The solution for me was to compile with 
`-disable-simplify-libcalls`.

I never ran into this issue with GDC when I was compiling with 
`-nophoboslib -nostdinc -nodefaultlibs -nostdlib`.  If I remember 
correctly, GDC would generate calls to `memset`, `memcpy`, and 
friends but seemed to be smart enough not to rewrite my own 
implementations of those functions, so as long as I implemented 
those functions everything worked fine.

I'll have more to say in response to one of your other posts.

Mike



More information about the Digitalmars-d mailing list