From 366b9a7e4a067cece3b1215de7fb4dffc703e88a Mon Sep 17 00:00:00 2001 From: Tomohiro Date: Thu, 2 Jul 2020 20:20:34 +0900 Subject: Fix #12745 (#14879) --- compiler/extccomp.nim | 12 +----------- compiler/main.nim | 5 +++++ 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'compiler') diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 6feb68f81..7d5df0906 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -281,9 +281,6 @@ const hExt* = ".h" -proc libNameTmpl(conf: ConfigRef): string {.inline.} = - result = if conf.target.targetOS == osWindows: "$1.lib" else: "lib$1.a" - proc nameToCC*(name: string): TSystemCC = ## Returns the kind of compiler referred to by `name`, or ccNone ## if the name doesn't refer to any known compiler. @@ -663,14 +660,7 @@ proc addExternalFileToCompile*(conf: ConfigRef; filename: AbsoluteFile) = proc getLinkCmd(conf: ConfigRef; output: AbsoluteFile, objfiles: string, isDllBuild: bool): string = if optGenStaticLib in conf.globalOptions: - var libname: string - if not conf.outFile.isEmpty: - libname = conf.outFile.string.expandTilde - if not libname.isAbsolute(): - libname = getCurrentDir() / libname - else: - libname = (libNameTmpl(conf) % splitFile(conf.projectName).name) - result = CC[conf.cCompiler].buildLib % ["libfile", quoteShell(libname), + result = CC[conf.cCompiler].buildLib % ["libfile", quoteShell(output), "objfiles", objfiles] else: var linkerExe = getConfigVar(conf, conf.cCompiler, ".linkerexe") diff --git a/compiler/main.nim b/compiler/main.nim index e498dc6b9..25a42300f 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -67,10 +67,15 @@ when not defined(leanCompiler): finishDoc2Pass(graph.config.projectName) proc setOutFile(conf: ConfigRef) = + proc libNameTmpl(conf: ConfigRef): string {.inline.} = + result = if conf.target.targetOS == osWindows: "$1.lib" else: "lib$1.a" + if conf.outFile.isEmpty: let base = conf.projectName let targetName = if optGenDynLib in conf.globalOptions: platform.OS[conf.target.targetOS].dllFrmt % base + elif optGenStaticLib in conf.globalOptions: + libNameTmpl(conf) % base else: base & platform.OS[conf.target.targetOS].exeExt conf.outFile = RelativeFile targetName -- cgit 1.4.1-2-gfad0