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

Cross-compilation for iOS fails after upgrade to Big Sur (macOS 11) #8359

Closed
coelle opened this issue Feb 16, 2021 · 6 comments
Closed

Cross-compilation for iOS fails after upgrade to Big Sur (macOS 11) #8359

coelle opened this issue Feb 16, 2021 · 6 comments
Labels
OS:macos Issues specific to Apple Operating Systems like MacOS and iOS

Comments

@coelle
Copy link

coelle commented Feb 16, 2021

Describe the bug
After updating a system to macOS 11 the cross compilation for iPhone fails with the message

Run-time dependency appleframeworks found: NO (tried framework)

meson.build:3:0: ERROR: Dependency "appleframeworks" not found, tried framework

I attached the succeeding and failing meson-log files:

After

export SDKROOT=$(xcrun --sdk iphoneos --show-sdk-path)

and retrying on macOS 11, I get the following hint in the log file:

Compiler stderr:
 ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks//LocalAuthentication.framework/LocalAuthentication.tbd, missing required architecture x86_64 in file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks//LocalAuthentication.framework/LocalAuthentication.tbd (4 slices)
ld: building for iOS, but linking in object file built for iOS Simulator, file '/var/folders/8g/b9x3y6tj3yxf988c4gkb5ybc0000gp/T/testfile-cf7953.o' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

which indicates, the xcodebuild expects some architecture parameter.

If I use the clang++ command from the meson-log.txt and

  • set SDKROOT correctly
  • append -arch arm64 to the command-line
    the setup succeeds on macOS 11 and file output.exe results in output.exe: Mach-O 64-bit executable arm64.

So, how do I have to modify the meson.build for a succeeding build?

To Reproduce

meson.build

project('Objective C++', 'objcpp')

appleframeworks_dep = dependency('appleframeworks', modules: ['Foundation', 'Security', 'LocalAuthentication'])
exe = executable('objcppprog', 'prog.mm', dependencies: [appleframeworks_dep])
test('Simple Build', exe)

prog.mm

int main(void) {  return 0; }

cross-file.txt

[host_machine]
system = 'darwin'
cpu_family = 'aarch64'
cpu = 'arm64'
endian = 'little'

[binaries]
ar = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar'
as = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/as'
c = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang'
cc = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang'
cpp = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang'
cxx = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++'
ld = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld'
objc = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang'
objcpp = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++'
ranlib = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib'
strip = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip'

[properties]
skip_sanity_check = true
ios_deployment_target = '13.0'
vendor = 'apple'
target_dir = 'apple-iphoneos13.0-aarch64-arm64-little'
sys_root = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk'

Setup

meson setup --cross-file cross-file.txt build

Expected behavior
Finish the setup without error and meson test -C build should run but should skip the test.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? cross build
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)
    • Fails on macOS 11.2.1 and Xcode 12.3 / 12.4
    • Succeeds on macOS 10.15.7 and Xcode 12.3
  • what Python version are you using e.g. 3.8.0: 3.8.2 (from Xcode)
  • what meson --version : 0.56.0 (but 0.57.0 fails, too)
  • what ninja --version if it's a Ninja build: 1.10.2
@dcbaker dcbaker added the OS:macos Issues specific to Apple Operating Systems like MacOS and iOS label Feb 17, 2021
@dcbaker
Copy link
Member

dcbaker commented Feb 17, 2021

@jpakkane, @nirbheek, can either of you verify this? My macbook stopped updating at Catalina

@coelle
Copy link
Author

coelle commented Feb 21, 2021

Tell me if I can help in any way.

@jpakkane
Copy link
Member

jpakkane commented Mar 2, 2021

I tested this and could make it work by adding these entries to the cross file's properties entry:

objcpp_args = ['-arch', 'arm64']
objcpp_link_args = ['-arch', 'arm64']

I also had to set SDKROOT. Presumably there is also a command line argument you can give to the compiler/linker to make it work, but I don't know enough about macOS to know what that might be.

@coelle
Copy link
Author

coelle commented Mar 3, 2021

Thank you very much! This solved it. :-)

Did I miss anything in the documentation or is this a "try-and-error" thing?

@coelle coelle closed this as completed Mar 3, 2021
@coelle
Copy link
Author

coelle commented Mar 3, 2021

Problem solved.

@coelle coelle reopened this Mar 3, 2021
@coelle
Copy link
Author

coelle commented Mar 3, 2021

Short update:
The settings provided above solve the problem on macOS 11 but are not applicable for macOS 10. (both Xcode 12.4)
Ticket can stay closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS:macos Issues specific to Apple Operating Systems like MacOS and iOS
Projects
None yet
Development

No branches or pull requests

3 participants