diff options
author | Khronos <39792509+Khronos31@users.noreply.github.com> | 2020-06-01 21:06:25 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-01 14:06:25 +0200 |
commit | 5900d8442c6bf41bfaab02ae877ebf23680680bb (patch) | |
tree | e07f21994898625d224ce413734578766f53f372 | |
parent | 0489e76da768502aa7bddea1cbab3bfa5f6b22a2 (diff) | |
download | Nim-5900d8442c6bf41bfaab02ae877ebf23680680bb.tar.gz |
Fix a problem with extra build commands. (#14528)
When --compileOnly is on, extraCmds are not added to JsonBuildInstructions. ``` $ echo 'echo 123'>test.nim $ nim c --debuginfo --nimcache:cache test $ ls cache test test.dSYM test.nim $ tail -n3 cache/test.json "extraCmds": ["dsymutil /Users/khronos31/src/tmp/test"], "stdinInput": false } ``` ``` $ echo 'echo 123'>test.nim $ nim c --debuginfo --nimcache:cache --compileOnly test $ nim jsonscript --nimcache:cache test $ ls cache test test.nim $ tail -n3 cache/test.json "extraCmds": [], "stdinInput": false } ```
-rw-r--r-- | compiler/extccomp.nim | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 4c5b195ab..7757a9f9d 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -767,19 +767,16 @@ template tryExceptOSErrorMessage(conf: ConfigRef; errorPrefix: string = "", body (ose.msg & " " & $ose.errorCode)) raise +proc getExtraCmds(conf: ConfigRef; output: AbsoluteFile): seq[string] = + when defined(macosx): + if optCDebug in conf.globalOptions and optGenStaticLib notin conf.globalOptions: + # if needed, add an option to skip or override location + result.add "dsymutil " & $(output).quoteShell + proc execLinkCmd(conf: ConfigRef; linkCmd: string) = tryExceptOSErrorMessage(conf, "invocation of external linker program failed."): execExternalProgram(conf, linkCmd, hintLinking) -proc maybeRunDsymutil(conf: ConfigRef; exe: AbsoluteFile) = - when defined(osx): - if optCDebug in conf.globalOptions and optGenStaticLib notin conf.globalOptions: - # if needed, add an option to skip or override location - let cmd = "dsymutil " & $(exe).quoteShell - conf.extraCmds.add cmd - tryExceptOSErrorMessage(conf, "invocation of dsymutil failed."): - execExternalProgram(conf, cmd, hintExecuting) - proc execCmdsInParallel(conf: ConfigRef; cmds: seq[string]; prettyCb: proc (idx: int)) = let runCb = proc (idx: int, p: Process) = let exitCode = p.peekExitCode @@ -850,6 +847,7 @@ proc displayProgressCC(conf: ConfigRef, path, compileCmd: string): string = proc callCCompiler*(conf: ConfigRef) = var linkCmd: string + extraCmds: seq[string] if conf.globalOptions * {optCompileOnly, optGenScript} == {optCompileOnly}: return # speed up that call if only compiling and no script shall be # generated @@ -920,6 +918,7 @@ proc callCCompiler*(conf: ConfigRef) = let mainOutput = if optGenScript notin conf.globalOptions: conf.prepareToWriteOutput else: AbsoluteFile(conf.projectName) linkCmd = getLinkCmd(conf, mainOutput, objfiles) + extraCmds = getExtraCmds(conf, mainOutput) if optCompileOnly notin conf.globalOptions: const MaxCmdLen = when defined(windows): 8_000 else: 32_000 if linkCmd.len > MaxCmdLen: @@ -929,7 +928,8 @@ proc callCCompiler*(conf: ConfigRef) = linkViaResponseFile(conf, linkCmd) else: execLinkCmd(conf, linkCmd) - maybeRunDsymutil(conf, mainOutput) + for cmd in extraCmds: + execExternalProgram(conf, cmd, hintExecuting) else: linkCmd = "" if optGenScript in conf.globalOptions: @@ -1017,7 +1017,7 @@ proc writeJsonBuildInstructions*(conf: ConfigRef) = str getLinkCmd(conf, conf.absOutFile, objfiles) lit ",\L\"extraCmds\": " - lit $(%* conf.extraCmds) + lit $(%* getExtraCmds(conf, conf.absOutFile)) lit ",\L\"stdinInput\": " lit $(%* conf.projectIsStdin) |