Skip to content

Commit ad61bf8

Browse files
devurandomdvc94ch
authored andcommitted
Support setting LLVM build parallelism
This adds an "nproc" variable to the Makefile, which allows the user to configure the build parallelism (currently only supported for the LLVM build). I.e. this variable is passed on to the build tool via `-j$(nproc)`, if set. The variable is not set by default, which means the build behaves just like before, using the default parallelism of the build tool (e.g. nproc + 2 for Ninja). It can be set on the command line as e.g. `make nproc=2` (to force it to a fixed number) or `make nproc=$(nproc)` (to set it to the number of available processors). On "memory constrained" systems with e.g. 4 CPUs, but "only" 8 GiB of RAM, this is necessary in order to prevent the LLVM build from consuming excessive amounts of memory and thus locking up the entire system. Signed-Off-By: Dennis Schridde <[email protected]>
1 parent 22e676a commit ad61bf8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ root_dir := $(CURDIR)
22
build_dir := $(root_dir)/build
33
sysroot_dir := $(root_dir)/toolchain
44
target := riscv32-unknown-elf
5+
nproc :=
56

67

78
all: toolchain
@@ -36,7 +37,7 @@ llvm-configure: $(llvm_src)
3637
$(llvm_build): llvm-configure
3738

3839
llvm-build: $(llvm_build)
39-
cmake --build $(llvm_build)
40+
cmake --build $(llvm_build) -- $(if $(nproc),-j$(nproc))
4041
$(llvm_build)/bin/llc: llvm-build
4142

4243
llvm-install: $(llvm_build)/bin/llc

0 commit comments

Comments
 (0)