www.digitalmars.com         C & C++   DMDScript  

D.gnu - Can the runtime be disabled in GDC?

reply "Mike" <none none.com> writes:
I finally got a GDC cross-compiler compiled, and I'm currently 
trying to test it.  My simple "hello world" program does not use 
any D runtime features, and I was able to compile it with LDC 
-noruntime -nodefaultlib.

However, when I try to use GDC, I get...

"cannot find source code for runtime library file 'object.d'"

Are there similar options in GDC to disable the D runtime, or 
will I have to write stubs?

And, does GDC have any D-specific options?

Thanks,
Mike
Dec 01 2013
next sibling parent Iain Buclaw <ibuclaw gdcproject.org> writes:
On Dec 1, 2013 8:25 AM, "Mike" <none none.com> wrote:
 I finally got a GDC cross-compiler compiled, and I'm currently trying to
test it. My simple "hello world" program does not use any D runtime features, and I was able to compile it with LDC -noruntime -nodefaultlib.
 However, when I try to use GDC, I get...

 "cannot find source code for runtime library file 'object.d'"

 Are there similar options in GDC to disable the D runtime, or will I have
to write stubs?
 And, does GDC have any D-specific options?
You will require at least an object.d file to provide stubs - minilibd sbould be sufficient IIRC. There is -nodefaultlibs, or -nostdlib (which bypasses libgcc also). However, the compiler may generate calls to memcmp, memset, memcpy and memmove. So these should be provided for if you are not linking against some sort of libc. If you are linking against libc, and just don't want phobos, then there is -nophoboslib. This will also omit linking to druntime as currently there are bundled as one library. You also have -nostartfiles if you wish to also provide for the crtstart.o/crtend.o startup files. Currently there is no way to interface with dmd's -betterC switch. So if you don't want moduleinfo tidbits to be written, then you'll have to patch the compiler (d-lang.cc: d_init_options) - I can of course get this in as soon as possible . I'm not sure of ldc's -noruntime switch, but I am going to assume its functionality and say there is no equivalent in gdc. What would be nice though is a warning on any operations that cause implicit allocation/external calls. Regards -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Dec 01 2013
prev sibling parent Iain Buclaw <ibuclaw gdcproject.org> writes:
On 1 December 2013 10:17, Iain Buclaw <ibuclaw gdcproject.org> wrote:
 On Dec 1, 2013 8:25 AM, "Mike" <none none.com> wrote:
 I finally got a GDC cross-compiler compiled, and I'm currently trying to
 test it.  My simple "hello world" program does not use any D runtime
 features, and I was able to compile it with LDC -noruntime -nodefaultlib.

 However, when I try to use GDC, I get...

 "cannot find source code for runtime library file 'object.d'"

 Are there similar options in GDC to disable the D runtime, or will I have
 to write stubs?

 And, does GDC have any D-specific options?
You will require at least an object.d file to provide stubs - minilibd sbould be sufficient IIRC. There is -nodefaultlibs, or -nostdlib (which bypasses libgcc also). However, the compiler may generate calls to memcmp, memset, memcpy and memmove. So these should be provided for if you are not linking against some sort of libc. If you are linking against libc, and just don't want phobos, then there is -nophoboslib. This will also omit linking to druntime as currently there are bundled as one library. You also have -nostartfiles if you wish to also provide for the crtstart.o/crtend.o startup files. Currently there is no way to interface with dmd's -betterC switch. So if you
The interface with dmd's -betterC is -fno-emit-moduleinfo Regards Iain.
Dec 05 2013