2021-07-09 22:53:28 +00:00
# Setting up a development environment on macOS
# Prerequisites
2022-01-07 12:04:05 +00:00
This installation guide assumes that you have [Homebrew ](https://brew.sh ) and Xcode installed. You need to open Xcode at least once for it to install the required tools.
2021-12-27 18:06:00 +00:00
Before you build, you must set your command line tools to Xcode's tools instead of the ones installed via Homebrew:
```console
sudo xcode-select --switch /Applications/Xcode.app
```
2021-07-09 22:53:28 +00:00
Make sure you also have all the following dependencies installed:
```console
# core
2022-12-17 22:39:53 +00:00
brew install coreutils e2fsprogs qemu bash imagemagick ninja cmake ccache rsync zstd
2021-07-09 22:53:28 +00:00
# (option 1) fuse + ext2
2021-07-29 12:05:25 +00:00
brew install m4 autoconf automake libtool
2022-01-18 01:24:07 +00:00
brew install --cask macfuse
2021-07-09 22:53:28 +00:00
Toolchain/BuildFuseExt2.sh
# (option 2) genext2fs
brew install genext2fs
2023-03-11 19:09:10 +00:00
# for kernel debugging, on Apple Silicon
brew install x86_64-elf-gdb
2021-07-09 22:53:28 +00:00
```
2022-12-17 22:39:53 +00:00
If you have Xcode version 13 or older, also install a newer host compiler from homebrew. Xcode 14 is known to work.
```console
brew install llvm@15
# OR
brew install gcc@12
```
# Notes
2023-03-11 19:08:16 +00:00
You can use both Intel and Apple Silicon Macs to run the x86-64 version of SerenityOS. You do not
need to install Rosetta for this. An emulator is used when running on an Apple Silicon, so Serenity
will be slower compared to running natively with hardware-assisted virtualization on an Intel machine.
2022-02-15 21:32:21 +00:00
If you're building on M1 Mac and have Homebrew installed in both Rosetta and native environments,
you have to make sure that required packages are installed only in one of the environments. Otherwise,
these installations can conflict during the build process, which is manifested in hard to diagnose issues.
Building on M1 natively without Rosetta is recommended, as the build process should be faster without Rosetta
overhead.
2022-12-17 22:39:53 +00:00
Installing macfuse for the first time requires enabling its system extension in System Preferences and then restarting your machine. The output from installing macfuse with brew says this, but it's easy to miss.
2021-07-09 22:53:28 +00:00
2022-12-17 22:39:53 +00:00
It's important to make sure that Xcode is not only installed but also accordingly updated, otherwise CMake will run into incompatibilities with GCC.
2022-12-17 22:40:08 +00:00
Homebrew is known to ship bleeding edge CMake versions, but building CMake from source with homebrew
2022-12-27 18:40:23 +00:00
gcc or llvm may not work. If homebrew does not offer cmake 3.25.x+ on your platform, it may be necessary
2022-12-17 22:40:08 +00:00
to manually run Toolchain/BuildCMake.sh with Apple clang from Xcode as the first compiler in your $PATH.
2023-03-11 19:09:10 +00:00
If you want to debug the x86-64 kernel on an Apple Silicon machine, you can install the `x86_64-elf-gdb`
package to get a native build of GDB that can cross-debug x86-64 code.