Always cache colored diagnostics; strip color codes from ccache's stderr output as appropriate#596
Conversation
|
@whitslack: See my comment here: #224 (comment) |
54e0c70 to
2fa45a3
Compare
This function works like copy_fd but strips out selected ANSI CSI escape sequences. The intention is for this function to be called instead of copy_fd when copying cached compiler stderr output to ccache's stderr when the invoking command specifies -fno-diagnostics-color or -fdiagnostics-color=never or ccache's stderr is not a terminal and the invoking command does not specify -fdiagnostics-color or -fdiagnostics-color=always.
Testing -f fails when the file is not a regular file, such as when using Bash's process substitution.
9cb24d4 to
d19cd72
Compare
Merge remote-tracking branch 'origin/master' into cache-colored-diagnostics
Quoting Joel Rosdahl: > I intend to relatively soon refactor the code related to stderr > handling so that the stderr data read from the aggregated result file > won't hit the file system as a temporary file. Therefore, stripping > color codes from data read explicitly from a file descriptor does not > quite fit my plans. See: ccache#596 (comment)
Per request by Joel Rosdahl. See: ccache#596 (comment) Co-authored-by: Joel Rosdahl <joel@rosdahl.net>
The --log-out option was added to script(1) in util-linux 2.35. Since some distributions are still running older versions, remove the use of the option from the color_diagnostics test suite. Equivalent functionality is obtained simply by passing the name of the output file without using the --log-out option. See: ccache#596 (comment)
According to Joel Rosdahl, the intention in 3eb2483 was not to support regular expressions. This commit makes expect_file_{,not_}contains perform literal substring matching only. See: ccache#596 (comment)
“stderr” is a macro in MinGW and cannot be used as a variable name.
If the user running the test suite sets GCC_COLORS in their shell rc file the color_diagnostics tests fail. Fix this by explicitly unsetting GCC_COLORS where needed.
|
Good work. There are still some CI test failures and I've fixed one of them in e13badd. I also fixed an issue I had locally in b1bd4b7. Feel free to rework them if you like. There's however one CI test issue left, a unit test segfault in the "Build on Linux with native Clang" job. Disabling the unit test makes the ccache binary segfault in the bash test suite later. There seems to be some bad interaction between Clang 7.0.0, I modified the build to run the unit test with Valgrind to get a backtrace. It looks like this: https://travis-ci.org/github/jrosdahl/ccache/builds/695447083#L470 (followed by a crash further down). Rewriting The CI setup currently uses the Ubuntu 16.04. I spent some time to upgrade it (not yet on master) to Ubuntu 18.04 (I guess it's time for that anyway) and that fixes the Clang build, but doing so leaves the Ubuntu 16.04 Clang issue unsolved, which feels slightly uncomfortable. Here are some ways forward:
@whitslack: Any ideas or opinions on this? |
|
I've updated the CI environment to Ubuntu 18.04 on master now so I'll merge this. |
This fixes the Clang-Format CI job.
|
Thanks! |
@jrosdahl: Moot at this point, but my opinion is that neither runtime efficiency nor code legibility/maintainability should be sacrificed to cater to deficient compilers that are obsolete by several major releases. I'm glad you went with upgrading your CI environment. I doubt Ubuntu 16.04 will ever package ccache 4.0 anyway. |
|
To clarify, this is not about dropping support for Ubuntu 16.04 (which comes with Clang 3.8) or Clang 7 (which is not even 2 years old). It's about if the Clang 7 installation on Travis-CI's Ubuntu 16.04 is buggy or if there's a lurking bug in ccache (or On the subject of portability, I want to continue supporting CentOS 7 which has GCC 4.8.5 which I now realize doesn't implement |
The implementation from ccache#596 uses the spelling “command-line” instead of “command line” (which is what is actually emitted by GCC and specified in ccache#224).
The CCACHE_PREFIX test logs execution of prefixes. After 1c6ccf1 (ccache#596) the compiler and prefixes can be run twice if GCC doesn’t support -fdiagnostics-color and the test case is not prepared for that. Fix this by letting prefix-a truncate the log file.
This pull request resolves #223 and resolves #224.
-fdiagnostics-color} {Clang:-fcolor-diagnostics} to the real compiler, except…run_second_cppis true.unrecognized command-line optionand-fdiagnostics-color, then remove the color option and retry the command. Also, remember the failure and omit the color option from any subsequent GCC invocation.}-fno-diagnostics-coloror-fdiagnostics-color=never} {Clang:-fno-color-diagnostics} or ccache's stderr is not a TTY and the invoking command did not specify {GCC:-fdiagnostics-coloror-fdiagnostics-color=always} {Clang:-fcolor-diagnostics}, then use the aforementioned new function to strip ANSI CSI actionsKandm.