SheepShaver on Apple M1

About SheepShaver, a PPC Mac emulator for Windows, MacOS X, and Linux that can run System 7.5.3 to MacOS 9.0.4.

Moderators: Cat_7, Ronald P. Regensburg, ClockWise

shearer
Space Cadet
Posts: 8
Joined: Tue Nov 24, 2020 3:54 am

SheepShaver on Apple M1

Post by shearer »

Is there any possibility of seeing SheepShaver receive a native Apple M1 build in the future?

Currently the emulation runs quite slow compared to Intel, although this slowdown only appears mostly in the Finder. Many of the applications I tried that take over the screen have been running well.

Love this project and would love to see it continue to run well on current and future Macs.
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: SheepShaver on Apple M1

Post by Ronald P. Regensburg »

Good to know that SheepShaver runs on M1 Macs with the help of Rosetta 2.

I expect future arm64 or universal (x86_64 arm64) builds.

kanjitalk755 made his fork ready to build for Apple Silicon. It has not been tested yet. It seems the code was excluded later to avoid errors in Xcode 12.2

See his post in the forum here: viewtopic.php?p=67308#p67308
His fork is here: https://github.com/kanjitalk755/macemu

(kanjitalk755 fork is the source we use since a couple of years for BasiliskII and SheepShaver builds posted here in emaculation forum.)
Elyus
Tinkerer
Posts: 94
Joined: Wed Mar 21, 2012 12:35 am

Re: SheepShaver on Apple M1

Post by Elyus »

I've been experimenting with this on and off for a few days, and kanjitalk's fork does build, although you have to build a universal or native SDL2.framework to embed.

However, in a bizarre set of errors I've not really encountered before, arm64 SheepShaver currently refuses to launch. I've tried all sorts of different signing configurations, beta Xcode, and looking in various places to track down the errors. This is one problem with Apple's new processors which makes it tricky for developers—they're not really exposing enough information for developers to effectively debug certain issues.

Not being able to decrypt the errors or find any helpful resources myself, I gave up and joined Apple's Developer forum yesterday to ask about it: https://developer.apple.com/forums/thread/667698. Of course, it's good to have a post here as well; kanjitalk is exceedingly knowledgeable and may have some ideas about the source of the problem.

It's worth noting, even if we can get the build to launch, there's still some things to overcome. Notably, sigsegv for handling illegal instructions doesn't seem to support arm64 threads and registers. Regardless, I'm confident the jump to M1 will happen soon, and I'm looking forward to seeing the types of speed benefits the single-core focus of Apple's M1 will provide.
shearer
Space Cadet
Posts: 8
Joined: Tue Nov 24, 2020 3:54 am

Re: SheepShaver on Apple M1

Post by shearer »

Good to hear - can’t wait to see how it will perform on the new chips!
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Re: SheepShaver on Apple M1

Post by emendelson »

Has anyone tried building SS or BII for M1 recently??
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: SheepShaver on Apple M1

Post by Ronald P. Regensburg »

Not that I am aware of. Earlier trials resulted in error messages. I suppose that kanjitalk755 will need assistance with debugging.

BTW: It may be better to speak of building for arm64 or for Apple Silicon, M1 is only the first member of that family.
Jagmn
Student Driver
Posts: 20
Joined: Fri Feb 19, 2021 7:37 am

Re: SheepShaver on Apple M1

Post by Jagmn »

Just a heads up that I've been experimenting with building SS on the M1. It looks like the main issue is that the zeropage_size linker setting results in binaries that just won't run on aarch64 - though I'm willing to be challenged on this.

After some considerable delving into SS's memory management, I've got something booting that creates a more dynamic Mac<->host memory map but I need to spend more time understanding and cleaning everything up before it'd be ready for a patch. If anyone has a cleaner approach (amidst the plethora of memory approaches there already seems to be) do shout out!
Jagmn
Student Driver
Posts: 20
Joined: Fri Feb 19, 2021 7:37 am

Re: SheepShaver on Apple M1

Post by Jagmn »

For those interested in a native M1 build:

I've managed to get a fairly minimal set of changes to build SS for the M1 using the NATMEM_OFFSET build time option.

Running MacBench 5 against a few build combinations on the M1 shows that the SheepShaver JIT on x86_64 (under Rosetta 2) beats the native aarch64 build (which does not have JIT enabled / needs more work to port the JIT across). If you disable the x86_64 JIT then the aarch64 native build is faster but not by orders of magnitude.
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: SheepShaver on Apple M1

Post by Ronald P. Regensburg »

What is the difference between aarch64 and arm64, or is it the same? Apple refers to it as arm64 (or Apple Silicon).
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SheepShaver on Apple M1

Post by adespoton »

aarch64 is what the QEMU project calls its ARM 64-bit Architecture core. It's essentially synonymous with ARM64.
Jagmn
Student Driver
Posts: 20
Joined: Fri Feb 19, 2021 7:37 am

Re: SheepShaver on Apple M1

Post by Jagmn »

