Hitchikers Guide to Porting Phobos / D Runtime to other architectures

Adam D. Ruppe destructionator at gmail.com
Tue Jan 7 18:03:56 PST 2014


On Wednesday, 8 January 2014 at 01:27:28 UTC, Walter Bright wrote:
> It's not that hard. Use the -betterC switch to prevent 
> ModuleInfo records and their dependencies from being emitted, 
> and then you can write D code that has zero dependence on 
> druntime or phobos.

...until you declare a struct. I find the -betterC switch to be 
totally useless. If you are just toying, there's no module info 
anyway:

extern(C) {
	void _d_run_main() {} // why is this required now????
	void* _d_dso_registry;

	void _start() {

	}
}

dmd -c *.d -defaultlib= -debuglib=
gcc -m32 *.o -nostdlib

success. Add "struct Test{}" and:

Error: ModuleInfo not found. object.d may be incorrectly 
installed or corrupt.

OK, add -betterC:

Error: TypeInfo not found. object.d may be incorrectly installed 
or corrupt, compile with -v switch


If you do use an object.d with it defined to get past the 
compiler, it doesn't help much as the linker complains anyway:

test.o:(.data._D20TypeInfo_S4test4Test6__initZ+0x0): undefined 
reference to `_D15TypeInfo_Struct6__vtblZ'


So my verdict is -betterC is pretty useless. If it got past the 
TypeInfo stuff the same way it gets past ModuleInfo though, then 
we'd be cooking with gas. That potentially gives a language that 
is legitimately a better C. But without structs, bah.


More information about the Digitalmars-d mailing list