Dave Cheney committed fa07712 Draft

build: reduce the use of subshells in recursive make

Using make -C $* rather than (cd $* ; make) results in a small,
but measurable improvement in build times where compilation is
not the major component. eg.

before - ~/go/src/pkg$ time make
real 0m1.176s
user 0m0.639s
sys 0m0.399s
after - ~/go/src/pkg$ time make
real 0m0.916s
user 0m0.571s
sys 0m0.243s

There are other places in the distribution src/make.common for example
that could also benefit from this change.

CC=golang-dev, rsc

Committer: Andrew Gerrand <>

Comments (0)

Files changed (2)

 	rm -rf *.o *.a *.[$(OS)] [$(OS)].out $(CLEANFILES)
-	(cd $* && gomake install)
+	gomake -C $* install
 .PHONY: all clean nuke install coverage test bench testpackage-clean\ 
 	importpath dir
 bench.dirs: $(addsuffix .bench, $(BENCH))
-	+cd $* && $(MAKE) clean
+	+$(MAKE) -C $* clean
-	+cd $* && $(MAKE) install
+	+$(MAKE) -C $* install
-	+cd $* && $(MAKE) nuke
+	+$(MAKE) -C $* nuke
-	+cd $* && $(MAKE) test
+	+$(MAKE) -C $* test
-	+cd $* && $(MAKE) bench
+	+$(MAKE) -C $* bench	
 clean: clean.dirs