Whew. So I've managed to get the JIT running on the M1. What a learning experience that has been! No-where near ready to have anything to submit upstream but it seems to work and boosts performance well above the x86_64-JIT-on-Rosetta experience (nearly 2x).

Probably not the right thread for the query but: it looks like SheepShaver's JIT was based on an old version of QEMU. Has anyone looked at getting a modern QEMU JIT working instead?
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SheepShaver on Apple M1

Post by adespoton »

I stopped using JIT over 5 years ago, due to it being less stable, and no-JIT being more than fast enough.

Do you see an advantage to running M1 JIT over M1 no-JIT? Is M1 no-JIT faster than R2-JIT?
Jagmn
Student Driver
Posts: 20
Joined: Fri Feb 19, 2021 7:37 am

Re: SheepShaver on Apple M1

Post by Jagmn »

I see definite speed advantages with JIT vs no-JIT. This is helpful as I like to do graphics work in OS9 apps and the boost makes it easier/nicer for me to work with larger files.

I've been using MacBench 5.0 to compare speeds. My current set of results all running under Apple's M1:
  • SS Downloaded running w/JIT in Rosetta 2: 271%
  • SS Built for M1 running w/JIT: 470%
  • SS Downloaded running w/NoJIT in Rosetta 2: 73%
  • SS Built for M1 running w/NoJIT: 96%
The benchmark number (100%) is against a PowerMac G3 300Mhz.
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SheepShaver on Apple M1

Post by adespoton »

Interesting... so M1 JIT is performing at an approximate equivalent of a 1.4GHz PPC!
I should run MacBench 5 on my Intel machine and see how it compares.

One note of worth is that the old benchmarking tools often show wildly skewed results on emulators due to what does and doesn't get emulated accurately. I presume you have "Don't Use CPU When Idle" disabled?
Jagmn
Student Driver
Posts: 20
Joined: Fri Feb 19, 2021 7:37 am

Re: SheepShaver on Apple M1

Post by Jagmn »

I do have "idlewait true" in my preferences file. I haven't experimented with flipping it.

With regards to the JIT being buggy: I do see some flakiness occasionally and am zoning in on where I think the problem is (jit-cache invalidate + branching/block behaviour around that).
shearer
Space Cadet
Posts: 8
Joined: Tue Nov 24, 2020 3:54 am

Re: SheepShaver on Apple M1

Post by shearer »

It looks like we now have a native build for M1 and this is working well for others! Very excited to try it out.
Unfortunately it won't run on my M1 Mac Mini, it closes immediately at startup.

The Intel version of SheepShaver still launches just fine. What should I be looking at to troubleshoot this? It's as if the M1 SheepShaver can't locate my Mac OS ROM file, is there a file I can edit to point it in the right direction?

I've looked at the documentation and other threads but couldn't find an answer, thanks in advance.

Edit: Interestingly, when I open the app using Rosetta it does launch just like the Intel build. But this doesn't give me any speed advantages.
Last edited by shearer on Tue May 18, 2021 9:08 pm, edited 1 time in total.
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: SheepShaver on Apple M1

Post by Ronald P. Regensburg »

The app should be installed in the same location as the working Intel version.
If it is, and it quits on launch, you may have been bitten by a security feature in macOS.
Try this:
- Copy the SheepShaver application to a different location, like your desktop
- Trash the original application
- Move the copy back to the location where you installed the original
shearer
Space Cadet
Posts: 8
Joined: Tue Nov 24, 2020 3:54 am

Re: SheepShaver on Apple M1

Post by shearer »

Ronald P. Regensburg wrote: Tue May 18, 2021 9:08 pm The app should be installed in the same location as the working Intel version.
If it is, and it quits on launch, you may have been bitten by a security feature in macOS.
Try this:
- Copy the SheepShaver application to a different location, like your desktop
- Trash the original application
- Move the copy back to the location where you installed the original
Thanks, I have followed these steps but it hasn't given me a different result. It still won't launch, however when I tell it to open in Rosetta, it does launch (at a similar or the same speeds as the Intel build on a M1 Mac).
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: SheepShaver on Apple M1

Post by Ronald P. Regensburg »

This build is supposed to run natively on arm64. I cannot test it myself, the M1 iMac I ordered will arrive next month. The Intel part of this first universal build should be identical to the final Intel build, so you might as well use that one for now.
shearer
Space Cadet
Posts: 8
Joined: Tue Nov 24, 2020 3:54 am

Re: SheepShaver on Apple M1

Post by shearer »

Will do, I'll keep an eye out to see anyone else mention similar issues.
Jagmn
Student Driver
Posts: 20
Joined: Fri Feb 19, 2021 7:37 am

Re: SheepShaver on Apple M1

Post by Jagmn »

shearer wrote: Tue May 18, 2021 9:35 pm Will do, I'll keep an eye out to see anyone else mention similar issues.
The Universal build (SheepShaver_universal_20210428.zip) seems to run fine for me (well; a boot, reboot, launch-app test works without issue).
What do you see if you try running it from Terminal.app? You can launch terminal then run the following:

Code: Select all

