kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

commit 94eaef5e27c8ca1c0e3f9dcc5556f29f7b6503e2
parent 085571a2844d40bee4bcfe3a41944c0bb0d2c87a
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Sun, 14 Jun 2026 15:44:23 -0700

build: parallelize lib/bin/rt builds by default

Append -j$(NCPU) to MAKEFLAGS at the top level so plain `make`,
`make lib`, `make bin`, etc. build in parallel without the caller
passing -j. Guarded to MAKELEVEL 0 so recursive $(MAKE) inherits the
parent jobserver instead of re-forcing -j, and skipped when a test goal
is requested so the heavy suites stay serial.

Diffstat:
MMakefile | 17+++++++++++++++++
1 file changed, 17 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -9,6 +9,23 @@ endif .DEFAULT_GOAL := all +# Parallelize the library/binary/runtime build by default: appending -j to +# MAKEFLAGS at the top level turns plain `make`, `make lib`, `make bin`, etc. +# into parallel builds without the caller passing -j. Two guards keep it +# scoped: +# - MAKELEVEL 0 only, so a recursive $(MAKE) (bootstrap/dist/rt) inherits the +# parent jobserver instead of re-forcing -j (which would disable the +# jobserver and oversubscribe cores). +# - skip when any requested goal is a test target: the suites are heavy and +# their output interleaves badly under -j, so `make test-*` stays serial. +# A caller's explicit `-j`/`-jN` still wins; override with `make NCPU=1 ...`. +NCPU ?= $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4) +ifeq ($(MAKELEVEL),0) +ifeq ($(filter test%,$(MAKECMDGOALS)),) +MAKEFLAGS += -j$(NCPU) +endif +endif + # Build setup, in dependency order. Each include owns one concern and only # reads the variables produced by the ones before it: # env.mk host detection, driver/env source selection, SDK sysroot