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

How to specify mininum iOS version for linker? #109

Open
JCash opened this issue Aug 17, 2021 · 0 comments
Open

How to specify mininum iOS version for linker? #109

JCash opened this issue Aug 17, 2021 · 0 comments

Comments

@JCash
Copy link

JCash commented Aug 17, 2021

Hi!

I have an issue with the latest versions of the iPhoneOS, where when I link towards the AVFoundation framework, I always also get linkage towards the AVFAudio framework, regardless of which minnimum iPhoneOS version I specify.

Since the AVFAudio framework is new since iPhoneOS 14.5, it won't work with older devices.
The apple linker checks the min iPhoneOS version and links accordingly. (See example below)

So my questions are, how do I build/configure cctools-port to do this, and what should I pass into the linker?

Any tips/hints are much appreciated!

Regards,
Mathias

Currently, I build cctools with prefix arm-apple-darwin19 and latest libtapi, and I link with:
(I removed the libraries/frameworks for brevity)

clang++ -arch arm64 -target arm-apple-darwin19 -m64 -miphoneos-version-min=8.0 -O2 -g -stdlib=libc++ -isysroot /opt/platformsdk/iPhoneOS14.5.sdk -o ./testapp -fobjc-link-runtime -dead_strip -Wl,-U,_objc_loadClassref -fno-autolink -ObjC  -lclang_rt.ios -framework AVFoundation ./main.o

Comparing with Apple clang, it's easy to switch between min iPhoneOS versions:

clang -target arm64-apple-ios10.0 -framework AVFoundation -o ./testapp

otool -L ./testapp | grep AVF

    /System/Library/Frameworks/AVFoundation.framework/AVFoundation (compatibility version 1.0.0, current version 2.0.0)

(when using verbose, the 14.3 build passes this to the apple linker: -platform_version ios 10.0.0 14.5)

versus

clang -target arm64-apple-ios14.5 -framework AVFoundation -o ./testapp

otool -L ./testapp | grep AVF

    /System/Library/Frameworks/AVFoundation.framework/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
    /System/Library/Frameworks/AVFAudio.framework/AVFAudio (compatibility version 1.0.0, current version 1.0.0)

(when using verbose, the 14.3 build passes this to the apple linker: -platform_version ios 14.5.0 14.5)

Comparing the AVFoundation.tbd between versions reveals this bit, which is a clue.
Also, the `AVFAudio.tbd doesn't exist in 14.3)

AVFoundation.tbd (iPhoneOS 14.3)

...
install-name:    '/System/Library/Frameworks/AVFoundation.framework/Frameworks/AVFAudio.framework/AVFAudio'
exports:
  - targets:         [ armv7-ios, armv7s-ios ]
    objc-classes:    [ AVAudioEndpointDetector ]
    objc-ivars:      [ AVAudioEndpointDetector._impl ]
  - targets:         [ arm64-ios, arm64e-ios, armv7-ios, armv7s-ios ]
    symbols:         [ _AVAudioBitRateStrategy_Constant, _AVAudioBitRateStrategy_LongTermAverage, 
...

AVFoundation.tbd (iPhoneOS 14.5)

...
install-name:    '/System/Library/Frameworks/AVFAudio.framework/AVFAudio'
exports:
  - targets:         [ armv7-ios, armv7s-ios ]
    objc-classes:    [ AVAudioEndpointDetector ]
    objc-ivars:      [ AVAudioEndpointDetector._impl ]
  - targets:         [ arm64-ios, arm64e-ios, armv7-ios, armv7s-ios ]
    symbols:         [ '$ld$previous$/System/Library/Frameworks/AVFoundation.framework/AVFoundation$$2$1.0$14.5$$', 
                       _AVAudioBitRateStrategy_Constant, _AVAudioBitRateStrategy_LongTermAverage, 
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant