mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
prefix NimDestroyGlobals with nimMainPrefix (#24493)
ref https://github.com/nim-lang/Nim/issues/24471
---------
Co-authored-by: metagn <metagngn@gmail.com>
(cherry picked from commit 3bee04d9f3)
This commit is contained in:
@@ -2246,12 +2246,13 @@ proc updateCachedModule(m: BModule) =
|
||||
addFileToCompile(m.config, cf)
|
||||
|
||||
proc generateLibraryDestroyGlobals(graph: ModuleGraph; m: BModule; body: PNode; isDynlib: bool): PSym =
|
||||
let procname = getIdent(graph.cache, "NimDestroyGlobals")
|
||||
let prefixedName = m.config.nimMainPrefix & "NimDestroyGlobals"
|
||||
let procname = getIdent(graph.cache, prefixedName)
|
||||
result = newSym(skProc, procname, m.idgen, m.module.owner, m.module.info)
|
||||
result.typ = newProcType(m.module.info, m.idgen, m.module.owner)
|
||||
result.typ.callConv = ccCDecl
|
||||
incl result.flags, sfExportc
|
||||
result.loc.snippet = "NimDestroyGlobals"
|
||||
result.loc.snippet = prefixedName
|
||||
if isDynlib:
|
||||
incl(result.loc.flags, lfExportLib)
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ which will likely make your program crash at runtime.
|
||||
The name `NimMain` can be influenced via the `--nimMainPrefix:prefix` switch.
|
||||
Use `--nimMainPrefix:MyLib` and the function to call is named `MyLibNimMain`.
|
||||
|
||||
When compiling to static or dynamic libraries, they don't call destructors of global variables as normal Nim programs would do. A C API `NimDestroyGlobals` is provided to call these global destructors.
|
||||
When compiling to static or dynamic libraries, they don't call destructors of global variables as normal Nim programs would do. A C API `NimDestroyGlobals` is provided to call these global destructors. It is influenced by the `--nimMainPrefix:prefix` switch, too.
|
||||
|
||||
|
||||
### Nim invocation example from C
|
||||
|
||||
Reference in New Issue
Block a user