[sdk/kdesrc-build/auto-detect-nr-cpus] /: rc-file: Update num-cpus to be num-cores, use env vars.

Michael Pyne null at kde.org
Wed Jul 8 04:24:11 BST 2020


Git commit 27505b67a2775cdb04c46b438e54b06158d6b658 by Michael Pyne.
Committed on 08/07/2020 at 03:22.
Pushed by mpyne into branch 'auto-detect-nr-cpus'.

rc-file: Update num-cpus to be num-cores, use env vars.

M  +6    -4    doc/index.docbook
M  +1    -1    kdesrc-build-setup
M  +1    -1    kdesrc-buildrc-kf5-sample
M  +2    -2    modules/ksb/BuildContext.pm
M  +1    -1    modules/ksb/FirstRun.pm
M  +5    -2    qt5-build-include

https://invent.kde.org/sdk/kdesrc-build/commit/27505b67a2775cdb04c46b438e54b06158d6b658

diff --git a/doc/index.docbook b/doc/index.docbook
index bc60de9..df3c703 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -503,7 +503,7 @@ compile jobs you wish to allow.  A higher number (up to the number of logical CP
 your system has available) leads to quicker builds, but requires more system resources.
 </para>
 
-<tip><para>&kdesrc-build; sets the option <option><link linkend="conf-num-cpus">num-cpus</link></option> to
+<tip><para>&kdesrc-build; sets the option <option><link linkend="conf-num-cores">num-cores</link></option> to
 the detected number of available processing cores. You can use this value
 in your own configuration file to avoid having to set it manually.
 </para></tip>
@@ -512,7 +512,9 @@ in your own configuration file to avoid having to set it manually.
 <title>Configuring Make to use all available CPUs, with exceptions</title>
 <screen>
 global
-    make-options -j <literal>${num-cpus}</literal>
+    # This environment variable is automatically used by make, including
+    # make commands not run by kdesrc-build directly, such as Qt's configure
+    set-env MAKEFLAGS -j<literal>${num-cores}</literal>
     …
 end global
 
@@ -2622,8 +2624,8 @@ module if it normally would have tried anyways.</entry>
 due to fixes in the underlying build system.</entry>
 </row>
 
-<row id="conf-num-cpus">
-<entry>num-cpus</entry>
+<row id="conf-num-cores">
+<entry>num-cores</entry>
 <entry>Cannot be overridden</entry>
 <entry>
 <para>This option is automatically set by &kdesrc-build; to the number of
diff --git a/kdesrc-build-setup b/kdesrc-build-setup
index 838165a..6d2fd47 100755
--- a/kdesrc-build-setup
+++ b/kdesrc-build-setup
@@ -368,7 +368,7 @@ print $output <<EOF;
 
     # Use multiple cores for building. Other options to GNU make may also be
     # set.
-    make-options -j \${num-cpus}
+    make-options -j \${num-cores}
 
     # kdesrc-build can install a sample .xsession file for "Custom"
     # (or "XSession") logins,
diff --git a/kdesrc-buildrc-kf5-sample b/kdesrc-buildrc-kf5-sample
index 823b1bf..136a992 100644
--- a/kdesrc-buildrc-kf5-sample
+++ b/kdesrc-buildrc-kf5-sample
@@ -14,7 +14,7 @@ global
     # logs will be kept under this directory as well.
     source-dir ~/kde/src
 
-    make-options -j ${num-cpus}
+    make-options -j ${num-cores}
 end global
 
 # Instead of specifying modules here, the current best practice is to refer to
diff --git a/modules/ksb/BuildContext.pm b/modules/ksb/BuildContext.pm
index 3ceaf01..6a5179e 100644
--- a/modules/ksb/BuildContext.pm
+++ b/modules/ksb/BuildContext.pm
@@ -173,8 +173,8 @@ sub new
     assert_isa($self, 'ksb::BuildContext');
 
     # Make the number of CPUs available to the rc-file by turning it into a pre-set option
-    my $nproc = int (eval { (filter_program_output(undef, 'nproc'))[0] } // 4);
-    $self->setOption('num-cpus', $nproc);
+    my $nproc = int (eval { (filter_program_output(undef, 'nproc'))[0] } // 3) + 1;
+    $self->setOption('num-cores', $nproc);
 
     return $self;
 }
diff --git a/modules/ksb/FirstRun.pm b/modules/ksb/FirstRun.pm
index 04ec9ac..c631efb 100644
--- a/modules/ksb/FirstRun.pm
+++ b/modules/ksb/FirstRun.pm
@@ -527,7 +527,7 @@ global
     include-dependencies true
 
     cmake-options -DCMAKE_BUILD_TYPE=RelWithDebInfo
-    make-options  -j ${num-cpus}
+    make-options  -j ${num-cores}
 end global
 
 # With base options set, the remainder of the file is used to define modules to build, in the
diff --git a/qt5-build-include b/qt5-build-include
index d756301..28ea98f 100644
--- a/qt5-build-include
+++ b/qt5-build-include
@@ -16,7 +16,10 @@ module-set qt5-set
     prefix ${qtdir}
 
     configure-flags -release -reduce-relocations -force-debug-info -separate-debug-info
-    make-options -j ${num-cpus}
+
+    # Applies to every make command run for Qt build, including Qt's own attempts to
+    # run make from its configure script.
+    set-env MAKEFLAGS -j${num-cores}
 end module-set
 
 # qtwebengine is essentially the Chromium Embedded Framework with Qt bindings
@@ -26,5 +29,5 @@ end module-set
 # also ensure you don't outstrip your available RAM with too high of a
 # parallelism (-j flag).
 options qtwebengine
-    make-options NINJAFLAGS=-j4
+    set-env NINJAFLAGS -j4
 end options


More information about the kde-doc-english mailing list