wangqr / Aegisub

Win64 nightly builds available at GHA artifact, also at following link:
https://ftp.wangqr.tk/aegisub/
Other
799 stars 49 forks source link

Universal Binary for macOS 11 #77

Open thebitstick opened 4 years ago

thebitstick commented 4 years ago

Aegisub works fine under Rosetta 2 but a native arm64 binary would be nice.

wangqr commented 4 years ago

I don't have a ARM mac. I'll look into ways to cross compile arm64 from intel mac. The main consern is LuaJIT, as the current build script assumes x86. Other libraries are in C/C++ and probably works just fine on arm64.

thebitstick commented 4 years ago

I'm more than willing to test out any builds.

LuaJIT seems to run on iOS? They have information on older revisions of ARM, so I'm sure it won't be extremely difficult.

bzq2810 commented 3 years ago

I tried to build the native bundle for Apple Silicon with the following cmds:

export CPPFLAGS="-I/opt/homebrew/opt/icu4c/include -I/opt/homebrew/include"
export LDFLAGS="-L/opt/homebrew/opt/icu4c/lib"
export PATH="/opt/homebrew/opt/icu4c/bin:/opt/homebrew/opt/icu4c/sbin:$PATH"
export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig"
./autogen.sh
./configure --with-boost-libdir="/opt/homebrew/Cellar/boost/1.75.0_1/lib"
make osx-bundle

I got the "Aegisub.app" successfully. However, the app crashed at launch. You can find the crash log here.

Any suggestion to make the app runnable? Thanks.

al3xtjames commented 3 years ago

You might need to sign the binary (using codesign -s - Aegisub.app - not sure if this also covers libraries). Apple Silicon Macs require binaries to be signed, though you can use an ad-hoc signature (which is what codesign -s - does).

bzq2810 commented 3 years ago

@al3xtjames Thanks for the advice. The codesign does not work. The crash log remains the same.

wangqr commented 3 years ago

Can you try codesign --deep -s - Aegisub.app? The --deep option will recursively sign dylibs that are needed by aegisub. After that you can verify the signature with codesign -dvvv Aegisub.app

bzq2810 commented 3 years ago

@wangqr The app still crashes with the same log even after add the --deep option. codesign -dvvv Aegisub.app shows the following:

Executable=/Users/ziqiang/Documents/Aegisub/Aegisub.app/Contents/MacOS/aegisub
Identifier=com.aegisub.aegisub
Format=app bundle with Mach-O thin (arm64)
CodeDirectory v=20400 size=406892 flags=0x2(adhoc) hashes=12709+3 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=4bc1f9fb38ae80f955d733c8c2ea6f5a57ccb65d
CandidateCDHashFull sha256=4bc1f9fb38ae80f955d733c8c2ea6f5a57ccb65d991e8e672f33dd3c30c0bf4d
Hash choices=sha256
CMSDigest=4bc1f9fb38ae80f955d733c8c2ea6f5a57ccb65d991e8e672f33dd3c30c0bf4d
CMSDigestType=2
CDHash=4bc1f9fb38ae80f955d733c8c2ea6f5a57ccb65d
Signature=adhoc
Info.plist entries=18
TeamIdentifier=not set
Sealed Resources version=2 rules=13 files=191
Internal requirements count=0 size=12

It seems the app has already been signed. I tried to codesign the wxmac related libraries with codesign -f -s - Aegisub.app/Contents/MacOS/libwx* and get the following results:

Aegisub.app/Contents/MacOS/libwx_baseu-3.0.0.5.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_baseu-3.0.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_baseu-3.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_baseu_net-3.0.0.5.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_baseu_net-3.0.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_baseu_net-3.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_baseu_xml-3.0.0.5.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_baseu_xml-3.0.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_baseu_xml-3.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_osx_cocoau_adv-3.0.0.5.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_osx_cocoau_adv-3.0.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_osx_cocoau_adv-3.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_osx_cocoau_core-3.0.0.5.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_osx_cocoau_core-3.0.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_osx_cocoau_core-3.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_osx_cocoau_gl-3.0.0.5.0.dylib: replacing existing signature
Aegisub.app/Contents/MacOS/libwx_osx_cocoau_gl-3.0.0.5.0.dylib: the codesign_allocate helper tool cannot be found or used

