From 2aec5b6c49b32c5541e091d8023873bc4eceac28 Mon Sep 17 00:00:00 2001 From: Parashurama Date: Wed, 1 Feb 2017 08:51:24 +0100 Subject: 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. --- compiler/commands.nim | 4 ++-- compiler/extccomp.nim | 14 +++++++++++++- 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): -- cgit 1.4.1-2-gfad0