Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>The Short Answer</h2> <p>Without patching <code>colorgcc.pl</code> itself, the easiest way to fix this is to write yourself a simple wrapper script for each command, calling <code>ccache</code> with the appropriate arguments for that command, and passing along the arguments the script received (effectively <a href="http://en.wikipedia.org/wiki/Currying" rel="nofollow noreferrer">currying</a> the call to <code>ccache</code>.)</p> <p>E.g., for <strong>gcc</strong>:</p> <ul> <li><p><strong>/usr/local/bin/ccache-gcc.sh:</strong></p> <pre><code>#!/bin/bash ccache /usr/bin/gcc "$@" </code></pre></li> <li><p><strong>~/.colorgcc:</strong></p> <pre><code>gcc: /usr/local/bin/ccache-gcc.sh </code></pre></li> </ul> <p>and for <strong>g++</strong>:</p> <ul> <li><p><strong>/usr/local/bin/ccache-g++.sh:</strong></p> <pre><code>#!/bin/bash ccache /usr/bin/g++ "$@" </code></pre></li> <li><p><strong>~/.colorgcc:</strong></p> <pre><code>gcc: /usr/local/bin/ccache-g++.sh </code></pre></li> </ul> <p>There are ways to clean this up so that you only use a single script, with symlinks for each variant, but those are beyond the scope of this answer, and I leave them to you as an excercise :-)</p> <h2>The Long Answer</h2> <p>The problem is that the script treats everything to the right of the colon in the prefs file as the "command" passed to exec, not as the "command" and extra "arguments". I.e., in your case, the script ends up trying to do this:</p> <ul> <li><p><em>Incorrect:</em></p> <pre><code>exec "ccache /usr/bin/g++" "--version" </code></pre> <p>(i.e., "<strong>ccache /usr/bin/g++</strong>" is a single argument.)</p></li> </ul> <p>But it should be doing this:</p> <ul> <li><p><em>Correct:</em></p> <pre><code>exec "ccache" "/usr/bin/g++" "--version" </code></pre> <p>(i.e., "<strong>ccache</strong>" and "<strong>/usr/bin/g++</strong>" are <em>two separate</em> arguments.)</p></li> </ul> <p>Perl's <code>exec</code> ultimately calls <code>execvp</code>, after possibly applying some "do what I mean" logic to its arguments. <code>execvp</code> then does some DWIM of its own. Perl's <code>exec</code> pre-processing, which splits up a single argument string into the multiple arguments <code>execvp</code> expects, only kicks in when <code>exec</code> receives a single argument. In <code>colorgcc.pl</code>, the call to <code>exec</code> looks like this (roughly):</p> <pre><code>exec "${program}" @ARGV </code></pre> <p>where <strong><code>${program}</code></strong> comes from your configuration (or the defaults), and <strong><code>@ARGV</code></strong> is the list of arguments you passed when you (indirectly) invoked <code>colorgcc.pl</code>. In your case, <strong><code>${program}</code></strong> is, literally, <strong><code>ccache /usr/bin/g++</code></strong> (a single string, as noted above,) when it ought to be just <strong><code>ccache</code></strong>, with <strong><code>/usr/bin/g++</code></strong> being prepended to <code>@ARGV</code>.</p> <hr> <p>(Some of you may wonder why I've gone to all the trouble of explaining this, when it's a one-line fix to <code>colorgcc.pl</code>. That's true, but if I just did that, the world would lose another opportunity to learn about this class of errors. Plus, I wouldn't get as many votes.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload