Skip to content

Redirecting stderr causes cache miss #222

@torokati44

Description

@torokati44

Actual behavior: Redirecting stderr to a file causes a cache miss.
Expected behavior: Redirecting stderr does not affect ccache operation in general.
Steps to reproduce:

  • Clean and clear the ccache cache, and zero out its statistics: ccache -cCz
  • Take a small, valid C or C++ file: main.c
  • Compile it twice using ccache, once redirecting stderr into a file, and once without, in any order:
    • clang -c main.c -o main.o (where clang is ccache in disguise)
    • clang -c main.c -o main.o 2> /dev/null (or vice versa)
  • Check the ccache statistics: ccache -s
  • There are two cache misses, opposed to the expected one miss and one hit.

Additional notes:

  • Redirecting stdout does not seem to matter.
  • It occurs even if there isn't any output to stderr nor stdout in either compilation.
  • Redirecting to a regular file or /dev/null does not make a difference.
  • If stderr is redirected to /dev/null in both cases (or in neither of them), there is no problem.

ccache version: 3.3.4
compiler: clang 5.0.1 (although I feel like this is indifferent)
OS: Fedora 27 x64

Rationale:
I'm trying to run two-stage builds on Travis CI, where the first stage builds a sizable C++ project using ccache, and the second stage uses the cache to build much faster, then runs a series of tests on the built project. The compilation and the tests together would often exceed the 50 minute per-job limit of Travis CI. In the first stage I'm interested in the compiler output during compilation, in the second I'm not, hence the redirection.

Two example builds, the first works fine and the second demonstrates the issue:
https://travis-ci.org/torokati44/inet/builds/336512738
https://travis-ci.org/torokati44/inet/builds/336548982

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions