summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2022-02-05 06:10:24 +0800
committerGitHub <noreply@github.com>2022-02-04 17:10:24 -0500
commit7b09fd70ab8154eed3738dfd86f84c5642df3cf2 (patch)
tree1fbca71b85a46d221eebe05544d2b6bd0ccbbda1
parent33bfe5b12cf771072d93d7316945f3f5e6c727ff (diff)
downloadNim-7b09fd70ab8154eed3738dfd86f84c5642df3cf2.tar.gz
undefine C symbols in JS backend [backport:1.6] (#19437)
fix #19330; fix #19059
-rw-r--r--compiler/cmdlinehelper.nim3
-rw-r--r--compiler/commands.nim5
-rw-r--r--tests/js/tcsymbol.nim6
3 files changed, 11 insertions, 3 deletions
diff --git a/compiler/cmdlinehelper.nim b/compiler/cmdlinehelper.nim
index 007dc2319..02162755c 100644
--- a/compiler/cmdlinehelper.nim
+++ b/compiler/cmdlinehelper.nim
@@ -64,7 +64,8 @@ proc loadConfigsAndProcessCmdLine*(self: NimProg, cache: IdentCache; conf: Confi
       if conf.cmd == cmdNimscript: return false
   # now process command line arguments again, because some options in the
   # command line can overwrite the config file's settings
-  extccomp.initVars(conf)
+  if conf.backend != backendJs: # bug #19059
+    extccomp.initVars(conf)
   self.processCmdLine(passCmd2, "", conf)
   if conf.cmd == cmdNone:
     rawMessage(conf, errGenerated, "command missing")
diff --git a/compiler/commands.nim b/compiler/commands.nim
index a1fa55e74..fb2907bb1 100644
--- a/compiler/commands.nim
+++ b/compiler/commands.nim
@@ -899,8 +899,9 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
     splitSwitch(conf, arg, key, val, pass, info)
     os.putEnv(key, val)
   of "cc":
-    expectArg(conf, switch, arg, pass, info)
-    setCC(conf, arg, info)
+    if conf.backend != backendJs: # bug #19330
+      expectArg(conf, switch, arg, pass, info)
+      setCC(conf, arg, info)
   of "track":
     expectArg(conf, switch, arg, pass, info)
     track(conf, arg, info)
diff --git a/tests/js/tcsymbol.nim b/tests/js/tcsymbol.nim
new file mode 100644
index 000000000..07e52b9b6
--- /dev/null
+++ b/tests/js/tcsymbol.nim
@@ -0,0 +1,6 @@
+discard """
+  matrix: "--cc:gcc; --cc:tcc"
+"""
+
+doAssert not defined(gcc)
+doAssert not defined(tcc)
\ No newline at end of file