* Adam Borowski <[email protected]>, 2016-04-27, 18:13:
For pre-squeeze, there's "getconf _NPROCESSORS_ONLN".
At least one Debian derivative, Dyson, has:
draconis:[~]$ dpkg --print-architecture
illumos-amd64
draconis:[~]$ getconf _NPROCESSORS_ONLN
getconf: Invalid argument (_NPROCESSORS_ONLN)
That's odd.
so let's not advertise getconf, as -j`something with no stdout output`
results in a fork bomb.
I was always baffled with the semantics of make's argumentless -j. Why
would anyone want this behavior? :-\
Anyway, I'd expect any decent DEB_BUILD_OPTIONS parser to reject the
bogus "parallel=".
For example, debhelper does it right:
if ($opt =~ /^parallel=(-?\d+)$/ && $wanted eq 'parallel') {
return $1;
}
[Optional minus sign is to support CPUs made of antimatter.]
The snippet I've been using in my d/rules is also immune to accidental
lone -j:
parallel = -j$(or $(patsubst parallel=%,%,$(filter
parallel=%,$(DEB_BUILD_OPTIONS))),1)
...
$(MAKE) $(parallel)
Unfortunately, the snippet Policy ยง4.9.1 recommends is forkbomb-prone:
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
MAKEFLAGS += -j$(NUMJOBS)
endif
--
Jakub Wilk