[Cook] RE: [Aegis]What does "single-thread" do anyway?

Peter Miller peterm at platypus.net
Thu Jun 20 08:37:57 EST 2002


Fredrick Paul Eisele writes

> I understand how "single-thread" is intended to be used.
> 
> boofar.lock: phoey
>   single-thread boofar.lock
> {
>     ... do some stuff...
> }

This is a Cook question.
The single-thread recipe attribute is for use with parallel builds,
telling Cook that it shouldn't do two foobar.lock things at once.

Perhapse an example is in order.  Yacc is a fine example...

	%.c %.h: %.y
		single-thread yy.tab.h yy.tab.c
	{
		yacc -d %.y;
		mv yy.tab.c %.c;
		mv yy.tab.h %.h;
	}

Yacc creates fix-named output files, and you have to move them aroud if
you have more than one yacc source in a project.  Imagine if Cook is
building in paralle on a 2 cpu system, and it decided to do

	yacc foo.y
	yacc bar.y
	mv yy.tab.c foo.c
	mv yy.tab.c bar.c
	mv yy.tab.h foo.h
	mv yy.tab.h bar.h

doesn't work, does it?  The single-thread attribute tells Cook this is a
bad idea.  Actually, this is more common than you may think.  When using
a whole-project build (RMCH, after all), you get recipes like this...
	
	%0%.o: %0%.c
		single-thread %.o
	{
		cc -c %0%.c;
		if [%0] then
			mv %.o %0%.o;
	}

because lots of old, dumb C compilers don't grok -o with -c, and so
always put the .o file in the current directory, but that's probably not
where it's wanted.  So you need to have some way of telling Cook that
foo/main.c and bar/main.c shouldn't be coimpiled at the same time, hence
single-thread.

Regards
Peter Miller <millerp at canb.auug.org.au>
/\/\*        http://www.canb.auug.org.au/~millerp/ 



More information about the Cook-users mailing list