So this is working as designed, when you explicitly override the Optimization flags it is assumed that you will not want the old compile.
There are a couple of ways to properly fix this
1. Store the compile options used with the cache, and compare them at the start of a compile, to determine whether or not to skip using the cache.
2. add a new flag to indicate that the implied skip cache shouldn't be used. This is easier but some what hacky.
A third option is open to Ubuntu, to use a distro patch (I don't think this will be taken upstream, at least not with out discussion) to remove forcing optimization options to skip the cache. This is the easiest and the patch to do so is attached
So this is working as designed, when you explicitly override the Optimization flags it is assumed that you will not want the old compile.
There are a couple of ways to properly fix this
1. Store the compile options used with the cache, and compare them at the start of a compile, to determine whether or not to skip using the cache.
2. add a new flag to indicate that the implied skip cache shouldn't be used. This is easier but some what hacky.
A third option is open to Ubuntu, to use a distro patch (I don't think this will be taken upstream, at least not with out discussion) to remove forcing optimization options to skip the cache. This is the easiest and the patch to do so is attached