Serenity: Building and running serenity under qemu on macOS host

Created on 21 Nov 2019  路  17Comments  路  Source: SerenityOS/serenity

Hi,

I would like to build and run serenity under qemu but under a macOS host.

Any inputs on how to do it?

All 17 comments

Hi, building on Mac is not supported (see ##597). However, you could do what I do and have a linux box setup with ssh and run qemu with the -vnc :0 option to connect remotely.

Ok, thanks for the information.

I got the GCC cross-compiler to work on the mac by modifying the build scripts, I will look into the successive steps. I think that there could be some value in patching the codebase to allow it being compiled on a non case sensitive FS, but for the time being I will try to create a dedicated case-sensitive volume. I have not been looking yet into how to mount ext2 filesystem on macOS, I think it should be possible, but I'm sure that there will be more "missing" commands that will need to be filled ;)

I will write in this issue if I will make any step forward.

I have been able to compile everything on macOS, using the gcc cross-compiler, patching errors as I was going.
I have compiled the build support DevTools (like the IPCCompiler) using XCode clang.

Main issues are:

  1. Replacing the only file that causes problems on non case-sensitive FS (String.h, renamed to CString.h and with a search&replace in the whole source tree to fix it)
  2. A few GCC only usages of the C++ standard (Q_OBJECT macro is not valid for abstract objects)
  3. A few linux specific things to ifdef inside CLocalSocket / CLocalServer / CEventLoop (SOCK_NONBLOCK | SOCK_CLOEXEC) when compiled as host (mainly for IPCCompiler & co)
  4. Making sure to set AR (not sure if also RANLIB) variables in Makefile.common to point them at the crosscompiler version

Just to check if everything was compiling fine, I have been spawning a VMWare VM to build the ext2 root filesystem image, and looks like it works!

Serenity on qemu-macOS

I will investigate if it's possible to create and fill the ext2 root filesystem from native macOS, somehow.

For some reason the WindowServer is not starting and so many components of the OS.
One thing I can read in the logs is:

WindowServer(20): perror(): open: Invalid argument

I will try to build under the vm and check any difference, it may just be a qemu under macOS behaving differently from the linux version.

Edit:
Upgrading to latest Qemu seems to fix everything.
Performance is very low, I could not get any qemu accelerator to work. The only supported one for i38 architecture is Intel HAXM but it crashes the OS during kernel boot

Nice! Would love to see the root fs build under Mac, but I don鈥檛 think it鈥檚 possible without major changes to scripts and the process and needing to install something like FUSE for macOS.

You're right, I've had to install:

  • FUSE (brew cask install osxfuse)
  • fuse-ext2 (https://github.com/alperakcan/fuse-ext2) (for mount support)
  • e2fsprogs (brew install e2fsprogrs) for mke2fs and add it to $PATH

I've also had to modify the build-root-filesystem.sh to have separate chmod, because macos mknod doesn't support the-m umask option.

Doing all of the above creates a bootable ext2 disk image suitable for booting the OS just fine.
I will check in the next days if everything works as expected.

The only remaining problem now to allow for regulare development on macOS is how to get some more speed out of qemu.

@Pagghiu I would love to see your fork of Serenity with these changes!

Sure, I can create a fork with the changes.
I will cleanup the modifications a little bit and testing them on a clean macOS to be sure that everything works properly. 馃憤

@Pagghiu I tried your fork on macOS 10.14.6 and build fails with this:

/usr/local/bin/ginstall -c -m 644 ../../tools/macosx/fuse-ext2.fs/Contents/Info.plist /Library/Filesystems/fuse-ext2.fs/Contents/Info.plist
/usr/local/bin/ginstall -c -m 644 ../../tools/macosx/fuse-ext2.fs/Contents/PkgInfo /Library/Filesystems/fuse-ext2.fs/Contents/PkgInfo
/usr/local/bin/ginstall -c -m 644 ../../tools/macosx/fuse-ext2.fs/Contents/Resources/English.lproj/InfoPlist.strings /Library/Filesystems/fuse-ext2.fs/Contents/Resources/English.lproj/InfoPlist.strings
/usr/local/bin/ginstall -c -d /Library/PreferencePanes
cp -R ../../tools/macosx/prefpane/build/Release/fuse-ext2.prefPane /Library/PreferencePanes/fuse-ext2.prefPane
cp: ../../tools/macosx/prefpane/build/Release/fuse-ext2.prefPane: No such file or directory
make[3]: *** [install-exec-local] Error 1
make[2]: *** [install-am] Error 2
make[1]: *** [install-recursive] Error 1
make: *** [install-recursive] Error 1
~/serenity

That's an error in the fuse-ext2 installation script that I 99% copy/pasted from https://github.com/alperakcan/fuse-ext2.
It looks the same described here https://github.com/alperakcan/fuse-ext2/issues/89 but I am not sure if the issue linked explains it fully but you could give it a look.

The error actual source error happens before the piece of log you're pasting because it's not generating the preference pane (fuse-ex2.prefPane).

I would also try to execute the install script making sure 'cd' the Toolchain directory that contains BuildFuseExt2.sh.

Thanks, the following fixed it for me:

  • Install Xcode
  • Run sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

I was also able to build/run on macos using your fork. Well done!

excellent!
I will rebase the branch every once in a while, to stay up to date with latest master ;-)
@awesomekling would you be interested into a pull request to allow for official macos support?

excellent!
I will rebase the branch every once in a while, to stay up to date with latest master ;-)
@awesomekling would you be interested into a pull request to allow for official macos support?

Sure why not :)

I suppose this may be closed now?

Yes, I think so 馃槂
I am still trying to stay up to date with things that break the macOS build every once in a while, but we will eventually open dedicated issues / PR on a case by case basis.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Lubrsi picture Lubrsi  路  4Comments

danboid picture danboid  路  6Comments

awesomekling picture awesomekling  路  3Comments

howar6hill picture howar6hill  路  3Comments

ZyorYT picture ZyorYT  路  6Comments