### Installing
```
brew install gnu-sed
brew install make
brew install gawk
brew install qemu
# ...for compiling x86_64 unikernes
brew install x86_64-elf-binutils
brew install x86_64-elf-gcc
# ...for compiling aarch-64 Unikernels
brew install aarch64-elf-binutils
brew install aarch64-elf-gcc
```
## Fresh install problems and how to fix them:
~~1. Wrong version of sed
Error Code: `sed: \1 not defined in the RE`
Solution => Installing gsed with homebrew and updating the $PATH in bash/zsh profile with the new version of sed~~ (SK: Fixed with build system)
~~2. Wrong version of bison
Error Code: `/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bison: invalid option -- W`~~
(SK: We switched to python-based KConfig to avoid this problem)
3. Wrong version of make
Solution => Call build system with `gmake`, like `gmake menuconfig`
(SK: I added a message saying, it should be invoked with gmake)
## Musl fix
PR: https://github.com/unikraft/lib-musl/pull/63 (SK: :+1:)
macOS (similar to Windows) is case insensitive and that causes an issue on Musl, as there are two "similar" files: _Exit.c and _exit.c.
Apply the following patch
```makefile
diff --git a/Makefile.uk.musl.exit b/Makefile.uk.musl.exit
index 93a72b3..e318d01 100644
--- a/Makefile.uk.musl.exit
+++ b/Makefile.uk.musl.exit
@@ -10,6 +10,8 @@ LIBMUSL_EXIT_HDRS-y += $(LIBMUSL)/include/stdio.h
LIBMUSL_EXIT_HDRS-y += $(LIBMUSL)/include/stdlib.h
LIBMUSL_EXIT_HDRS-y += $(LIBMUSL)/include/syscall.h
+$(LIBMUSL)/src/exit/__Exit.c: $(LIBMUSL_BUILD)/.origin
+ @ln $(LIBMUSL)/src/exit/_Exit.c $@
LIBMUSL_EXIT_SRCS-y += $(LIBMUSL_BASE)/abort.c
LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/abort_lock.c
@@ -17,7 +19,7 @@ LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/assert.c
LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/atexit.c
LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/at_quick_exit.c
LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/exit.c
-LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/_Exit.c
+LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/__Exit.c
LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/quick_exit.c
$(eval $(call _libmusl_import_lib,exit,$(LIBMUSL_EXIT_HDRS-y),$(LIBMUSL_EXIT_SRCS-y)))
```
## Aarch64 gcc unknown `-fcf-protection=none` flag
Remove the flag from`Makefile.uk`
PR that fixes it: https://github.com/unikraft/unikraft/pull/944 (SK: :+1:)
### How to compile with gcc for x86_64
~~
```bash
make CROSS_COMPILE=x86_64-elf-
```
~~
(SK: Not needed anymore, the build systems uses this setting when on Mac)
### How to compile with gcc for x86_64
~~
```bash
make CROSS_COMPILE=aarch64-elf-
```
~~
(SK: Not needed anymore, the build systems uses this setting when on Mac)
!! **clang is still work in progress**
### How to compile with clang for x86_64
```bash
make CC=<path-to-llvm-clang-installation> CFLAGS=--target=x86_64-unknown-linux-gnu LD=/opt/local/bin/x86_64-elf-gcc STRIP=/opt/local/bin/x86_64-elf-strip OBJCOPY=/opt/local/bin/x86_64-elf-objcopy
```
## Fix in order to make network work
As it is described in this issue, the fix should be live in QEMU from version 7.1.0:
https://gitlab.com/qemu-project/qemu/-/issues/465
## Example QEMU run command with network and filesystem support
```bash
sudo qemu-system-x86_64 \
-fsdev local,id=myid,path=$(pwd)/fs0,security_model=none \
-device virtio-9p-pci,fsdev=myid,mount_tag=fs0,disable-modern=on,disable-legacy=off \
-netdev vmnet-bridged,id=vmnet,ifname=en0 \
-device virtio-net-pci,netdev=vmnet \
-append "netdev.ipv4_addr=172.44.0.2 netdev.ipv4_gw_addr=172.44.0.1 netdev.ipv4_subnet_mask=255.255.255.0 --" \
-kernel build/nginx_qemu-x86_64 \
-nographic
```
(SK: `qemu-guest` is updated as well)
## Status of apps built (Plat/Arch/Compiler)
### app-helloworld
- [x] IntelMac/x86_64/gcc
- [x] IntelMac/aarch64/gcc
- [x] IntelMac/x86_64/clang
- [ ] IntelMac/aarch64/clang
- [x] SiliconeMac/x86_64/gcc
- [x] SiliconeMac/aarch64/gcc
- [ ] SiliconeMac/x86_64/clang
- [ ] SiliconeMac/aarch64/clang
### app-helloworld-cpp
- [ ] IntelMac/x86_64/gcc
- [ ] IntelMac/aarch64/gcc
- [ ] IntelMac/x86_64/clang
- [ ] IntelMac/aarch64/clang
- [ ] SiliconeMac/x86_64/gcc
- [ ] SiliconeMac/aarch64/gcc
- [ ] SiliconeMac/x86_64/clang
- [ ] SiliconeMac/aarch64/clang
### app-httpreply
- [x] IntelMac/x86_64/gcc
- [x] IntelMac/aarch64/gcc
- [ ] IntelMac/x86_64/clang
- [ ] IntelMac/aarch64/clang
- [x] SiliconeMac/x86_64/gcc
- [x] SiliconeMac/aarch64/gcc
- [ ] SiliconeMac/x86_64/clang
- [ ] SiliconeMac/aarch64/clang
### app-nginx
- [x] IntelMac/x86_64/gcc
- [x] IntelMac/aarch64/gcc
- [ ] IntelMac/x86_64/clang
- [ ] IntelMac/aarch64/clang
- [x] SiliconeMac/x86_64/gcc
- [x] SiliconeMac/aarch64/gcc
- [ ] SiliconeMac/x86_64/clang
- [ ] SiliconeMac/aarch64/clang
### app-python3
- [x] IntelMac/x86_64/gcc
- [x] IntelMac/aarch64/gcc
- [ ] IntelMac/x86_64/clang
- [ ] IntelMac/aarch64/clang
- [x] SiliconeMac/x86_64/gcc
- [x] SiliconeMac/aarch64/gcc
- [ ] SiliconeMac/x86_64/clang
- [ ] SiliconeMac/aarch64/clang
### app-redis
- [x] IntelMac/x86_64/gcc
- [x] IntelMac/aarch64/gcc
- [ ] IntelMac/x86_64/clang
- [ ] IntelMac/aarch64/clang
- [x] SiliconeMac/x86_64/gcc
- [x] SiliconeMac/aarch64/gcc
- [ ] SiliconeMac/x86_64/clang
- [ ] SiliconeMac/aarch64/clang
### app-sqlite
- [x] IntelMac/x86_64/gcc
- [ ] IntelMac/aarch64/gcc
- [x] IntelMac/x86_64/clang
- [ ] IntelMac/aarch64/clang
- [x] SiliconeMac/x86_64/gcc
- [x] SiliconeMac/aarch64/gcc
- [ ] SiliconeMac/x86_64/clang
- [ ] SiliconeMac/aarch64/clang