/path/to/SheepShaver.app/Contents/MacOS/SheepShaver
(You can drag-n-drop the SheepShaver.app file to get the /path/to/SheepShaver.app portion, then add the /Contents/MacOS/SheepShaver part.)

When I run that build with my ROM and OS9.0.4 disk, I get:

Code: Select all

SheepShaver V2.5 by Christian Bauer and Mar"c" Hellwig
Reading ROM file...
Using SDL/coreaudio audio output
selected Ethernet device type slirp
Using SDL_Renderer driver: metal
PowerPC CPU emulator by Gwenole Beauchesne
ioctl(DKIOCCDREADTOC) failed: Bad file descriptor
ioctl(DKIOCCDREADTOC) failed: Bad file descriptor
WARNING: Unknown DiskStatus(6)
WARNING: Unknown DiskStatus(6)
shearer
Space Cadet
Posts: 8
Joined: Tue Nov 24, 2020 3:54 am

Re: SheepShaver on Apple M1

Post by shearer »

Jagmn wrote: Wed May 19, 2021 12:39 pm
shearer wrote: Tue May 18, 2021 9:35 pm Will do, I'll keep an eye out to see anyone else mention similar issues.
The Universal build (SheepShaver_universal_20210428.zip) seems to run fine for me (well; a boot, reboot, launch-app test works without issue).
What do you see if you try running it from Terminal.app? You can launch terminal then run the following:

Code: Select all

/path/to/SheepShaver.app/Contents/MacOS/SheepShaver
(You can drag-n-drop the SheepShaver.app file to get the /path/to/SheepShaver.app portion, then add the /Contents/MacOS/SheepShaver part.)

When I run that build with my ROM and OS9.0.4 disk, I get:

Code: Select all

SheepShaver V2.5 by Christian Bauer and Mar"c" Hellwig
Reading ROM file...
Using SDL/coreaudio audio output
selected Ethernet device type slirp
Using SDL_Renderer driver: metal
PowerPC CPU emulator by Gwenole Beauchesne
ioctl(DKIOCCDREADTOC) failed: Bad file descriptor
ioctl(DKIOCCDREADTOC) failed: Bad file descriptor
WARNING: Unknown DiskStatus(6)
WARNING: Unknown DiskStatus(6)
Thanks for this, when I launch it via the terminal I can launch SheepShaver on this M1 Mac Mini.
When I double click the app icon in the Finder it doesn't launch.

This is what it tells me:

Code: Select all

SheepShaver V2.5 by Christian Bauer and Mar"c" Hellwig
Reading ROM file...
Using SDL/coreaudio audio output
selected Ethernet device type slirp
Using SDL_Renderer driver: metal
Detected CPU features: MMX SSE SSE2 SSE3 SSSE3
PowerPC CPU emulator by Gwenole Beauchesne
WARNING: Unknown DiskStatus(6)
WARNING: Unknown DiskStatus(6)
WARNING: Unknown DiskStatus(6)
WARNING: Unknown DiskStatus(6)
Strangely enough, using this method it feels like it is still running using Rosetta. The boot and response speed is the same.
My old Intel Macbook Pro runs SheepShaver about 3x faster, so that doesn't seem right.
Last edited by shearer on Thu May 20, 2021 7:02 pm, edited 2 times in total.
shearer
Space Cadet
Posts: 8
Joined: Tue Nov 24, 2020 3:54 am

Re: SheepShaver on Apple M1

Post by shearer »

I just noticed I had set my entire Terminal to run using Rosetta for another project.
When I disable that and launch SheepShaver with your instructions, it fails to launch and sends me this message:

Code: Select all

SheepShaver V2.5 by Christian Bauer and Mar"c" Hellwig
ERROR: Cannot map ROM: Cannot allocate memory.


EDIT: And this solves the problem. I had my SheepShaver setup to use 1,024MB in RAM. I booted in Rosetta and changed this to 512MB, and now it launches just fine (and fast!) without Rosetta!
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: SheepShaver on Apple M1

Post by Ronald P. Regensburg »

SheepShaver is inflexible in which location in memory it uses. The error is typical for when other processes are occupying that specific location in memory. I was about to ask you if SheepShaver would launch after a restart of your Mac Mini. Usually that solves the problem.

Good that you solved it by assigning less RAM. And 512 MB is plenty for most purposes.
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SheepShaver on Apple M1

Post by adespoton »

Ronald P. Regensburg wrote: Thu May 20, 2021 7:19 pm SheepShaver is inflexible in which location in memory it uses. The error is typical for when other processes are occupying that specific location in memory. I was about to ask you if SheepShaver would launch after a restart of your Mac Mini. Usually that solves the problem.

Good that you solved it by assigning less RAM. And 512 MB is plenty for most purposes.
Hmm... you just gave me an idea. SheepShaver uses fixed memory references and so needs that particular chunk of memory. I wonder how difficult it would be to add a memmap routine such that it still requires a contiguous chunk, but it doesn't have to start at 0? Windows, macOS and Linux all support this now, so in theory it *should* be possible with a single added function in the setup routine.
Post Reply