Skip to content

Commit

Permalink
Merge pull request #6918 from WalterBright/link-betterC
Browse files Browse the repository at this point in the history
fix Issue 17521 - -betterC programs should not link in Phobos by default
merged-on-behalf-of: Martin Nowak <code@dawg.eu>
  • Loading branch information
dlang-bot committed Jun 26, 2017
2 parents 47c0f93 + 85873d9 commit 5a03f92
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/ddmd/backend/backconfig.c
Expand Up @@ -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
Expand Down Expand Up @@ -253,6 +254,8 @@ void out_config_init(
if (stackstomp)
config.flags2 |= CFG2stomp;

config.betterC = betterC;

ph_init();
block_init();

Expand Down
1 change: 1 addition & 0 deletions src/ddmd/backend/cdef.d
Expand Up @@ -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); }
Expand Down
1 change: 1 addition & 0 deletions src/ddmd/backend/cdef.h
Expand Up @@ -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();
};
Expand Down
3 changes: 2 additions & 1 deletion src/ddmd/backend/dwarf.c
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/ddmd/backend/elfobj.c
Expand Up @@ -1127,7 +1127,8 @@ void Obj::term(const char *objfilename)
}

#if MARS
obj_rtinit();
if (!config.betterC)
obj_rtinit();
#endif

#if SCPP
Expand Down
6 changes: 4 additions & 2 deletions src/ddmd/dmsc.d
Expand Up @@ -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(
Expand Down Expand Up @@ -113,7 +114,8 @@ void backend_init()
params.symdebug,
params.alwaysframe,
params.stackstomp,
params.cpu >= CPU.avx
params.cpu >= CPU.avx,
params.betterC
);

debug
Expand Down
4 changes: 2 additions & 2 deletions src/ddmd/link.d
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion test/runnable/cassert.d
Expand Up @@ -10,7 +10,7 @@ void test(int ij)
assert(ij,"it is not zero");
}

int main()
extern (C) int main()
{
test(1);
return 0;
Expand Down

0 comments on commit 5a03f92

Please sign in to comment.