summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorParashurama <Rhagdamaziel@ymail.com>2017-02-01 08:51:24 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-02-01 08:51:24 +0100
commit2aec5b6c49b32c5541e091d8023873bc4eceac28 (patch)
tree22f877794e1d0a404940e5cda9d6f84b1d9cb88d
parent8b10609452f848a39d9c141dc96bf11d23f30eeb (diff)
downloadNim-2aec5b6c49b32c5541e091d8023873bc4eceac28.tar.gz
fixes compiler ignoring passC/passL args when setting --cc:compiler. (#5310)
This commit change the way passC/passL cmdline arg and setting in config
files are parsed.
They are added to a separate linkOptionsCmd/compileOptionsCmd and are
inserted when compile/linking command list are requested.
-rw-r--r--compiler/commands.nim4
-rw-r--r--compiler/extccomp.nim14
2 files changed, 15 insertions, 3 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim
index 61189fba1..aac740553 100644
--- a/compiler/commands.nim
+++ b/compiler/commands.nim
@@ -509,10 +509,10 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) =
     else: localError(info, errGuiConsoleOrLibExpectedButXFound, arg)
   of "passc", "t":
     expectArg(switch, arg, pass, info)
-    if pass in {passCmd2, passPP}: extccomp.addCompileOption(arg)
+    if pass in {passCmd2, passPP}: extccomp.addCompileOptionCmd(arg)
   of "passl", "l":
     expectArg(switch, arg, pass, info)
-    if pass in {passCmd2, passPP}: extccomp.addLinkOption(arg)
+    if pass in {passCmd2, passPP}: extccomp.addLinkOptionCmd(arg)
   of "cincludes":
     expectArg(switch, arg, pass, info)
     if pass in {passCmd2, passPP}: cIncludes.add arg.processPath(info)
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim
index 8ca34223b..0f283b208 100644
--- a/compiler/extccomp.nim
+++ b/compiler/extccomp.nim
@@ -392,6 +392,8 @@ type
 var
   externalToLink: TLinkedList # files to link in addition to the file
                               # we compiled
+  linkOptionsCmd: string = ""
+  compileOptionsCmd: seq[string] = @[]
   linkOptions: string = ""
   compileOptions: string = ""
   ccompilerpath: string = ""
@@ -450,6 +452,12 @@ proc addCompileOption*(option: string) =
   if strutils.find(compileOptions, option, 0) < 0:
     addOpt(compileOptions, option)
 
+proc addLinkOptionCmd*(option: string) =
+  addOpt(linkOptionsCmd, option)
+
+proc addCompileOptionCmd*(option: string) =
+  compileOptionsCmd.add(option)
+
 proc initVars*() =
   # we need to define the symbol here, because ``CC`` may have never been set!
   for i in countup(low(CC), high(CC)): undefSymbol(CC[i].name)
@@ -524,6 +532,10 @@ proc add(s: var string, many: openArray[string]) =
 
 proc cFileSpecificOptions(cfilename: string): string =
   result = compileOptions
+  for option in compileOptionsCmd:
+    if strutils.find(result, option, 0) < 0:
+      addOpt(result, option)
+
   var trunk = splitFile(cfilename).name
   if optCDebug in gGlobalOptions:
     var key = trunk & ".debug"
@@ -544,7 +556,7 @@ proc getCompileOptions: string =
   result = cFileSpecificOptions("__dummy__")
 
 proc getLinkOptions: string =
-  result = linkOptions
+  result = linkOptions & " " & linkOptionsCmd & " "
   for linkedLib in items(cLinkedLibs):
     result.add(CC[cCompiler].linkLibCmd % linkedLib.quoteShell)
   for libDir in items(cLibs):