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

Handle universal/fat binaries #2

Open
MathPlayer opened this issue Jun 19, 2018 · 8 comments
Open

Handle universal/fat binaries #2

MathPlayer opened this issue Jun 19, 2018 · 8 comments

Comments

@MathPlayer
Copy link

MathPlayer commented Jun 19, 2018

In Apple world it's quite common to have a binary with multiple architectures merged together.
There is a conan issue discussing about a generic implementation. Since it's quite hard to find such an implementation, I was thinking that a particular, Apple specific one can be added as part of this package.
If you agree, I can start working on something, using the examples from the mentioned issue.

@ghost
Copy link

ghost commented Oct 12, 2018

Do you have an example that is working? I cannot find it anywhere.

@theodelrieu
Copy link
Owner

Sorry for the delay, I had notifications turned off on my own repo...

I'd like to see what you can come up with :), I resigned myself to using separate archs + a custom script invoking lipo, but we can still experiment.

@paulocoutinhox
Copy link

Any news about how to create it?

Whats the current solution? Create one profile for each arch and after join with lipo externally?

Thanks.

@theodelrieu
Copy link
Owner

Whats the current solution? Create one profile for each arch and after join with lipo externally?

This is currently what I'm doing. Although you can use a single profile and change the arch setting each time:

conan create . user/channel --profile ios -s arch=armv8

@MathPlayer
Copy link
Author

MathPlayer commented Feb 13, 2019

The only thing I've found is that all archs for the same platform can be included in the same profile, maybe something like the following will work (example only for iOS):

diff --git a/conanfile.py b/conanfile.py
index dcfe743..3334407 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -48,6 +48,9 @@ class DarwinToolchainConan(ConanFile):
         if self.settings.os == "watchOS" and self.settings.arch == "armv8":
             darwin_arch = "arm64_32"

+        if self.settings.os == "iOS":
+            darwin_arch = ["arm64", "armv7"]
+
         xcrun = tools.XCRun(self.settings)
         sysroot = xcrun.sdk_path

@@ -67,10 +70,19 @@ class DarwinToolchainConan(ConanFile):

         # CMake issue, for details look https://github.com/conan-io/conan/issues/2378
         cflags = copy.copy(common_flags)
-        cflags.extend(["-arch", darwin_arch])
+        if self.settings.os != "iOS":
+            cflags.extend(["-arch", darwin_arch])
+        else:
+            for arch in darwin_arch:
+                cflags.extend(["-arch", arch])
+
         self.cpp_info.cflags = cflags
         link_flags = copy.copy(common_flags)
-        link_flags.append("-arch %s" % darwin_arch)
+        if self.settings.os != "iOS":
+            link_flags.append("-arch %s" % darwin_arch)
+        else:
+            for arch in darwin_arch:
+                link_flags.append("-arch %s" % arch)

         self.cpp_info.sharedlinkflags.extend(link_flags)
         self.cpp_info.exelinkflags.extend(link_flags)

@paulocoutinhox
Copy link

Will be nice implement array of arch, i agree.

In my tool i have created all steps to generate universal framework in our business:
https://github.com/ezored/target-ios/blob/master/build/ezored_target.py#L191

Thanks anyway.

@theodelrieu
Copy link
Owner

Unfortunately, there is no way for a consumer to provide multiple archs to the recipe, this is a Conan limitation.

The toolchain could force all architectures as you mention, but there is no way to select only a few architectures (e.g. there are currently 5 architectures for iOS IIRC).

Furthermore, you'd have to find a way to set the package ID accordingly depending on the archs you used (to avoid colliding two packages built with armv8/armv7 and armv8/armv7s).

I think this issue should be reconsidered if Conan introduces support for multiple values' settings/options.

I would advise you to open an issue about this topic (or find an already opened one), there might be other use-cases for multiple values' settings than the one we're discussing here.

@a4z
Copy link

a4z commented Dec 19, 2019

Will be nice implement array of arch, i agree.

In my tool i have created all steps to generate universal framework in our business:
https://github.com/ezored/target-ios/blob/master/build/ezored_target.py#L191

Thanks anyway.

the link does not work anymore, but I found your repo @PRSolucoes , ezored , looks interesting and could be exactly what I need to kick start me with conan (to which I am pretty new) for what I need, what is djiini + some things for android ios , so exactly what you prepared
will test this now

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

4 participants