theodelrieu / conan-darwin-toolchain

Conan build require to cross build to any darwin platform
MIT License
31 stars 21 forks source link

Take os.sdk setting into account #12

Closed Linux13524 closed 3 years ago

Linux13524 commented 3 years ago

Is there a reason the os.sdk setting was not yet passed to apple_deployment_target_flag?

I tried to build a simple test project with the following profile, but got an error:

[settings]
os=iOS
os_build=Macos
os.sdk=iphonesimulator
os.version=12.0
arch=armv8
arch_build=x86_64
compiler=apple-clang
compiler.cppstd=17
compiler.version=12.0
compiler.libcxx=libc++
build_type=Release
[options]
[build_requires]
*: darwin-toolchain/1.0.8@theodelrieu/stable

The error was: ld: building for iOS, but linking in object file (CMakeFiles/test.dir/src/main.cpp.o) built for iOS Simulator, file 'CMakeFiles/test.dir/src/main.cpp.o' for architecture arm64

Adding os.sdk setting to the tools.apple_deployment_target_flag() function fixes it.

theodelrieu commented 3 years ago

Hi, thanks for the PR.

I did start working on making darwin-toolchain work with Apple M1, but got lost into build/host context issues. I encountered this issue and did not update the code once the feature was implemented 😅

Note that it is very possible that you run into M1 specific issues with the current version of darwin-toolchain!

Linux13524 commented 3 years ago

Hi. Nice to hear you already started working on the Apple M1 compatibility!
So you would say this is not as simple as the fix I added here in this pull request? Im not very familar with the Apple architectures I have to say.

theodelrieu commented 3 years ago

I did put it on the backburner for months though, as M1 Macs come with Rosetta2 which make x86 programs compatible. The main issue you might face is not really Conan-related, it has to do with iOS simulators having the same architecture than iOS devices. This is the exact issue you faced, since Conan only recognized the armv8 arch and assumed it was building for iOS.

If you are using lipo for example, you will have to transition to XCFrameworks instead, as you are not allowed to have the same architecture multiple times in a fat library.

Also, many Xcode projects use the following line in their .xcconfig file:

EXCLUDED_ARCHS[sdk=iphonesimulator*] = 'arm64'

theodelrieu commented 3 years ago

@Linux13524 The Homebrew seems to get stuck, could you upgrade the xcode image to osx_image: xcode12?

Linux13524 commented 3 years ago

Thanks for all the insights! I upgraded the CI image.

theodelrieu commented 3 years ago

@lasote 👋 Sorry to pull you in, but since you made the CI of this I'd like to know if you could help me understand how I should fix the job failure 😛

Traceback (most recent call last):

  File "build.py", line 1, in <module>
    from conan.packager import ConanMultiPackager

ModuleNotFoundError: No module named 'conan.packager'

By the way, it might be time to move this recipe to CCI?

theodelrieu commented 3 years ago

@Linux13524 I think I have it, could you change build.py to import from cpt.packager import ConanMultiPackager instead?

Linux13524 commented 3 years ago

@theodelrieu Cool, that worked!

theodelrieu commented 3 years ago

@Linux13524 Thank you!

theodelrieu commented 3 years ago

@Linux13524 I can't deploy the new release since Bintray died a few weeks ago, I'm on vacation until next week, I will open a PR to conan-center-index to add darwin-toolchain to it

Linux13524 commented 3 years ago

@theodelrieu Ok, thanks a lot for your efforts!

rohan-elear commented 3 years ago

@theodelrieu awesome to see you are working on the cross platform support. I was following your comments on an issue in Conan repo. I have transitioned to .xcframeworks and it's frankly a lesser hassle. I do use the EXCLUDED_ARCHS[sdk=iphonesimulator*] = 'arm64' for now. Eagerly waiting on the M1 cross-platform support.