summary refs log tree commit diff stats
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2023-05-26 18:07:37 +0300
committerGitHub <noreply@github.com>2023-05-26 17:07:37 +0200
commit1aaff9dc48337b58d5606cc18c5ba777cab1a0ba (patch)
tree1806309cd8cfbe9841cc68e3e4b524ef134f239f
parent656706026b2357a6ff195e3f509f793553e95e8a (diff)
downloadNim-1aaff9dc48337b58d5606cc18c5ba777cab1a0ba.tar.gz
fix & add test for basic hot code reloading case (#21915)
fixes #21885
-rw-r--r--compiler/cgen.nim5
-rw-r--r--testament/categories.nim1
-rw-r--r--tests/dll/nimhcr_basic.nim7
3 files changed, 12 insertions, 1 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index 8c85db2f8..b332c6cd7 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -2180,7 +2180,10 @@ proc finalCodegenActions*(graph: ModuleGraph; m: BModule; n: PNode): PNode =
 
     if m.hcrOn:
       # make sure this is pulled in (meaning hcrGetGlobal() is called for it during init)
-      cgsym(m, "programResult")
+      let sym = magicsys.getCompilerProc(m.g.graph, "programResult")
+      # ignore when not available, could be a module imported early in `system`
+      if sym != nil:
+        cgsymImpl m, sym
       if m.inHcrInitGuard:
         endBlock(m.initProc)
 
diff --git a/testament/categories.nim b/testament/categories.nim
index d554ebe34..d5964225f 100644
--- a/testament/categories.nim
+++ b/testament/categories.nim
@@ -80,6 +80,7 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string, isOrc =
   testSpec r, makeTest("tests/dll/client.nim", options & " --threads:on" & rpath, cat)
   testSpec r, makeTest("tests/dll/nimhcr_unit.nim", options & " --threads:off" & rpath, cat)
   testSpec r, makeTest("tests/dll/visibility.nim", options & " --threads:off" & rpath, cat)
+  testSpec r, makeTest("tests/dll/nimhcr_basic.nim", options & " --threads:off" & rpath, cat)
 
   if "boehm" notin options:
     # force build required - see the comments in the .nim file for more details
diff --git a/tests/dll/nimhcr_basic.nim b/tests/dll/nimhcr_basic.nim
new file mode 100644
index 000000000..340c3fc4e
--- /dev/null
+++ b/tests/dll/nimhcr_basic.nim
@@ -0,0 +1,7 @@
+discard """
+  output: '''
+Hello world
+'''
+"""
+
+echo "Hello world"