From c986e6550756cfa25dab4aa9f3ce90be9c4d340e Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Fri, 1 Apr 2016 02:53:02 -0700 Subject: [PATCH] Build llvm fe in make test, enable parallel build Summary:public All frontends and the backend should be built by `make test` irrespective of configure flags. This diff also re-enables parallel building for the compilation of infer done by the `test` target. The ocaml unit tests, tracebugs tests, and everything run by buck are still sequential. Enabling parallel builds roughly halves the time spent building infer. This diff computes the number of cpus (NCPU) at configure time. Reviewed By: jvillard Differential Revision: D3121658 fb-gh-sync-id: a667cf8 fbshipit-source-id: a667cf8 --- Makefile.in | 31 ++++++++++++++++++++++--------- configure.ac | 20 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index 9494cbff8..a79bad88a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -29,6 +29,8 @@ TARGETS_TO_TEST += objc endif TARGETS_TO_TEST := $(shell echo $(TARGETS_TO_TEST)) +NCPU = @NCPU@ + all: $(INFER_ANALYZERS) java: inferTraceBugs @@ -86,21 +88,28 @@ endif clang: clang_plugin endif +test_build_clang: clang_plugin + $(MAKE) -C $(INFER_DIR) clang + +test_build_java: + $(MAKE) -C $(INFER_DIR) java + +test_build_llvm: + $(MAKE) -C $(INFER_DIR) llvm + +test_build: test_build_clang test_build_java test_build_llvm + unit: $(MAKE) -C $(SRC_DIR) unit -test_build: - $(MAKE) -C $(SRC_DIR) test_clean - $(MAKE) -C $(SRC_DIR) test_build - ifeq (@BUILD_C_ANALYZERS@,yes) test_build: clang_plugin endif -ocaml_unit_test: $(INFER_ANALYZERS) unit +ocaml_unit_test: test_build unit $(INFERUNIT_BIN) -buck_test: $(INFER_ANALYZERS) +buck_test: test_build NO_BUCKD=1 buck clean NO_BUCKD=1 buck test $(TARGETS_TO_TEST) ifeq (@BUILD_JAVA_ANALYZERS@,yes) @@ -115,9 +124,9 @@ ifeq (@BUILD_JAVA_ANALYZERS@,yes) endif inferTraceBugs: - make -C infer $(INFERTRACEBUGS_BIN) + $(MAKE) -C $(INFER_DIR) $(INFERTRACEBUGS_BIN) -inferTraceBugs_test: $(INFER_ANALYZERS) +inferTraceBugs_test: test_build ifeq (@BUILD_JAVA_ANALYZERS@,yes) $(INFER_BIN) -o __test-infer-out__ -- \ javac $(EXAMPLES_DIR)/Hello.java \ @@ -139,7 +148,11 @@ endif --only-show > /dev/null @rm -fr __test-infer-out__ -test: ocaml_unit_test buck_test inferTraceBugs_test +test: + $(MAKE) -C $(INFER_DIR) $(INFER_BIN) + $(MAKE) -C $(SRC_DIR) init + $(MAKE) -j$(NCPU) test_build + $(MAKE) ocaml_unit_test buck_test inferTraceBugs_test test_xml: buck_test_xml diff --git a/configure.ac b/configure.ac index e91ca9eb6..956a6a31c 100644 --- a/configure.ac +++ b/configure.ac @@ -240,6 +240,26 @@ 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_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) + AC_MSG_RESULT([$NCPU]) + fi +else + NCPU=1 + AC_MSG_RESULT([failed, defaulting to 1]) +fi +AC_SUBST([NCPU]) + + AC_CONFIG_FILES([ Makefile.config Makefile