Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Universal Binary for Apple Silicon #13708

Closed
thebitstick opened this issue Nov 24, 2020 · 12 comments · Fixed by #14839
Closed

Universal Binary for Apple Silicon #13708

thebitstick opened this issue Nov 24, 2020 · 12 comments · Fixed by #14839

Comments

@thebitstick
Copy link

What happens?

PPSSPP crashes due to x86-64 SDL2 not being present.

What should happen?

PPSSPP running normally.

What hardware, operating system, and PPSSPP version? On desktop, GPU matters for graphical issues.

Mac Mini (2020) with Apple M1, macOS Big Sur 11.0.1

I originally was going to submit an issue asking for just an ARM binary for Apple Silicon, but I had remembered that I uninstalled Homebrew and installed MacPorts because it has an ARM version of SDL2 ready.
I would try to just symlink the libraries from MacPorts to where PPSSPP looks for them, but it wouldn't even work because x86-64 applications can't use use ARM libraries.
At the moment Homebrew is not available for Apple Silicon, so it might not be possible to fix for now, but when it arrives, and an ARM SDL2 is ready, an Universal Binary will be needed.

@hrydgard
Copy link
Owner

I aim to support M1 natively but it will be a little while.

@tonyunreal
Copy link

Just found out today that Homebrew has an arm64 (Apple Silicon) bottle for PPSSPP 1.11:
https://formulae.brew.sh/formula/ppsspp

Not sure who the maintainer is or whether it contains any hack from the original source code, but it runs well on my M1 Mac mini. Can we assume this issue is solved?

@janmalec
Copy link

I managed to compile it on M1 cpu by adding the flag -DUSE_DISCORD=0 and no other modifications

@tonyunreal
Copy link

I managed to compile it on M1 cpu by adding the flag -DUSE_DISCORD=0 and no other modifications

Thanks for the tip janmalec, the official source code build fine with this flag.

I had to disable qt (official instructions says use --qtbrew) and replace the outdated MoltenVK library to get Vulkan working.

Strangely, my build crashed mid-game after about 5 minutes of playing, macOS complained about VM memory allocation or something like that. It never happened with the Homebrew bottled version, I wonder if it was caused by a recent glitch in the code, or if there is more tweak we didn't know of.

@unknownbrackets
Copy link
Collaborator

Hm, we're already returning true on PlatformIsWXExclusive(). What was the specific VM memory allocation error message?

-[Unknown]

@hrydgard
Copy link
Owner

Huh, I could compile it without even disabling the Discord stuff, and it works just fine, didn't have any crashes in maybe 30 min of playing...

@tonyunreal
Copy link

tonyunreal commented Feb 12, 2021

Hm, we're already returning true on PlatformIsWXExclusive(). What was the specific VM memory allocation error message?

Weird, I couldn't get it to crash again, so it was completely random. I did find the crash log from last time it happened though, here's the log:

PPSSPPSDL_2021-02-12-134828_minione.crash.txt

@tonyunreal
Copy link

Huh, I could compile it without even disabling the Discord stuff, and it works just fine, didn't have any crashes in maybe 30 min of playing...

The discord linking error only happens when qt is enabled. Maybe the building instructions should tell people to use ./b.sh instead of ./b.sh --qtbrew ?

Undefined symbols for architecture arm64:
  "_CFStringCreateWithCString", referenced from:
      _Discord_Register in libdiscord-rpc.a(discord_register_osx.m.o)
  "_LSRegisterURL", referenced from:
      _Discord_Register in libdiscord-rpc.a(discord_register_osx.m.o)
  "_LSSetDefaultHandlerForURLScheme", referenced from:
      _Discord_Register in libdiscord-rpc.a(discord_register_osx.m.o)
  "_NSHomeDirectory", referenced from:
      _Discord_Register in libdiscord-rpc.a(discord_register_osx.m.o)
  "_OBJC_CLASS_$_NSBundle", referenced from:
      objc-class-ref in libdiscord-rpc.a(discord_register_osx.m.o)
  "_OBJC_CLASS_$_NSFileManager", referenced from:
      objc-class-ref in libdiscord-rpc.a(discord_register_osx.m.o)
  "_OBJC_CLASS_$_NSString", referenced from:
      objc-class-ref in libdiscord-rpc.a(discord_register_osx.m.o)
  "___CFConstantStringClassReference", referenced from:
      CFString in libdiscord-rpc.a(discord_register_osx.m.o)
      CFString in libdiscord-rpc.a(discord_register_osx.m.o)
      CFString in libdiscord-rpc.a(discord_register_osx.m.o)
      CFString in libdiscord-rpc.a(discord_register_osx.m.o)
      CFString in libdiscord-rpc.a(discord_register_osx.m.o)
      CFString in libdiscord-rpc.a(discord_register_osx.m.o)
  "_objc_autoreleasePoolPop", referenced from:
      _Discord_Register in libdiscord-rpc.a(discord_register_osx.m.o)
  "_objc_autoreleasePoolPush", referenced from:
      _Discord_Register in libdiscord-rpc.a(discord_register_osx.m.o)
  "_objc_msgSend", referenced from:
      _Discord_Register in libdiscord-rpc.a(discord_register_osx.m.o)
ld: symbol(s) not found for architecture arm64

libdiscord-rpc.a/discord_register_osx.m.o reports back with arm64 support though:

% file discord_register_osx.m.o

discord_register_osx.m.o: Mach-O 64-bit object arm64

@hrydgard
Copy link
Owner

hrydgard commented Feb 12, 2021

Right, I rarely bother with the qt build, it's kind of fallen behind a bit (no Vulkan support). Should fix that though.

@unknownbrackets
Copy link
Collaborator

KERN_INVALID_ADDRESS at 0x0000000341cfc802
x4: 0x0000000341cfc800
x19: 0x0000000291004b20 SP
x23: 0x00000000088b6a10 RA
x24: 0x0000000000005dba downcount
x26: 0x0000000113000000 jitbase
x27: 0x0000000102dcc880 ctx
x28: 0x0000000287008000 membase

This looks to have happened within jit. We tried to access 0x0000000341cfc802 - 0x0000000287008000 = 0xBACF4802 / 0x3ACF4802 unmasked, which is a nonsense address. x22 is 0x00000000bacf4800 (v1), so it likely came from that. Hm.

-[Unknown]

@halpz
Copy link

halpz commented Mar 23, 2021

doesn't work for me - I get:

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc 
Build flags: 
Id flags:  

The output was:
1
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ 
Build flags: 
Id flags:  

The output was:
1
ld: library not found for -lc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Checking whether the ASM compiler is GNU using "--version" did not match "(GNU assembler)|(GCC)|(Free Software Foundation)":
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: arm64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@unknownbrackets
Copy link
Collaborator

Does this work any better if you try with latest git?

I'm not sure about the lSystem and lc++ issues. That seems like toolchain issues where your compiler isn't setup to be able to build anything, or else is trying to cross compile.

-[Unknown]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants