Skip to content

Latest commit

 

History

History
71 lines (54 loc) · 3.27 KB

building.md

File metadata and controls

71 lines (54 loc) · 3.27 KB

Building

Dependencies

  • The build system depends on Node.js and Git.
  • The compilation depends on NASM, and GCC, binutils, and LD that are able to build x86_64 ELF binaries.
    • (It would be nice if we could also support Clang, but the generated machine code (for both the kernel and userland) code crashes.)
  • Building the bootable ISO depends on GRUB 2.
  • Although you can use any emulator, the build system invokes QEMU.

Linux

Check if your distro's package manager has a prebuilt version of GCC/binutils/LD that supports x86_64 ELF. x86_64-elf-gcc. If not, follow these instructions to build your own GCC cross compiler.

Windows

You can find precompiled x86_64-elf binaries online with a bit of hunting. Examples:

Otherwise, you can follow these instructions to build your own GCC cross compiler.

Likewise with GRUB 2.

Otherwise, you can will have to [build GRUB 2 from source] (https://www.gnu.org/software/grub/grub-download.html).

Mac OS

If you have Homebrew, you can install everything you need with:

brew install node git nasm qemu llvm x86_64-elf-binutils i386-elf-grub xorriso
echo 'export PATH="/usr/local/brew/opt/llvm/bin:$PATH"' >> ~/.bash_profile

Preparation

  • Create a file Build/local-config.json with the paths to the above tools.
{
	"tools": {
		"ar": "llvm-ar",
		"gas": "llvm-mc",
		"nasm": "nasm",
		"gcc": "clang",
		"grub-mkrescue": "grub-mkrescue",
		"ld": "ld.lld",
		"qemu": "qemu-system-x86_64"
	},
	"parallel_tasks": 1
}

If you're unsure of what to set parallel_tasks to, try running ./build benchmark and it'll find the optimal value for the fastest builds on your system.

Building

Call all commands from inside the Build directory. Here are some useful ones:

  • ./build all - Builds everything. The kernel, all applications, and creates a Perception.iso in the root directory.
  • ./build run - Builds everything and starts QEMU.
  • ./build run <application> --local - Builds an application and runs it locally in the host OS.
  • ./build clean - Cleans up built files.
  • ./build all --prepare - Prepares applications and libraries (downloads third party files, generates auto-complete metadata, transpiles Permebuf files, etc.) without actually building anything.

You can lean more about the build system and more commands in Build/README.md.

Code Completion Support

Upon building, the build system generates .clang_complete files can be used for code completion. I use Sublime Text with EasyClangComplete which works out of the box. It's also helpful to tell your code completer that we're using C17 and C++20, and not to use default includes. If you're using Sublime with EasyClangComplete, you can open the project build/perception.sublime-project.