From 89daebfad18df28d9324590a54d255ca72c86ad7 Mon Sep 17 00:00:00 2001 From: Andrii Riabushenko Date: Wed, 8 Jan 2020 22:28:41 +0000 Subject: [PATCH 1/3] pass platform only if vccexe is used --- compiler/extccomp.nim | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index de6c0ca3b5c88..7fb73d5f067dd 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -558,15 +558,13 @@ proc getCompileOptions(conf: ConfigRef): string = proc vccplatform(conf: ConfigRef): string = # VCC specific but preferable over the config hacks people # had to do before, see #11306 - case conf.target.targetCPU - of cpuI386: - result = " --platform:x86" - of cpuArm: - result = " --platform:arm" - of cpuAmd64: - result = " --platform:amd64" - else: - result = "" + let exe = getConfigVar(conf, conf.cCompiler, ".exe") + if exe.len == 0 or "vccexe" in exe: + result = case conf.target.targetCPU + of cpuI386: " --platform:x86" + of cpuArm: " --platform:arm" + of cpuAmd64: " --platform:amd64" + else: "" proc getLinkOptions(conf: ConfigRef): string = result = conf.linkOptions & " " & conf.linkOptionsCmd & " " @@ -596,7 +594,7 @@ proc getLinkerExe(conf: ConfigRef; compiler: TSystemCC): string = proc getCompileCFileCmd*(conf: ConfigRef; cfile: Cfile, isMainFile = false; produceOutput = false): string = - var c = conf.cCompiler + let c = conf.cCompiler # We produce files like module.nim.cpp, so the absolute Nim filename is not # cfile.name but `cfile.cname.changeFileExt("")`: var options = cFileSpecificOptions(conf, cfile.nimname, cfile.cname.changeFileExt("").string) From 5a433b7984423d84e8ed70b5efb6311029b5ae01 Mon Sep 17 00:00:00 2001 From: Andrii Riabushenko Date: Wed, 8 Jan 2020 22:34:48 +0000 Subject: [PATCH 2/3] fix --- compiler/extccomp.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 7fb73d5f067dd..63b6b6f99ead0 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -559,7 +559,7 @@ proc vccplatform(conf: ConfigRef): string = # VCC specific but preferable over the config hacks people # had to do before, see #11306 let exe = getConfigVar(conf, conf.cCompiler, ".exe") - if exe.len == 0 or "vccexe" in exe: + if "vccexe" in exe: result = case conf.target.targetCPU of cpuI386: " --platform:x86" of cpuArm: " --platform:arm" From e8cf09118f300a9e369a2befd90e0a46c7f542da Mon Sep 17 00:00:00 2001 From: Andrii Riabushenko Date: Thu, 9 Jan 2020 08:55:11 +0000 Subject: [PATCH 3/3] fixes #12297 --- compiler/extccomp.nim | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 63b6b6f99ead0..0db97ef9f329c 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -558,13 +558,14 @@ proc getCompileOptions(conf: ConfigRef): string = proc vccplatform(conf: ConfigRef): string = # VCC specific but preferable over the config hacks people # had to do before, see #11306 - let exe = getConfigVar(conf, conf.cCompiler, ".exe") - if "vccexe" in exe: - result = case conf.target.targetCPU - of cpuI386: " --platform:x86" - of cpuArm: " --platform:arm" - of cpuAmd64: " --platform:amd64" - else: "" + if conf.cCompiler == ccVcc: + let exe = getConfigVar(conf, conf.cCompiler, ".exe") + if "vccexe.exe" == extractFilename(exe): + result = case conf.target.targetCPU + of cpuI386: " --platform:x86" + of cpuArm: " --platform:arm" + of cpuAmd64: " --platform:amd64" + else: "" proc getLinkOptions(conf: ConfigRef): string = result = conf.linkOptions & " " & conf.linkOptionsCmd & " "