From 9caa1a5aa8437e365361e23fc227afd92b1c59e6 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Fri, 1 May 2020 09:15:46 +0200 Subject: [PATCH] arc: do not unload globals when building a library [backport:1.2] (#14180) (cherry picked from commit d5fc35c968c49c6f5529624108ed327095a548c4) --- compiler/cgen.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/cgen.nim b/compiler/cgen.nim index a8045e054d..3df23b7ce0 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1999,8 +1999,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