Make main functions static so they are visible only within main module
This commit is contained in:
parent
eec239e851
commit
2c904039fa
1 changed files with 14 additions and 7 deletions
|
|
@ -953,13 +953,13 @@ proc genMainProc(m: BModule) =
|
|||
# prevents inlining of the NimMainInner function and dependent
|
||||
# functions, which might otherwise merge their stack frames.
|
||||
PreMainBody =
|
||||
"void PreMainInner(void) {$N" &
|
||||
"static void PreMainInner(void) {$N" &
|
||||
"\tsystemInit000();$N" &
|
||||
"$1" &
|
||||
"$2" &
|
||||
"$3" &
|
||||
"}$N$N" &
|
||||
"void PreMain(void) {$N" &
|
||||
"static void PreMain(void) {$N" &
|
||||
"\tvoid (*volatile inner)(void);$N" &
|
||||
"\tsystemDatInit000();$N" &
|
||||
"\tinner = PreMainInner;$N" &
|
||||
|
|
@ -973,12 +973,12 @@ proc genMainProc(m: BModule) =
|
|||
MainProcsWithResult =
|
||||
MainProcs & "\treturn nim_program_result;$N"
|
||||
|
||||
NimMainInner = "N_CDECL(void, NimMainInner)(void) {$N" &
|
||||
NimMainInner = "N_CDECL(static void, NimMainInner)(void) {$N" &
|
||||
"$1" &
|
||||
"}$N$N"
|
||||
|
||||
NimMainProc =
|
||||
"N_CDECL(void, NimMain)(void) {$N" &
|
||||
"N_CDECL(static void, NimMain)(void) {$N" &
|
||||
"\tvoid (*volatile inner)(void);$N" &
|
||||
"\tPreMain();$N" &
|
||||
"\tinner = NimMainInner;$N" &
|
||||
|
|
@ -1026,7 +1026,7 @@ proc genMainProc(m: BModule) =
|
|||
PosixNimDllMain = WinNimDllMain
|
||||
|
||||
PosixCDllMain =
|
||||
"void NIM_POSIX_INIT NimMainInit(void) {$N" &
|
||||
"static void NIM_POSIX_INIT NimMainInit(void) {$N" &
|
||||
MainProcs &
|
||||
"}$N$N"
|
||||
|
||||
|
|
@ -1117,7 +1117,10 @@ proc registerModuleToMain(g: BModuleList; m: PSym) =
|
|||
var
|
||||
init = m.getInitName
|
||||
datInit = m.getDatInitName
|
||||
addf(g.mainModProcs, "N_LIB_PRIVATE N_NIMCALL(void, $1)(void);$N", [init])
|
||||
if sfMainModule in m.flags:
|
||||
addf(g.mainModProcs, "N_LIB_PRIVATE N_NIMCALL(static void, $1)(void);$N", [init])
|
||||
else:
|
||||
addf(g.mainModProcs, "N_LIB_PRIVATE N_NIMCALL(void, $1)(void);$N", [init])
|
||||
addf(g.mainModProcs, "N_LIB_PRIVATE N_NIMCALL(void, $1)(void);$N", [datInit])
|
||||
if sfSystemModule notin m.flags:
|
||||
addf(g.mainDatInit, "\t$1();$N", [datInit])
|
||||
|
|
@ -1129,7 +1132,11 @@ proc registerModuleToMain(g: BModuleList; m: PSym) =
|
|||
|
||||
proc genInitCode(m: BModule) =
|
||||
var initname = getInitName(m.module)
|
||||
var prc = "N_LIB_PRIVATE N_NIMCALL(void, $1)(void) {$N" % [initname]
|
||||
var prc: Rope
|
||||
if sfMainModule in m.module.flags:
|
||||
prc = "N_LIB_PRIVATE N_NIMCALL(static void, $1)(void) {$N" % [initname]
|
||||
else:
|
||||
prc = "N_LIB_PRIVATE N_NIMCALL(void, $1)(void) {$N" % [initname]
|
||||
if m.typeNodes > 0:
|
||||
appcg(m, m.s[cfsTypeInit1], "static #TNimNode $1[$2];$n",
|
||||
[m.typeNodesName, rope(m.typeNodes)])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue