Skip to content

[build] Build ELKS using parallel make automatically (using up to max CPU cores)#2701

Merged
ghaerr merged 3 commits into
masterfrom
parallel
Jun 15, 2026
Merged

[build] Build ELKS using parallel make automatically (using up to max CPU cores)#2701
ghaerr merged 3 commits into
masterfrom
parallel

Conversation

@ghaerr

@ghaerr ghaerr commented Jun 15, 2026

Copy link
Copy Markdown
Owner

This PR enhances the ELKS build system to take advantage of make's parallel build capability, which drastically reduces the time required to build the cross-compiler, C library, kernel, and applications. This capability is also added to the GitHub CI system, which is run on every PR/commit.

Time to build ia16-elf-gcc cross-compiler from scratch: 30+ minutes -> 11 minutes.
Time to build full ELKS C library, kernel and applications: 3-4 minutes -> 45 seconds (16-core MacBook Pro).

A number of ideas and code for this PR were previously submitted by @asiekierka in #2480 and @djohanse in #2695. Thank you both very much for your submissions, sorry it's taken so long. Also, thanks to @hexadec1mal for providing information and a possible fix for the sometimes-seen compiler-generated.h problem during the kernel build.

When running . env.sh to setup the ELKS environment, either sysctl (for macOS) or nproc (for Linux/CI) is used to obtain the number of cores available, which is then passed as an argument to make using make -j using the MAKEFLAGS environment variable. If parallel make building is not desired, edit env.sh and set MAKEFLAGS=.

There may be further speedups possible in the kernel build by optimizing the elf2elks/elftoolchain and elks-compress builds, as well as possibly speeding up buildext.sh, build.sh, buildimages.sh and image creation, which are still built sequentially.

This enhancement has been tested on macOS and on GitHub CI. While I believe all the bases are now covered with regards to potential problems in building the C library, kernel and applications, there may still be race conditions that come up. Now that I understand how parallel make actually works, hopefully any problems can be quickly fixed.

Now that I see the huge benefits in building ELKS using all cores, I realize this should have been done a long time ago. Thanks again to @asiekierka and @djohanse for pushing for this as well as providing code.

@ghaerr ghaerr merged commit 5da79cb into master Jun 15, 2026
2 checks passed
@ghaerr ghaerr deleted the parallel branch June 15, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant