DLL fixes for windows; fixes #175
This commit is contained in:
parent
674c05f426
commit
1d065b601c
4 changed files with 16 additions and 11 deletions
|
|
@ -861,7 +861,8 @@ proc genMainProc(m: BModule) =
|
||||||
CommonMainBody & "}$n"
|
CommonMainBody & "}$n"
|
||||||
WinCDllMain =
|
WinCDllMain =
|
||||||
"BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, $n" &
|
"BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, $n" &
|
||||||
" LPVOID lpvReserved) {$n" & "\tNimMain();$n" &
|
" LPVOID lpvReserved) {$n" &
|
||||||
|
"\tif(fwdreason == DLL_PROCESS_ATTACH) NimMain();$n" &
|
||||||
"\treturn 1;$n" & "}$n"
|
"\treturn 1;$n" & "}$n"
|
||||||
PosixNimDllMain = WinNimDllMain
|
PosixNimDllMain = WinNimDllMain
|
||||||
PosixCDllMain =
|
PosixCDllMain =
|
||||||
|
|
|
||||||
|
|
@ -215,12 +215,18 @@ proc processDynLib(c: PContext, n: PNode, sym: PSym) =
|
||||||
if (sym == nil) or (sym.kind == skModule):
|
if (sym == nil) or (sym.kind == skModule):
|
||||||
POptionEntry(c.optionStack.tail).dynlib = getLib(c, libDynamic,
|
POptionEntry(c.optionStack.tail).dynlib = getLib(c, libDynamic,
|
||||||
expectDynlibNode(c, n))
|
expectDynlibNode(c, n))
|
||||||
elif n.kind == nkExprColonExpr:
|
else:
|
||||||
|
if n.kind == nkExprColonExpr:
|
||||||
var lib = getLib(c, libDynamic, expectDynlibNode(c, n))
|
var lib = getLib(c, libDynamic, expectDynlibNode(c, n))
|
||||||
addToLib(lib, sym)
|
addToLib(lib, sym)
|
||||||
incl(sym.loc.flags, lfDynamicLib)
|
incl(sym.loc.flags, lfDynamicLib)
|
||||||
else:
|
else:
|
||||||
incl(sym.loc.flags, lfExportLib)
|
incl(sym.loc.flags, lfExportLib)
|
||||||
|
# since we'll be loading the dynlib symbols dynamically, we must use
|
||||||
|
# a calling convention that doesn't introduce custom name mangling
|
||||||
|
# cdecl is the default - the use can override this explicitly
|
||||||
|
if sym.typ.callConv == ccDefault:
|
||||||
|
sym.typ.callConv = ccCDecl
|
||||||
|
|
||||||
proc processNote(c: PContext, n: PNode) =
|
proc processNote(c: PContext, n: PNode) =
|
||||||
if (n.kind == nkExprColonExpr) and (sonsLen(n) == 2) and
|
if (n.kind == nkExprColonExpr) and (sonsLen(n) == 2) and
|
||||||
|
|
|
||||||
|
|
@ -1935,7 +1935,6 @@ when not defined(EcmaScript) and not defined(NimrodVM):
|
||||||
include "system/syslocks"
|
include "system/syslocks"
|
||||||
include "system/threads"
|
include "system/threads"
|
||||||
elif not defined(nogc):
|
elif not defined(nogc):
|
||||||
initStackBottom()
|
|
||||||
initGC()
|
initGC()
|
||||||
|
|
||||||
proc setControlCHook*(hook: proc () {.noconv.})
|
proc setControlCHook*(hook: proc () {.noconv.})
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,6 @@ when not defined(useNimRtl):
|
||||||
when not useStackMaskHack:
|
when not useStackMaskHack:
|
||||||
var mainThread: TGcThread
|
var mainThread: TGcThread
|
||||||
ThreadVarSetValue(globalsSlot, addr(mainThread))
|
ThreadVarSetValue(globalsSlot, addr(mainThread))
|
||||||
initStackBottom()
|
|
||||||
initGC()
|
initGC()
|
||||||
|
|
||||||
when emulatedThreadVars:
|
when emulatedThreadVars:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue