diff --git a/src/ddmd/backend/backconfig.c b/src/ddmd/backend/backconfig.c index dc708e87f2c3..1b2f619590b6 100644 --- a/src/ddmd/backend/backconfig.c +++ b/src/ddmd/backend/backconfig.c @@ -51,7 +51,8 @@ void out_config_init( // 2: fake it with C symbolic debug info bool alwaysframe, // always create standard function frame bool stackstomp, // add stack stomping code - bool avx // use AVX instruction set + bool avx, // use AVX instruction set + bool betterC // implement "Better C" ) { #if MARS @@ -253,6 +254,8 @@ void out_config_init( if (stackstomp) config.flags2 |= CFG2stomp; + config.betterC = betterC; + ph_init(); block_init(); diff --git a/src/ddmd/backend/cdef.d b/src/ddmd/backend/cdef.d index e39f731cf369..9fcc4052b981 100644 --- a/src/ddmd/backend/cdef.d +++ b/src/ddmd/backend/cdef.d @@ -692,6 +692,7 @@ struct Config // to near linkage_t linkage; // default function call linkage EHmethod ehmethod; // exception handling method + bool betterC; // implement "Better C" static uint sizeCheck(); unittest { assert(sizeCheck() == Config.sizeof); } diff --git a/src/ddmd/backend/cdef.h b/src/ddmd/backend/cdef.h index 52c414a4502a..e51ba6dc3038 100644 --- a/src/ddmd/backend/cdef.h +++ b/src/ddmd/backend/cdef.h @@ -931,6 +931,7 @@ struct Config // to near linkage_t linkage; // default function call linkage EHmethod ehmethod; // exception handling method + bool betterC; // implement "Better C" static unsigned sizeCheck(); }; diff --git a/src/ddmd/backend/dwarf.c b/src/ddmd/backend/dwarf.c index 2be5a8b650cf..a5d6cf884fdc 100644 --- a/src/ddmd/backend/dwarf.c +++ b/src/ddmd/backend/dwarf.c @@ -98,7 +98,8 @@ bool doUnwindEhFrame() * g++ on FreeBSD does not generate mixed frames, while g++ on OSX and Linux does. */ assert(!(usednteh & ~(EHtry | EHcleanup))); - return (usednteh & (EHtry | EHcleanup)) || (config.exe & (EX_FREEBSD | EX_FREEBSD64)); + return (usednteh & (EHtry | EHcleanup)) || + (config.exe & (EX_FREEBSD | EX_FREEBSD64)) && !config.betterC; } #if ELFOBJ diff --git a/src/ddmd/backend/elfobj.c b/src/ddmd/backend/elfobj.c index 1c7b298758ab..19be88a45aaf 100644 --- a/src/ddmd/backend/elfobj.c +++ b/src/ddmd/backend/elfobj.c @@ -1127,7 +1127,8 @@ void Obj::term(const char *objfilename) } #if MARS - obj_rtinit(); + if (!config.betterC) + obj_rtinit(); #endif #if SCPP diff --git a/src/ddmd/dmsc.d b/src/ddmd/dmsc.d index 4ad2ee94b870..12bc5e940073 100644 --- a/src/ddmd/dmsc.d +++ b/src/ddmd/dmsc.d @@ -55,7 +55,8 @@ void out_config_init( // 2: fake it with C symbolic debug info bool alwaysframe, // always create standard function frame bool stackstomp, // add stack stomping code - bool avx // use AVX instruction set + bool avx, // use AVX instruction set + bool betterC // implement "Better C" ); void out_config_debug( @@ -113,7 +114,8 @@ void backend_init() params.symdebug, params.alwaysframe, params.stackstomp, - params.cpu >= CPU.avx + params.cpu >= CPU.avx, + params.betterC ); debug diff --git a/src/ddmd/link.d b/src/ddmd/link.d index 0acca14e6092..29def646a75e 100644 --- a/src/ddmd/link.d +++ b/src/ddmd/link.d @@ -660,12 +660,12 @@ public int runLINK() const(char)* p = (*global.params.dllfiles)[i]; argv.push(p); } - /* Standard libraries must go after user specified libraries + /* D runtime libraries must go after user specified libraries * passed with -l. */ const(char)* libname = global.params.symdebug ? global.params.debuglibname : global.params.defaultlibname; size_t slen = strlen(libname); - if (slen) + if (!global.params.betterC && slen) { char* buf = cast(char*)malloc(3 + slen + 1); strcpy(buf, "-l"); diff --git a/test/runnable/cassert.d b/test/runnable/cassert.d index 3f766ab61301..8c7675084957 100644 --- a/test/runnable/cassert.d +++ b/test/runnable/cassert.d @@ -10,7 +10,7 @@ void test(int ij) assert(ij,"it is not zero"); } -int main() +extern (C) int main() { test(1); return 0;