summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2019-09-08 10:31:34 +0200
committerAraq <rumpf_a@web.de>2019-09-08 13:08:41 +0200
commit3255b55266800549ce21ce317afccf4f98a2f7af (patch)
tree202443389b2915dc9c8d6b7a09aaf87ed0909cfd
parent8362d92e47cb3dda451829223a28a77947f1f68d (diff)
downloadNim-3255b55266800549ce21ce317afccf4f98a2f7af.tar.gz
fixes #11675
-rw-r--r--compiler/options.nim2
-rw-r--r--compiler/scriptconfig.nim14
2 files changed, 15 insertions, 1 deletions
diff --git a/compiler/options.nim b/compiler/options.nim
index 1b9bbb38f..5c7513f6b 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -110,7 +110,7 @@ type
     cmdJsonScript             # compile a .json build file
   TStringSeq* = seq[string]
   TGCMode* = enum             # the selected GC
-    gcNone, gcBoehm, gcRegions, gcMarkAndSweep, gcDestructors,
+    gcUnselected, gcNone, gcBoehm, gcRegions, gcMarkAndSweep, gcDestructors,
     gcRefc, gcV2, gcGo
     # gcRefc and the GCs that follow it use a write barrier,
     # as far as usesWriteBarrier() is concerned
diff --git a/compiler/scriptconfig.nim b/compiler/scriptconfig.nim
index 2aca43b2b..2dcac5666 100644
--- a/compiler/scriptconfig.nim
+++ b/compiler/scriptconfig.nim
@@ -214,6 +214,12 @@ proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
 
   conf.searchPaths.add(conf.libpath)
 
+  let oldGlobalOptions = conf.globalOptions
+  let oldSelectedGC = conf.selectedGC
+  undefSymbol(conf.symbols, "nimv2")
+  conf.globalOptions.excl optNimV2
+  conf.selectedGC = gcUnselected
+
   var m = graph.makeModule(scriptName)
   incl(m.flags, sfMainModule)
   graph.vm = setupVM(m, cache, scriptName.string, graph)
@@ -221,6 +227,14 @@ proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
   graph.compileSystemModule() # TODO: see why this unsets hintConf in conf.notes
   discard graph.processModule(m, llStreamOpen(scriptName, fmRead))
 
+  # watch out, "newruntime" can be set within NimScript itself and then we need
+  # to remember this:
+  if optNimV2 in oldGlobalOptions:
+    conf.globalOptions.incl optNimV2
+    defineSymbol(conf.symbols, "nimv2")
+  if conf.selectedGC == gcUnselected:
+    conf.selectedGC = oldSelectedGC
+
   # ensure we load 'system.nim' again for the real non-config stuff!
   resetSystemArtifacts(graph)
   # do not remove the defined symbols