Gentoo Archives: gentoo-dev

From: Mike Gilbert <floppym@g.o>
To: Gentoo Dev <gentoo-dev@l.g.o>
Subject: Re: [gentoo-dev] [PATCH 2/3] multiprocessing.eclass: Introduce get_nproc() to get no of CPUs
Date: Wed, 14 Dec 2016 19:06:59
Message-Id: CAJ0EP43vb_MYAGw0oKTHx2rhstRjjpUNGaEMAF2EWpWwXJnenA@mail.gmail.com
In Reply to: Re: [gentoo-dev] [PATCH 2/3] multiprocessing.eclass: Introduce get_nproc() to get no of CPUs by Fabian Groffen
1 On Wed, Dec 14, 2016 at 1:29 PM, Fabian Groffen <grobian@g.o> wrote:
2 > On 14-12-2016 13:01:16 -0500, Doug Freed wrote:
3 >> On Wed, Dec 14, 2016 at 12:48 PM, Nathan Zachary
4 >> <nathanzachary@g.o> wrote:
5 >> > On 14/12/16 10:11, Doug Freed wrote:
6 >> >>> I somehow doubt that would give me the expected number only, and I lack
7 >> >>> a BSD install handy to test it.
8 >> >> $(sysctl -n hw.ncpu)
9 >> >>
10 >> > I don't know that the sysctl command works universally:
11 >> >
12 >> > # sysctl -n hw.ncpu
13 >> > sysctl: cannot stat /proc/sys/hw/ncpu: No such file or directory
14 >> >
15 >>
16 >> It's BSD-specific (Darwin may have it too, but I'm not in OS X at the
17 >> moment, so I can't check), which pretty much describes this branch in
18 >> the codepath as well. Linux users will have the nproc command from
19 >> coreutils.
20 >
21 > Yes, Darwin has it too, but the tool lives in /usr/sbin instead:
22 >
23 > https://gitweb.gentoo.org/repo/proj/prefix.git/tree/scripts/bootstrap-prefix.sh#n1987
24 >
25
26 Seems like we could borrow that code for the eclass, with some minor
27 modifications. It should probably use ${CBUILD:-${CHOST}} to cover
28 cross-compiling.
29
30 Another alternative would be to check the userland_BSD and
31 userland_GNU use flags.