Have a look at the last line, it says that the codesign_allocate helper tool cannot be found when signing the libwx_osx_cocoau_gl-3.0.0.5.0.dylib. However, other libraries are signed with no problems. And I also find the crash logs contain the following lines related to the libwx_osx_cocoau_gl-3.0.0.5.0.dylib.

Application Specific Information:
dyld: launch, loading dependent libraries
@executable_path/libwx_osx_cocoau_gl-3.0.0.5.0.dylib
wangqr commented 3 years ago

You might want to check the signature on libwx_osx_cocoau_gl with codesign -dvvv Aegisub.app/Contents/MacOS/libwx_osx_cocoau_gl-3.0.0.5.0.dylib.

As for the codesign_allocate issue, can you run codesign_allocate directly? If not you might need to add it to PATH. On my intel mac it is located at /Library/Developer/CommandLineTools/usr/bin/codesign_allocate and /usr/bin/codesign_allocate

bzq2810 commented 3 years ago

codesign -dvvv Aegisub.app/Contents/MacOS/libwx_osx_cocoau_gl-3.0.0.5.0.dylib:

Executable=/Users/ziqiang/Documents/Aegisub/Aegisub.app/Contents/MacOS/libwx_osx_cocoau_gl-3.0.0.5.0.dylib
Identifier=libwx_osx_cocoau_gl-3-55554944a8d9bdbebd7631bab4e0791c5bd47c6c
Format=Mach-O thin (arm64)
CodeDirectory v=20400 size=1207 flags=0x2(adhoc) hashes=31+2 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=596800413096d076ad220cc7ecb7188c796ea73f
CandidateCDHashFull sha256=596800413096d076ad220cc7ecb7188c796ea73f7778f33de0888d087fe107d8
Hash choices=sha256
CMSDigest=596800413096d076ad220cc7ecb7188c796ea73f7778f33de0888d087fe107d8
CMSDigestType=2
CDHash=596800413096d076ad220cc7ecb7188c796ea73f
Signature=adhoc
Info.plist=not bound
TeamIdentifier=not set
Sealed Resources=none
Internal requirements count=0 size=12

That seems no difference when comparing with other signed libraries.

locate codesign_allocate:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate-p
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man/man1/codesign_allocate.1
/Library/Developer/CommandLineTools/usr/bin/codesign_allocate
/Library/Developer/CommandLineTools/usr/bin/codesign_allocate-p
/Library/Developer/CommandLineTools/usr/share/man/man1/codesign_allocate.1
/usr/bin/codesign_allocate
/usr/libexec/DeveloperTools/codesign_allocate

which codesign_allocate:

/usr/bin/codesign_allocate

I tried to switch to the codesign_allocate binary in other locations by modifying the sequence of PATH, got the same results. I don't think this is the codesign_allocate problem. Otherwise, the other libraries cannot be signed properly.

PutoML commented 3 years ago

For what it’s worth, if I run codesign --deep -f -s - Aegisub.app, the resulting binary loads for me, though it fails at loading any lua scripts whatsoever, with the following error:

attempt to index global 'aegisub' (a nil value)

XStylus commented 3 years ago

Just adding my voice to the choir. Aegisub r9198 does not launch for me on a brand new Mac Mini 2020 w/16GB memory.

