From a0a803c0b053dd9b4867690d8bc25fc0b97fa486 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Mon, 11 Sep 2023 14:42:06 +0800 Subject: settingenviron: Set MAKEFLAGS for parallelism in ~lfs/.bashrc --- chapter04/aboutsbus.xml | 12 ----------- chapter04/settingenviron.xml | 49 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/chapter04/aboutsbus.xml b/chapter04/aboutsbus.xml index f88db24f6..42a523fa1 100644 --- a/chapter04/aboutsbus.xml +++ b/chapter04/aboutsbus.xml @@ -37,18 +37,6 @@ numbers can vary by as much as dozens of minutes in some cases. - For many modern systems with multiple processors (or cores) the - compilation time for a package can be reduced by performing a "parallel - make" by either setting an environment variable or telling the - make program how many processors are available. For - instance, an Intel i5-6500 CPU can support four simultaneous processes with: - - export MAKEFLAGS='-j4' - - or by building with: - - make -j4 - When multiple processors are used in this way, the SBU units in the book will vary even more than they normally would. In some cases, the make step will simply fail. Analyzing the output of the build process will also diff --git a/chapter04/settingenviron.xml b/chapter04/settingenviron.xml index b255a4b45..2d8d6045f 100644 --- a/chapter04/settingenviron.xml +++ b/chapter04/settingenviron.xml @@ -195,6 +195,55 @@ EOF completed LFS system. + + For many modern systems with multiple processors (or cores) the + compilation time for a package can be reduced by performing a "parallel + make" by telling the make program how many processors are available via + a command line option or an environment variable. For instance, an Intel + Core i9-13900K processor has 8 P (performance) cores and + 16 E (efficiency) cores, and a P core can simultaneously run two threads + so each P core are modeled as two logical cores by the Linux kernel. + As the result there are 32 logical cores in total. One obvious way to + use all these logical cores is allowing make to spawn + up to 32 build jobs. This can be done by passing the + -j32 option to make: + + + make -j32 + + + Or set the MAKEFLAGS environment variable and its + content will be automatically used by make as + command line options: + + + export MAKEFLAGS=-j32 + + + + Never pass a -j option without a number to + make or set such an option in + MAKEFLAGS. Doing so will allow make + to spawn infinite build jobs and cause system stability issue. + + + + + To use all logical cores available for building packages in + and + , set MAKEFLAGS + now in .bashrc: + + +cat >> ~/.bashrc << "EOF" +export MAKEFLAGS=-j$(nproc) +EOF + + + Replace $(nproc) with the number of logical + cores you want to use if you don't want to use all the logical cores. + + Finally, to ensure the environment is fully prepared for building the temporary tools, force the bash shell to read the new user profile: -- cgit v1.2.3-54-g00ecf