diff options
author | Xi Ruoyao <xry111@xry111.site> | 2023-09-11 14:42:06 +0800 |
---|---|---|
committer | Xi Ruoyao <xry111@xry111.site> | 2023-09-13 17:34:36 +0800 |
commit | da122542429e5a6ec8b3cb4421ea3d590c7c0b6c (patch) | |
tree | 27130adbfeec93aa7a64cd384b9b63f99114f229 | |
parent | b91b12adf3d7926f570b900f758e4670de3d4ec1 (diff) |
settingenviron: Set MAKEFLAGS for parallelism in ~lfs/.bashrc
-rw-r--r-- | chapter04/aboutsbus.xml | 12 | ||||
-rw-r--r-- | chapter04/settingenviron.xml | 46 |
2 files changed, 46 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.</para> <note> - <para>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 - <command>make</command> program how many processors are available. For - instance, an Intel i5-6500 CPU can support four simultaneous processes with:</para> - - <screen role="nodump"><userinput>export MAKEFLAGS='-j4'</userinput></screen> - - <para>or by building with:</para> - - <screen role="nodump"><userinput>make -j4</userinput></screen> - <para>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..cbed3ba17 100644 --- a/chapter04/settingenviron.xml +++ b/chapter04/settingenviron.xml @@ -195,6 +195,52 @@ EOF</userinput></screen> completed LFS system.</para> </important> + <para> + 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 + 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. To use all these + logical cores for a <command>make</command>, append + <parameter>-j32</parameter> for the command: + </para> + + <screen role='nodump'><userinput>make -j32</userinput></screen> + + <para> + Or set the <envar>MAKEFLAGS</envar> environment variable and its + content will be automatically used by <command>make</command> as + command line options: + </para> + + <screen role='nodump'><userinput>export MAKEFLAGS=-j32</userinput></screen> + + <para> + To use all logical cores available for building packages in + <xref linkend='chapter-cross-tools'/> and + <xref linkend='chapter-temporary-tools'/>, set <envar>MAKEFLAGS</envar> + now in <filename>.bashrc</filename>: + </para> + + <!-- "|| echo 1" is for guarding against the cases where nproc is not + available or it fails. A "-j" option without a number is VERY + DANGEROUS because it would cause make spawning as many parallel jobs + as possible. --> +<screen><userinput>cat > ~/.bashrc << "EOF" +<literal>export MAKEFLAGS=-j<replaceable>$(nproc || echo 1)</replaceable></literal> +EOF</userinput></screen> + + <para> + The <command>nproc</command> command is only available if the host + distro provides Coreutils 8.1 or newer. Replace + <replaceable>$(nproc || echo 1)</replaceable> with the number of logical + cores you want to use if the <command>nproc</command> command is not + available or you don't want to use all the logical cores. + </para> + <para>Finally, to ensure the environment is fully prepared for building the temporary tools, force the <command>bash</command> shell to read the new user profile:</para> |