summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2021-03-22 18:24:28 -0700
committerGitHub <noreply@github.com>2021-03-22 18:24:28 -0700
commita75c4b70e86705c98a4006aa8475a10a0ebf94ec (patch)
treeca43b7357ba3a9f01c54c1942a645d2cedbe9a89
parente5873b3a9300897443f0f2e2db128e3463089003 (diff)
downloadNim-a75c4b70e86705c98a4006aa8475a10a0ebf94ec.tar.gz
hint:cc goes to stderr (like all other hints) instead of stdout (#17465)
Co-authored-by: ee7 <45465154+ee7@users.noreply.github.com>
-rw-r--r--changelog.md1
-rw-r--r--compiler/extccomp.nim15
2 files changed, 8 insertions, 8 deletions
diff --git a/changelog.md b/changelog.md
index cc4f54fe0..00fc970bf 100644
--- a/changelog.md
+++ b/changelog.md
@@ -301,6 +301,7 @@
 
 - Added `unsafeIsolate` and `extract` to `std/isolation`.
 
+- `--hint:CC` now goes to stderr (like all other hints) instead of stdout.
 
 
 ## Tool changes
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim
index e95ed893b..e0fd5e206 100644
--- a/compiler/extccomp.nim
+++ b/compiler/extccomp.nim
@@ -281,6 +281,11 @@ const
 
   hExt* = ".h"
 
+template writePrettyCmdsStderr(cmd) =
+  if cmd.len > 0:
+    flushDot(conf)
+    stderr.writeLine(cmd)
+
 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.
@@ -848,11 +853,7 @@ proc callCCompiler*(conf: ConfigRef) =
   var script: Rope = nil
   var cmds: TStringSeq
   var prettyCmds: TStringSeq
-  let prettyCb = proc (idx: int) =
-    if prettyCmds[idx].len > 0:
-      flushDot(conf)
-      # xxx should probably use stderr like other compiler messages, not stdout
-      echo prettyCmds[idx]
+  let prettyCb = proc (idx: int) = writePrettyCmdsStderr(prettyCmds[idx])
 
   for idx, it in conf.toCompile:
     # call the C compiler for the .c file:
@@ -1108,9 +1109,7 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: AbsoluteFile) =
     doAssert toCompile.kind == JArray
     var cmds: TStringSeq
     var prettyCmds: TStringSeq
-    let prettyCb = proc (idx: int) =
-      if prettyCmds[idx].len > 0: echo prettyCmds[idx]
-
+    let prettyCb = proc (idx: int) = writePrettyCmdsStderr(prettyCmds[idx])
     for c in toCompile:
       doAssert c.kind == JArray
       doAssert c.len >= 2