[cfe-dev] Why copy_if_different?

Yuri Gribov tetra2005 at googlemail.com
Fri Apr 29 03:26:30 PDT 2011


On Fri, Apr 29, 2011 at 1:48 PM, Francois Pichet <pichet2000 at gmail.com> wrote:
> On Fri, Apr 29, 2011 at 5:34 AM, Yuri Gribov <tetra2005 at googlemail.com> wrote:
>> On Fri, Apr 29, 2011 at 1:15 PM, Francois Pichet <pichet2000 at gmail.com> wrote:
>>> On Fri, Apr 29, 2011 at 5:09 AM, Yuri Gribov <tetra2005 at googlemail.com> wrote:
>>>> Hi all,
>>>>
>>>> What is the reason for custom build rules in Visual Studion using
>>>> 'cmake -E copy_if_different' instead of plain 'cmake -E copy'? If
>>>> target file is older than source but contents is the same the source
>>>> will not be copied and the timestamp of target will remain the same.
>>>> This means that VS will try to rebuild this file (and a dozen of
>>>> dependent projects) on every run (I observe this particular behavior
>>>> on my system).
>>>
>>> I too observed this behaviour with MSVC 2008 but not with MSVC 2010.
>>> That's one of the reason i switched from 2008 to 2010.
>>>
>>
>> I really do not think that this behavior depends on particular version of VS.
>
> I don't know. MSVC 2010 now use MSBUILD under the hood to build.
> MSBUILD wasn't used with 2008 for C++ project. There could be side
> effects to that. As I said I never observed even one case of
> unnecessary recompilation with 2010, something I was seeing very often
> with 2008. I really don't know why though.
>

BTW I think I have a real-world example of broken dependencies in Clang:

1) Firstly I build debug Clang.
include/clang/Basic/DiagnosticASTKinds.inc.tmp is generated using
debug tablegen and then copied to DiagnosticASTKinds.inc.

2) Now I switch to release and build it the DiagnosticASTKinds.inc.tmp
is regenerated (because it depends on release tablegen and it's newer
than debug tablegen that was used to generate it).

Note that now VS thinks that DiagnosticASTKinds.inc has to be rebuilt
(it's older than DiagnosticASTKinds.inc.tmp). But due to
copy_if_different DiagnosticASTKinds.inc.tmp is never copied to
DiagnosticASTKinds.inc. So VS will try to rebuild Clang forever.

-- 
Best regards,
Yuri



More information about the cfe-dev mailing list