Re: [Vala] plans to speed up compilation



On 05/21/2010 06:43 PM, Adam Dingle wrote:
Our project (Shotwell) does not use autotools, but it has a hand-crafted
Makefile that achieves exactly what you described: if a .vala files does
not change then a .c file is not regenerated

Well yes and no... the .c file is not written BUT all the .vala files
are still opened and processed by valac because Shotwell's Makefile uses
a single valac invocation to which it passes the filenames of all .vala files.
This means that even though you only changed for example src/Page.vala, valac
will process all the .vala files in your project, just look at:

  touch src/Page.vala ; strace -f make 2>&1 | grep open


, and we can use make -j to
build all the .c files in parallel. In my earlier message I wasn't
talking about the speed of compiling the .c files (which is
satisfactory), but rather the speed of the 'valac --ccode' step which
converts the Vala files to C.

No you misunderstood what I said. Basically the gcc part is very fast
because gcc is only handed the .c files that have changed. However your
Makefile will hand _all_ .vala files to valac regardless of which ones
changed.

So the question is why can't "make" be used to speed up .vala -> .c
compilation just like it speeds up .c -> .o compilation? Consider for
example this hypophetical target:

  %.o: %.vala
          valac -c -o $@ $<

Do you see what I'm saying now? The "standard solution" to this problem
is "if some file didn't change then don't pass it to the compiler at all".

What actually happens using valac today is that despite running with "-c"
the semantic analyzer in valac aborts the compilation process when it sees
some function which is not in the file it's building. See sample here:
http://temp.minimum.se/valac_partial_build.zip

I wonder if that's just a silly bug in valac or if there is some fundamental
reason why this type of "per file" compilation can't work for valac?
The central question is: if I change a.vala, can it ever trigger changes
in file other than a.o ?


                Martin



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]