diff --git a/Makefile.config.in b/Makefile.config.in index 21423d2ce..2bd2c3ed9 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -7,6 +7,8 @@ PLATFORM = $(shell uname) +NCPU = @NCPU@ + ABSOLUTE_ROOT_DIR = $(shell cd $(ROOT_DIR) && pwd) EXAMPLES_DIR = $(ABSOLUTE_ROOT_DIR)/examples diff --git a/Makefile.in b/Makefile.in index 857fbeb50..68c1cfabc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -29,8 +29,6 @@ TARGETS_TO_TEST += objc endif TARGETS_TO_TEST := $(shell echo $(TARGETS_TO_TEST)) -NCPU = @NCPU@ - all: $(INFER_ANALYZERS) java: inferTraceBugs diff --git a/build-infer.sh b/build-infer.sh index c7394e6ef..daf65b758 100755 --- a/build-infer.sh +++ b/build-infer.sh @@ -14,6 +14,7 @@ set -e SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" INFER_ROOT="$SCRIPT_DIR/../" PLATFORM="$(uname)" +NCPU="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)" function usage() { echo "Usage: $0 [-y] [targets]" @@ -161,7 +162,7 @@ if [ "$BUILD_CLANG" = "yes" ] && ! facebook-clang-plugins/clang/setup.sh --only- fi fi -make -j $TARGETS || ( +make -j $NCPU $TARGETS || ( echo echo ' compilation failure; you can try running' echo diff --git a/configure.ac b/configure.ac index 956a6a31c..cf9ba853d 100644 --- a/configure.ac +++ b/configure.ac @@ -240,17 +240,11 @@ echo $buck_version > "$buckversion_file" AC_MSG_RESULT([$buck_version]) -AC_CHECK_TOOL([HAVE_NPROC], [nproc], [no]) -AC_CHECK_TOOL([HAVE_SYSCTL], [sysctl], [no]) +AC_CHECK_TOOL([GETCONF], [getconf], [no]) AC_MSG_CHECKING([the number of cpus the build host has]) -if test "$HAVE_NPROC" != "no"; then - if test $(nproc); then - NCPU=$(nproc) - AC_MSG_RESULT([$NCPU]) - fi -elif test $"HAVE_SYSCTL" != "no"; then - if test $(sysctl -n hw.ncpu); then - NCPU=$(sysctl -n hw.ncpu) +if test "$GETCONF" != "no"; then + if test $(getconf _NPROCESSORS_ONLN); then + NCPU=$(getconf _NPROCESSORS_ONLN) AC_MSG_RESULT([$NCPU]) fi else diff --git a/infer/src/Makefile.in b/infer/src/Makefile.in index ce2531c00..fb08c00c9 100644 --- a/infer/src/Makefile.in +++ b/infer/src/Makefile.in @@ -131,7 +131,7 @@ endif DEPENDENCIES = IR backend checkers eradicate harness \ facebook/checkers facebook/checkers/graphql facebook/scripts $(EXTRA_DEPS) -OCAMLBUILD = ocamlbuild $(OCAMLBUILD_OPTIONS) -j 0 $(addprefix -I , $(DEPENDENCIES)) +OCAMLBUILD = ocamlbuild $(OCAMLBUILD_OPTIONS) -j $(NCPU) $(addprefix -I , $(DEPENDENCIES)) .PHONY: all java clang llvm unit checkCopyright build_java build_clang build_llvm build_unit \ build_checkCopyright java_annotations clang_annotations llvm_annotations \