-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable colors when compiling foreign stubs. #3263
Comments
Dune is parsing the ansi sequences in the output of commands and re-printing them. In this case it seems that it doesn't understand the output of G++. Can you pipe the output of G++ into |
Sorry, I should have added means to reproduce the bug. In this particular case, I get a compilation error when enabling C++17. Theses are the steps I took, but one could craft a smaller example. git clone git@github.com:AltGr/ocaml-mccs.git
cd ocaml-mccs
git checkout 93cd3b25878c1a2bde5cab0a5c85a376936dc183
patch -p1 << EOF
diff --git a/src/dune b/src/dune
index dde1111..b495213 100644
--- a/src/dune
+++ b/src/dune
@@ -9,6 +9,7 @@
:standard
-I
.
+ -std=c++17
(:include cxxflags.sexp))
(c_library_flags
:standard
EOF
dune build # output is correct, but uncoloured
patch -p1 << EOF
diff --git a/src/dune b/src/dune
index b495213..ff4c528 100644
--- a/src/dune
+++ b/src/dune
@@ -10,6 +10,7 @@
-I
.
-std=c++17
+ -fdiagnostics-color=always
(:include cxxflags.sexp))
(c_library_flags
:standard
EOF
dune build # output is not correct, and uncoloured
dune build 2>&1 | hexdump -C I have the feeling that the two last outputs differ, maybe it has something to do with the piping? |
Piping the output of |
Ran into this issue again, and you were right, GCC emits a special ANSI code that Dune does not seem to understand. clang doesn't emit this code. From https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-VT52-Mode:
|
GCC emits coloured output when it's printing to a tty, and coloured output is disabled e.g., when the output is piped. When GCC is called by Dune, it doesn't output ANSI sequences. However, that behaviour can be forced with the `-fdiagnostics-color=always` flag. GCC has the particularity that after each color sequence, it will also emit a ESC K "erase from the cursor the end of line". Dune did not support this sequence, and this messes up the output. The sequence does not seem important; clang doesn't use it, and it clearing the line means that it would already have been written to, which seems unlikely. So, this patch simply ignores that sequence. Closes ocaml#3263. Signed-off-by: Antonin Décimo <antonin@tarides.com>
GCC emits coloured output when it's printing to a tty, and coloured output is disabled e.g., when the output is piped. When GCC is called by Dune, it doesn't output ANSI sequences. However, that behaviour can be forced with the `-fdiagnostics-color=always` flag. GCC has the particularity that after each color sequence, it will also emit a ESC K "erase from the cursor the end of line". Dune did not support this sequence, and this messes up the output. The sequence does not seem important; clang doesn't use it, and it clearing the line means that it would already have been written to, which seems unlikely. So, this patch simply ignores that sequence. Closes ocaml#3263. Signed-off-by: Antonin Décimo <antonin@tarides.com>
GCC emits coloured output when it's printing to a tty, and coloured output is disabled e.g., when the output is piped. When GCC is called by Dune, it doesn't output ANSI sequences. However, that behaviour can be forced with the `-fdiagnostics-color=always` flag. GCC has the particularity that after each color sequence, it will also emit a ESC K "erase from the cursor the end of line". Dune did not support this sequence, and this messes up the output. The sequence does not seem important; clang doesn't use it, and it clearing the line means that it would already have been written to, which seems unlikely. So, this patch simply ignores that sequence. Closes ocaml#3263. Signed-off-by: Antonin Décimo <antonin@tarides.com>
GCC emits coloured output when it's printing to a tty, and coloured output is disabled e.g., when the output is piped. When GCC is called by Dune, it doesn't output ANSI sequences. However, that behaviour can be forced with the `-fdiagnostics-color=always` flag. GCC has the particularity that after each color sequence, it will also emit a ESC K "erase from the cursor the end of line". Dune did not support this sequence, and this messes up the output. The sequence does not seem important; clang doesn't use it, and it clearing the line means that it would already have been written to, which seems unlikely. So, this patch simply ignores that sequence. Closes ocaml#3263. Signed-off-by: Antonin Décimo <antonin@tarides.com>
GCC emits coloured output when it's printing to a tty, and coloured output is disabled e.g., when the output is piped. When GCC is called by Dune, it doesn't output ANSI sequences. However, that behaviour can be forced with the `-fdiagnostics-color=always` flag. GCC has the particularity that after each color sequence, it will also emit a ESC K "erase from the cursor the end of line". Dune did not support this sequence, and this messes up the output. The sequence does not seem important; clang doesn't use it, and it clearing the line means that it would already have been written to, which seems unlikely. So, this patch simply ignores that sequence. Closes ocaml#3263. Signed-off-by: Antonin Décimo <antonin@tarides.com>
GCC emits coloured output when it's printing to a tty, and coloured output is disabled e.g., when the output is piped. When GCC is called by Dune, it doesn't output ANSI sequences. However, that behaviour can be forced with the `-fdiagnostics-color=always` flag. GCC has the particularity that after each color sequence, it will also emit a ESC K "erase from the cursor the end of line". Dune did not support this sequence, and this messes up the output. The sequence does not seem important; clang doesn't use it, and it clearing the line means that it would already have been written to, which seems unlikely. So, this patch simply ignores that sequence. Closes ocaml#3263. Signed-off-by: Antonin Décimo <antonin@tarides.com>
GCC emits coloured output when it's printing to a tty, and coloured output is disabled e.g., when the output is piped. When GCC is called by Dune, it doesn't output ANSI sequences. However, that behaviour can be forced with the `-fdiagnostics-color=always` flag. GCC has the particularity that after each color sequence, it will also emit a ESC K "erase from the cursor the end of line". Dune did not support this sequence, and this messes up the output. The sequence does not seem important; clang doesn't use it, and it clearing the line means that it would already have been written to, which seems unlikely. So, this patch simply ignores that sequence. Closes ocaml#3263. Signed-off-by: Antonin Décimo <antonin@tarides.com>
GCC emits coloured output when it's printing to a tty, and coloured output is disabled e.g., when the output is piped. When GCC is called by Dune, it doesn't output ANSI sequences. However, that behaviour can be forced with the `-fdiagnostics-color=always` flag. GCC has the particularity that after each color sequence, it will also emit a ESC K "erase from the cursor the end of line". Dune did not support this sequence, and this messes up the output. The sequence does not seem important; clang doesn't use it, and it clearing the line means that it would already have been written to, which seems unlikely. So, this patch simply ignores that sequence. Closes ocaml#3263. Signed-off-by: Antonin Décimo <antonin@tarides.com>
Hi!
I’m compiling C++ foreign stubs, and there are errors in it. I noticed that the G++ output doesn’t have colors, so I added the
-fdiagnostics-color=always
of G++ flag in the dune configuration. However, ansi escape codes are not interpreted and are outputted raw (the output is also messed up):I’d suggest to find a work-around to let processes in foreign stubs output ansi escape code that are correctly interpreted by the terminal, especially when using the
--verbose
option of Dune.The text was updated successfully, but these errors were encountered: