Hello,
when I install gcc/g++ before ccache the symlinks to /usr/bin/cc and
/usr/bin/c++ aren't updated. This is what happens (see below what's wrong) in
a clean chroot:
root@nemesis:/# apt-get install ccache
[snip]
Setting up ccache (3.1.5-2) ...
Updating symlinks in /usr/lib/ccache ...
root@nemesis:/# apt-get install gcc g++
[snip]
Selecting previously deselected package gcc.
Unpacking gcc (from .../gcc_4%3a4.6.0-6_amd64.deb) ...
[snip]
Selecting previously deselected package g++-4.6.
Unpacking g++-4.6 (from .../g++-4.6_4.6.1-1_amd64.deb) ...
Selecting previously deselected package g++.
Unpacking g++ (from .../g++_4%3a4.6.0-6_amd64.deb) ...
[snip]
Processing triggers for ccache ...
Updating symlinks in /usr/lib/ccache ...
[snip]
Setting up gcc (4:4.6.0-6) ...
[snip]
Setting up g++ (4:4.6.0-6) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto
mode.
root@nemesis:/# ls -la /usr/lib/ccache/
total 8
drwxr-xr-x 2 root root 4096 Jul 5 20:34 .
drwxr-xr-x 25 root root 4096 Jul 5 20:34 ..
lrwxrwxrwx 1 root root 16 Jul 5 20:34 c89-gcc -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 c99-gcc -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 g++ -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 g++-4.6 -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 gcc -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 gcc-4.6 -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-g++ ->
../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-g++-4.6 ->
../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-gcc ->
../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-gcc-4.6 ->
../../bin/ccache
root@nemesis:/# update-ccache-symlinks
root@nemesis:/# ls -la /usr/lib/ccache/
total 8
drwxr-xr-x 2 root root 4096 Jul 5 20:36 .
drwxr-xr-x 25 root root 4096 Jul 5 20:34 ..
lrwxrwxrwx 1 root root 16 Jul 5 20:36 c++ -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 c89-gcc -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 c99-gcc -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:36 cc -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 g++ -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 g++-4.6 -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 gcc -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 gcc-4.6 -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-g++ ->
../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-g++-4.6 ->
../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-gcc ->
../../bin/ccache
lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-gcc-4.6 ->
../../bin/ccache
As you can see in the first ls, both cc and c++ symlinks are missing in
/usr/lib/ccache/.
The problem is the following: both /usr/bin/cc and /usr/bin/c++ are
alternatives installed while executing gcc and g++ postinst scripts
respectively. The dpkg triggers for ccache are activated in the gcc/g++
configuring stage, before /usr/bin/cc and /usr/bin/c++ exist in the hard
disk, therefore they aren't considered by update-ccache-symlinks.
How to solve it? The first thing I tought was that adding a couple of file
triggers for /usr/bin/cc and /usr/bin/c++ to ccache would do the trick, but
unfortunately there's a problem with this; quoting from "File triggers"
section of /usr/share/doc/dpkg-dev/triggers.txt.gz
So file triggers can't be activated in the postinst, only during upack or
removal. Therefore the solution is making the triggers explicit, calling
them from some maintainer scripts in gcc-defaults. I'm attaching a
couple of patches implementing this solution.
So ... if the gcc maintainers accept the gcc-defaults patch, would you
accept the ccache one? If yes, I would open a new bug report against
src:gcc-defaults with the patch and mark this one as blocked. A reply just
saying "go ahead" is enough, thanks for your time.