[llvm-commits] [PATCH] Teach CMake to only touch tablegen-generated files if anything actually changed.

Frits van Bommel fvbommel at gmail.com
Fri Oct 22 10:06:10 PDT 2010


On Fri, Oct 22, 2010 at 6:25 PM, Óscar Fuentes <ofv at wanadoo.es> wrote:
> Frits van Bommel <fvbommel at gmail.com>
> writes:
>
>> I noticed the CMake build doesn't leave tablegen-generated files
>> untouched if they are regenerated with the same contents[1]. The
>> attached patch should fix that.
[snip]
>
> Thanks. Applied in r117102.
>
> IIRC a similar approach had problems in Windows: nmake (or was it
> mingw32-make?) executed tablegen every time, as it considered the
> resulting file always out of date.
>
> This was a long time ago and since the build (and cmake) changed, so
> let's try again.

Hmm, I suppose something similar would happen here too. That might
still be less work than compiling about half of LLVM and 80%+ of clang
(guesstimates) every time tablegen gets relinked though, depending on
how often real changes happen I suppose.

After some testing, I can confirm this does happen (tested on Linux,
not Windows).
We can solve that with an extra level of indirection: by keeping the
temporary file but generating it with a separate add_custom_command()
invocation, we only rerun tablegen once per generated file when it
gets relinked (no matter how often 'make' is invoked). This way we
still only touch the real .inc when something *actually* changed.
The attached patch implements this improvement. In the situation that
would otherwise keep rerunning tablegen there is still a little extra
work done, but instead of needlessly invoking tablegen it needlessly
invokes "cmake -E copy_if_different", which should be a lot faster.

Note that I wasn't sure what COMMENT lines to use for the two
different targets, but "Building ${ofn}.tmp..." and "Updating ${ofn}
if necessary" seems reasonable. (Similar phrasing is used when
regenerating library dependencies, I think)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmake-tablegen-copy_if_different-v2.patch
Type: text/x-patch
Size: 1685 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101022/22864ffd/attachment.bin>


More information about the llvm-commits mailing list