/Applications/Aegisub.app/Contents/MacOS/aegisub ; exit;
veditproto@NeoRetro ~ % /Applications/Aegisub.app/Contents/MacOS/aegisub ; exit;
2021-08-31 16:01:52.873 aegisub[907:14273] *** Terminating app due to uncaught exception 'NSGenericException', reason: '-[NSAlert runModal] may not be invoked inside of transaction begin/commit pair, or inside of transaction commit (usually this means it was invoked inside of a view's -drawRect: method.)'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff205a945f __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007fff202e1bbb objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff205a92c3 +[NSException raise:format:] + 181
    3   AppKit                              0x00007fff2350b592 _NSRunModal + 152
    4   AppKit                              0x00007fff22fc59f9 -[NSAlert runModal] + 225
    5   libwx_osx_cocoau_core-3.1.5.0.0.dyl 0x00000001117c8479 _ZN15wxMessageDialog9ShowModalEv + 417
    6   libwx_osx_cocoau_core-3.1.5.0.0.dyl 0x000000011172de27 _Z12wxMessageBoxRK8wxStringS1_lP8wxWindowii + 93
    7   aegisub                             0x0000000102e0ddd5 _ZN10AegisubApp18UnhandledExceptionEb + 1493
    8   aegisub                             0x0000000102e0df9a _ZN10AegisubApp16OnFatalExceptionEv + 26
    9   libwx_baseu-3.1.5.0.0.dylib         0x00000001125453ef _ZL20wxFatalSignalHandleri + 28
    10  libsystem_platform.dylib            0x00007fff2047bd7d _sigtramp + 29
    11  ???                                 0x0000000000000001 0x0 + 1
    12  CoreImage                           0x00007fff28fc8b1f ___ZL13can_use_metalv_block_invoke + 27
    13  libdispatch.dylib                   0x00007fff2028c806 _dispatch_client_callout + 8
    14  libdispatch.dylib                   0x00007fff2028d98c _dispatch_once_callout + 20
    15  CoreImage                           0x00007fff28f31d34 -[CIContext initWithOptions:] + 1168
    16  CoreUI                              0x00007fff27240ffb __38+[CUIShapeEffectStack sharedCIContext]_block_invoke + 70
    17  libdispatch.dylib                   0x00007fff2028c806 _dispatch_client_callout + 8
    18  libdispatch.dylib                   0x00007fff2028d98c _dispatch_once_callout + 20
    19  CoreUI                              0x00007fff27240fb3 +[CUIShapeEffectStack sharedCIContext] + 42
    20  CoreUI                              0x00007fff2723c2b2 _ZNK11CUIRenderer35CreateImageByApplyingEffectsToImageEPK13CUIDescriptorlPK9__CFArrayP7CGImagedhhR11CGBlendModeb + 13922
    21  CoreUI                              0x00007fff27237c71 _ZNK11CUIRenderer11CreateImageE6CGRectlPK13CUIDescriptorhPP7CGImagePxPhP11CGBlendMode + 5393
    22  CoreUI                              0x00007fff2725c97d _ZN11CUIRenderer28CreateLayerContentsFromImageEPK13CUIDescriptorPP7CGImageP6CGRect + 621
    23  CoreUI                              0x00007fff2725554a _ZN11CUIRenderer19CreateLayerContentsEPK14__CFDictionaryPP7CGImageP6CGRect + 236
    24  CoreUI                              0x00007fff2725542d CUICreateLayerContents + 131
    25  AppKit                              0x00007fff22cb6783 __52-[NSAppearance _createLayerContents:contentsCenter:]_block_invoke + 38
    26  AppKit                              0x00007fff22c69e8c -[NSCompositeAppearance _callCoreUIWithBlock:options:requireBezelTintColor:] + 399
    27  AppKit                              0x00007fff22cb6722 -[NSAppearance _createLayerContents:contentsCenter:] + 118
    28  AppKit                              0x00007fff22e92b29 NSCoreUIImageEffectsGetEffectedImage + 124
    29  AppKit                              0x00007fff23285a5a ___NSImageViewPerformBlockWithLayerContentsForImage_block_invoke + 154
    30  AppKit                              0x00007fff22c4be95 +[NSAppearance _performWithCurrentAppearance:usingBlock:] + 66
    31  AppKit                              0x00007fff22dd4402 -[_NSSimpleImageView updateLayer] + 1608
    32  AppKit                              0x00007fff22d39cac _NSViewUpdateLayer + 98
    33  AppKit                              0x00007fff22c4be95 +[NSAppearance _performWithCurrentAppearance:usingBlock:] + 66
    34  AppKit                              0x00007fff22eac093 __30-[_NSViewBackingLayer display]_block_invoke + 113
    35  AppKit                              0x00007fff22c8b0fd -[NSFocusStack performWithFocusView:inWindow:usingBlock:] + 92
    36  AppKit                              0x00007fff22d39635 -[_NSViewBackingLayer display] + 382
    37  QuartzCore                          0x00007fff26f1f6f3 _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 863
    38  QuartzCore                          0x00007fff2706abee _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 666
    39  QuartzCore                          0x00007fff26f00b6f _ZN2CA11Transaction6commitEv + 713
    40  AppKit                              0x00007fff22f34452 _NSTryRunModal + 70
    41  AppKit                              0x00007fff22fc5991 -[NSAlert runModal] + 121
    42  libwx_osx_cocoau_core-3.1.5.0.0.dyl 0x00000001117c8479 _ZN15wxMessageDialog9ShowModalEv + 417
    43  libwx_osx_cocoau_core-3.1.5.0.0.dyl 0x000000011172de27 _Z12wxMessageBoxRK8wxStringS1_lP8wxWindowii + 93
    44  aegisub                             0x0000000102e0ddd5 _ZN10AegisubApp18UnhandledExceptionEb + 1493
    45  aegisub                             0x0000000102e0df9a _ZN10AegisubApp16OnFatalExceptionEv + 26
    46  libwx_baseu-3.1.5.0.0.dylib         0x00000001125453ef _ZL20wxFatalSignalHandleri + 28
    47  libsystem_platform.dylib            0x00007fff2047bd7d _sigtramp + 29
    48  ???                                 0x0000000000000000 0x0 + 0
    49  AGXMetal13_3                        0x0000000131692d1a AGXMetal13_3 + 7265562
    50  libdispatch.dylib                   0x00007fff2028c806 _dispatch_client_callout + 8
    51  libdispatch.dylib                   0x00007fff2028d98c _dispatch_once_callout + 20
    52  AGXMetal13_3                        0x0000000130fb15a7 AGXMetal13_3 + 50599
    53  AGXMetal13_3                        0x0000000130fd8be5 AGXMetal13_3 + 211941
    54  Metal                               0x00007fff2861d883 -[MTLIOAccelService initWithAcceleratorPort:] + 382
    55  Metal                               0x00007fff2861d6df +[MTLIOAccelService registerService:] + 143
    56  libdispatch.dylib                   0x00007fff2028c806 _dispatch_client_callout + 8
    57  libdispatch.dylib                   0x00007fff202995ce _dispatch_lane_barrier_sync_invoke_and_complete + 60
    58  Metal                               0x00007fff286cd267 MTLIOAccelServiceRegisterService + 71
    59  Metal                               0x00007fff2861d529 +[MTLIOAccelDevice registerDevices] + 243
    60  Metal                               0x00007fff28648419 ___ZL24MTLDeviceArrayInitializev_block_invoke + 1250
    61  libdispatch.dylib                   0x00007fff2028c806 _dispatch_client_callout + 8
    62  libdispatch.dylib                   0x00007fff2028d98c _dispatch_once_callout + 20
    63  Metal                               0x00007fff2861d32e MTLCopyAllDevices + 189
    64  AppleMetalOpenGLRenderer            0x0000000130e33013 _ZN12GLDDeviceRec19initWithDisplayMaskEj + 125
    65  AppleMetalOpenGLRenderer            0x0000000130e39946 gldCreateDevice + 250
    66  libGFXShared.dylib                  0x00007fff6be083ca gfxInitializeLibrary + 2151
    67  GLEngine                            0x00007fff6c0201d9 gliInitializeLibrary + 25
    68  OpenGL                              0x00007fff6bdf5613 glcPluginCount + 1358
    69  OpenGL                              0x00007fff6bdf54e8 glcPluginCount + 1059
    70  OpenGL                              0x00007fff6bdf52a0 glcPluginCount + 475
    71  OpenGL                              0x00007fff6bdfc93f CGLChoosePixelFormat + 3479
    72  OpenGL                              0x00007fff6bdfbbfd CGLChoosePixelFormat + 85
    73  AppKit                              0x00007fff22fcf65b -[NSOpenGLPixelFormat initWithAttributes:] + 56
    74  libwx_osx_cocoau_gl-3.1.5.0.0.dylib 0x0000000110f9cec6 _Z21WXGLChoosePixelFormatPKiiS0_i + 175
    75  libwx_osx_cocoau_gl-3.1.5.0.0.dylib 0x0000000110f9dbf2 _ZN14wxGLAttributes16PlatformDefaultsEv + 70
    76  libwx_osx_cocoau_gl-3.1.5.0.0.dylib 0x0000000110f9c292 _ZN14wxGLCanvasBase15ParseAttribListEPKiR14wxGLAttributesP16wxGLContextAttrs + 34
    77  libwx_osx_cocoau_gl-3.1.5.0.0.dylib 0x0000000110f9e4f8 _ZN10wxGLCanvas6CreateEP8wxWindowiRK7wxPointRK6wxSizelRK8wxStringPKiRK9wxPalette + 66
    78  libwx_osx_cocoau_gl-3.1.5.0.0.dylib 0x0000000110f9e473 _ZN10wxGLCanvasC2EP8wxWindowiPKiRK7wxPointRK6wxSizelRK8wxStringRK9wxPalette + 121
    79  aegisub                             0x0000000102f92b40 _ZN12VideoDisplayC2EP9wxToolBarbP10wxComboBoxP8wxWindowPN3agi7ContextE + 176
    80  aegisub                             0x0000000102f94ed3 _ZN12VideoDisplayC1EP9wxToolBarbP10wxComboBoxP8wxWindowPN3agi7ContextE + 67
    81  aegisub                             0x0000000102f7cf97 _ZN8VideoBoxC2EP8wxWindowbPN3agi7ContextE + 3015
    82  aegisub                             0x0000000102f7e513 _ZN8VideoBoxC1EP8wxWindowbPN3agi7ContextE + 51
    83  aegisub                             0x0000000102dc64a6 _ZN9FrameMain12InitContentsEv + 774
    84  aegisub                             0x0000000102dc4fa9 _ZN9FrameMainC2Ev + 2809
    85  aegisub                             0x0000000102dc71f5 _ZN9FrameMainC1Ev + 21
    86  aegisub                             0x0000000102e0d0c4 _ZN10AegisubApp17NewProjectContextEv + 52
    87  aegisub                             0x0000000102e0bc85 _ZN10AegisubApp6OnInitEv + 5077
    88  libwx_osx_cocoau_core-3.1.5.0.0.dyl 0x0000000111730384 _ZN5wxApp10CallOnInitEv + 160
    89  libwx_baseu-3.1.5.0.0.dylib         0x00000001124bdb56 _Z7wxEntryRiPPw + 42
    90  aegisub                             0x0000000102e0a413 main + 35
    91  libdyld.dylib                       0x00007fff20451f3d start + 1
)
libc++abi: terminating with uncaught exception of type NSException
zsh: abort      /Applications/Aegisub.app/Contents/MacOS/aegisub
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]
XStylus commented 3 years ago

Addendum -- Aegisub r8942 (available on plorkyeran.com/aegisub/) does appear to run on the M1 proc.

All wangqr releases from 3.3.1 and r9116 onward do not appear to run on the M1 proc.

frozenpandaman commented 3 years ago

Running into the same errors. When I run @PutoML's command to fix the code signing error, it crashes with the following (same as what @XStylus got):

Crashed Thread:        0  Dispatch queue: com.Metal.DeviceDispatch
Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000001, 0x0000000181105330
Exception Note:        EXC_CORPSE_NOTIFY
Termination Reason:    Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process:   exc handler [27616]
Application Specific Information:
abort() called
BUG IN CLIENT OF LIBDISPATCH: trying to lock recursively
*** Terminating app due to uncaught exception 'NSGenericException', reason: '-[NSAlert runModal] may not be invoked inside of transaction begin/commit pair, or inside of transaction commit (usually this means it was invoked inside of a view's -drawRect: method.)'
terminating with uncaught exception of type NSException
billzt commented 2 years ago

Some tips

https://gist.github.com/frozenpandaman/92a84cd2ba690bb2399afd04e695bf8c