Re: [Vala] plans to speed up compilation



On 05/21/2010 12:06 PM, Martin Olsson wrote:
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.

Right. It must do this, since valac needs to know about symbols in all .vala files in order to be able to perform any compilation 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?

This is not a silly bug. There is a fundamental reason: any type in any .vala file in the project can depend on any other type in any .vala file, and so the compiler needs to know about all types in order to do anything.

The central question is: if I change a.vala, can it ever trigger changes
in file other than a.o ?

Certainly.  Here's a trivial example:

== a.vala ==

const int x = 4;

== b.vala ==

void main() {
  print("%d", x);
}

== end ==

If you compile with 'valac --save-temps a.vala b.vala', you'll see that b.c contains a line '#define x 4'. If you change the constant value in a.vala and rebuild, then this line in b.c will change.

As another example, a.vala can define a struct type which is included in a class defined in b.vala. If the struct size in a.vala changes, the class size in b.vala changes and so b.o will certainly need to be regenerated.

But even if the answer to your question was no, then we would *still* need to pass all vala files in the project to the command line when rebuilding a.vala, for the simple reason that a.vala can use types in any other .vala file and the compiler has no way of knowing about those types unless it knows which .vala files to look in to find them.

In summary, it sounds as if you've been assuming that Vala has some built-in notion of separate compilation for .vala files. As far as I'm aware it does not.

adam




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