media-kit / libmpv-darwin-build

libmpv for macOS & iOS.
Other
32 stars 11 forks source link

Issue building on M1 Mac #25

Closed guyman624 closed 9 months ago

guyman624 commented 10 months ago

log.txt When I build on my M1 Mac, I receive a variety of errors every time I try to build (using instructions from readme). Attached is an example of one such error.

macOS: 14.1

birros commented 10 months ago

These warnings and errors appear all over the log file, probably due to a recent Xcode update:

ld: warning: -undefined error is deprecated
C compiler cannot create executables

Unfortunately, we'll have to wait for future macOS / Xcode updates before the toolchain works properly again.

Apple magic…

guyman624 commented 10 months ago

Apple magic…

sounds about right thanks

23doors commented 9 months ago

I'm not so sure if Xcode update will fix it. Core issue here is:

ld: building for 'iOS', but linking in dylib (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libSystem.B.tbd) built for 'iOS-simulator'

Mac builds work fine, simulator seems to be an issue again

23doors commented 9 months ago

FYI, this occurs only on arm macs + Xcode 15 where new linker is causing issues but only with iphone simulator arm64 builds. Intel macs and/or xcode pre 15 are fine.

There is a linker flag to force old linker that makes it work again. Flag is said to be removed in future releases but hopefully this is actually a bug on their side that will be fixed.

Unsure if this flag needs to be added conditionally or will it work in all cases, but anyway to fix it on arm mac you can edit cross-files/iossimulator-arm64.ini and add -ld64 to link_args:

c_link_args = ['-ld64', '-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk', '-miphoneos-version-min=12.0']
cpp_link_args = ['-ld64', '-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk', '-miphoneos-version-min=12.0']
objc_link_args = ['-ld64', '-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk', '-miphoneos-version-min=12.0']
objcpp_link_args = ['-ld64', '-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk', '-miphoneos-version-min=12.0']
moffatman commented 9 months ago

I just filed a PR, so we can get it to work without forcing the old linker. I don't think they'll fix it, the link we were trying to do was technically not valid.