summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-05-01 09:15:46 +0200
committerGitHub <noreply@github.com>2020-05-01 09:15:46 +0200
commitd5fc35c968c49c6f5529624108ed327095a548c4 (patch)
treefc489a57030f3308149346bea66f051ac0195c59 /compiler
parent33e9ac7cd3796e26ea95bb755f9a732a24366161 (diff)
downloadNim-d5fc35c968c49c6f5529624108ed327095a548c4.tar.gz
arc: do not unload globals when building a library [backport:1.2] (#14180)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/cgen.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index 274f01ad7..a5ee6c7ca 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -2019,8 +2019,9 @@ proc myClose(graph: ModuleGraph; b: PPassContext, n: PNode): PNode =
     if m.config.exc == excGoto and getCompilerProc(graph, "nimTestErrorFlag") != nil:
       discard cgsym(m, "nimTestErrorFlag")
 
-    for i in countdown(high(graph.globalDestructors), 0):
-      n.add graph.globalDestructors[i]
+    if {optGenStaticLib, optGenDynLib} * m.config.globalOptions == {}:
+      for i in countdown(high(graph.globalDestructors), 0):
+        n.add graph.globalDestructors[i]
   if passes.skipCodegen(m.config, n): return
   if moduleHasChanged(graph, m.module):
     # if the module is cached, we don't regenerate the main proc