ClassiCube icon indicating copy to clipboard operation
ClassiCube copied to clipboard

macOS build should be a universal executable

Open UnknownShadow200 opened this issue 4 years ago • 6 comments

UnknownShadow200 avatar Sep 06 '21 07:09 UnknownShadow200

Regarding this (and Apple silicon builds in general), I've been getting a lot of deprecation warnings (removing Werror seems to fix these) mainly related to certs/crypto functionality and the Cocoa backend. In the end, though, the link fails with:

Undefined symbols for architecture arm64:
  "_CSSMOID_APPLE_X509_BASIC", referenced from:
      _Certs_VerifyChain in Certs.o
  "_SecCertificateCreateFromData", referenced from:
      _Certs_VerifyChain in Certs.o
  "_SecPolicySearchCopyNext", referenced from:
      _Certs_VerifyChain in Certs.o
  "_SecPolicySearchCreate", referenced from:
      _Certs_VerifyChain in Certs.o
  "_SecTrustCreateWithCertificates", referenced from:
      _Certs_VerifyChain in Certs.o
  "_SecTrustEvaluate", referenced from:
      _Certs_VerifyChain in Certs.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [ClassiCube] Error 1
make: *** [darwin] Error 2

iblowmymind avatar Aug 19 '25 19:08 iblowmymind

If you update to latest commit and try to compile now, does it work?

Unfortunately, ClassiCube does use a lot of obsolete APIs so that it works on old macOS versions.

UnknownShadow200 avatar Aug 19 '25 21:08 UnknownShadow200

Yes, I had to remove -Werror but the built completes successfully. Most of the errors are just deprecation warnings, however there are a few that aren't, related to Cocoa:

src/Window_cocoa.m:388:25: warning: sending 'CCWindowDelegate *' to parameter of incompatible type 'id<NSWindowDelegate> _Nullable'
  388 |         [winHandle setDelegate:del];
      |                                ^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:338:49: note: passing argument to parameter 'delegate' here
  338 | @property (nullable, weak) id<NSWindowDelegate> delegate;
      |                                                 ^
src/Window_cocoa.m:493:36: warning: passing 'const char *' to parameter of type 'const cc_uint8 *' (aka 'const unsigned char *') converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
  493 |                 i = Convert_Utf8ToCodepoint(&cp, src, len);
      |                                                  ^~~
src/String.h:197:63: note: passing argument to parameter 'data' here
  197 | int Convert_Utf8ToCodepoint(cc_codepoint* cp, const cc_uint8* data, cc_uint32 len);
      |                                                               ^
src/Window_cocoa.m:629:25: warning: incompatible pointer types sending 'CFStringRef' (aka 'const struct __CFString *') to parameter of type 'NSString * _Nonnull' [-Wincompatible-pointer-types]
  629 |         [alert setMessageText: titleCF];
      |                                ^~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSAlert.h:71:28: note: passing argument to parameter 'messageText' here
   71 | @property (copy) NSString *messageText;
      |                            ^
src/Window_cocoa.m:630:29: warning: incompatible pointer types sending 'CFStringRef' (aka 'const struct __CFString *') to parameter of type 'NSString * _Nonnull' [-Wincompatible-pointer-types]
  630 |         [alert setInformativeText: msgCF];
      |                                    ^~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSAlert.h:75:28: note: passing argument to parameter 'informativeText' here
   75 | @property (copy) NSString *informativeText;
      |                            ^

iblowmymind avatar Aug 20 '25 06:08 iblowmymind

Made a VERY hacky way of building a Universal executable as I don't really know my way around the Makefile here that well, sorry! I'll make a PR and you can give me suggestions on how to fix it up a little. I've observed gains of up to ~800 fps in my testing (M3 Pro MBP) from 1700 to 2500 when switching to an Apple silicon build.

iblowmymind avatar Aug 20 '25 07:08 iblowmymind

It seems like #1334 fixes the deprecation issues properly, would love to see that get merged.

iblowmymind avatar Aug 20 '25 07:08 iblowmymind

It seems like #1334 fixes the deprecation issues properly, would love to see that get merged.

I'd still prefer to look at another way of handling that, but it hasn't been high on the priority list unfortunately.

UnknownShadow200 avatar Aug 21 '25 13:08 UnknownShadow200