[commit: ghc] master: circleci: Detect core count (de95bf4)

git at git.haskell.org git at git.haskell.org
Fri Jul 6 18:08:53 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/de95bf40ee0af0e7da4cb6cc4e0ad33694234bb9/ghc

>---------------------------------------------------------------

commit de95bf40ee0af0e7da4cb6cc4e0ad33694234bb9
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Fri Jul 6 10:57:55 2018 -0400

    circleci: Detect core count
    
    Test Plan: Try `./validate`, CircleCI build; make sure core count
    detection works in both cases.
    
    Reviewers: alpmestan
    
    Reviewed By: alpmestan
    
    Subscribers: rwbarton, thomie, carter
    
    GHC Trac Issues: #14470
    
    Differential Revision: https://phabricator.haskell.org/D4897


>---------------------------------------------------------------

de95bf40ee0af0e7da4cb6cc4e0ad33694234bb9
 .circleci/config.yml   | 10 ++++++----
 mk/detect-cpu-count.sh | 26 ++++++++++++++++++++++++++
 validate               | 24 +-----------------------
 3 files changed, 33 insertions(+), 27 deletions(-)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index e52d38d..298162e 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -15,7 +15,9 @@ aliases:
       name: submodules
       command: .circleci/fetch-submodules.sh
   - &buildenv
-    THREADS: 9
+    # ideally we would simply set THREADS here instead of re-detecting it every
+    # time we need it below. Unfortunately, there is no way to set an environment
+    # variable with the result of a shell script.
     SKIP_PERF_TESTS: YES
     VERBOSE: 2
   - &boot
@@ -50,19 +52,19 @@ aliases:
   - &make
     run:
       name: Build
-      command: "make -j$THREADS"
+      command: "make -j`mk/detect-cpu-count.sh`"
   - &build_hadrian
     run:
       name: Build GHC using Hadrian
       command: |
         cabal update
-        hadrian/build.sh -j$THREADS
+        hadrian/build.sh -j`mk/detect-cpu-count.sh`
   - &test
     run:
       name: Test
       command: |
         mkdir -p test-results
-        make test SKIP_PERF_TESTS=YES JUNIT_FILE=../../test-results/junit.xml
+        make test THREADS=`mk/detect-cpu-count.sh` SKIP_PERF_TESTS=YES JUNIT_FILE=../../test-results/junit.xml
   - &store_test_results
     store_test_results:
       path: test-results
diff --git a/mk/detect-cpu-count.sh b/mk/detect-cpu-count.sh
new file mode 100755
index 0000000..abc4738
--- /dev/null
+++ b/mk/detect-cpu-count.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+detect_cpu_count () {
+    if [ "$CPUS" = "" ]; then
+        # Windows standard environment variable
+        CPUS="$NUMBER_OF_PROCESSORS"
+    fi
+
+    if [ "$CPUS" = "" ]; then
+        # Linux
+        CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
+    fi
+
+    if [ "$CPUS" = "" ]; then
+        # FreeBSD
+        CPUS=`getconf NPROCESSORS_ONLN 2>/dev/null`
+    fi
+
+    if [ "$CPUS" = "" ]; then
+        # nothing helped
+        CPUS="1"
+    fi
+}
+
+detect_cpu_count
+echo "$CPUS"
diff --git a/validate b/validate
index 0332e5b..2f82b28 100755
--- a/validate
+++ b/validate
@@ -119,29 +119,7 @@ check_packages () {
     fi
 }
 
-detect_cpu_count () {
-    if [ "$CPUS" = "" ]; then
-        # Windows standard environment variable
-        CPUS="$NUMBER_OF_PROCESSORS"
-    fi
-
-    if [ "$CPUS" = "" ]; then
-        # Linux
-        CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
-    fi
-
-    if [ "$CPUS" = "" ]; then
-        # FreeBSD
-        CPUS=`getconf NPROCESSORS_ONLN 2>/dev/null`
-    fi
-
-    if [ "$CPUS" = "" ]; then
-        # nothing helped
-        CPUS="1"
-    fi
-}
-
-detect_cpu_count
+CPUS=`mk/detect-cpu-count.sh`
 
 if ! [ -d testsuite ]
 then



More information about the ghc-commits mailing list