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

[feature] Ability to identify if binaries can be executed on a particular platform #11035

Closed
maikelvdh opened this issue Apr 15, 2022 · 8 comments · Fixed by #11321
Closed

[feature] Ability to identify if binaries can be executed on a particular platform #11035

maikelvdh opened this issue Apr 15, 2022 · 8 comments · Fixed by #11321
Assignees
Milestone

Comments

@maikelvdh
Copy link
Contributor

Typically there is made use of tools.cross_building(self.settings) to identify that for example test binaries can't be executed on a particular platform. Though this particular solution is not really sufficient to handle for example the case of running on a macOS with Apple Silicon (M1) chipset, as in that particular case you can execute both x86_64 and armv8 binaries without any issue (even without Rosetta enabled).

Extending tools.cross_building with yet another parameter similar to skip_x64_x86 seems not a good option. Therefore it would be good to have a dedicated method for this usecase like for example tools.can_run().

@uilianries
Copy link
Member

It's true you don't need to invoke Rosetta manually on M1 to execute x86_64, but still, the architecture is not the same and Mac will run Rosetta 2 dynamically, which has some loss of performance. I could use QEMU on Linux and say the same thing, but still, is not optimized.

I disagree adding such feature because any possible incompatibility error when executing an app, will result result someone asking to Conan issues or Conan Center Index for a solution, which is not related to Conan.

Running aligned architecture is the best option ever, and Conan already supports M1, which means, you can package ARM packages too.

@memsharded
Copy link
Member

I don't dislike being able to run things that are cross-built in platforms that allow it, and it seems this feature could make sense.

A different story is if we want to cross-build and/or cross-execute in ConanCenter. I see a point if that execution subsystem is not rock solid, as any potential error will result in further undesirable broken builds, support, tickets, discussions, etc in ConanCenter.

@memsharded memsharded added this to the 1.48 milestone Apr 18, 2022
@SSE4
Copy link
Contributor

SSE4 commented Apr 19, 2022

also, as I understand, this move could be a temporary. e.g. previously, Rosetta allowed to execute x86 (32-bit) and PowerPC binaries on x86_64 machines, but eventually Apple has removed that support completely, as x86_64 Apple machines became more wide-spread than x86(32) and PowerPC. actually, it lasted only OS 3 releases (from 10.4 to 10.7) that time.

@memsharded
Copy link
Member

also, as I understand, this move could be a temporary. e.g. previously, Rosetta allowed to execute x86 (32-bit) and PowerPC binaries on x86_64 machines, but eventually Apple has removed that support completely, as x86_64 Apple machines became more wide-spread than x86(32) and PowerPC. actually, it lasted only OS 3 releases (from 10.4 to 10.7) that time.

Yes, if the OSX support for this might be changing, dropped, etc., then trying to have something robust in Conan can be a maintenance burden and source of bugs and support tickets. And if support for x86(32) lasted only 3 releases, is not looking good...

@SSE4
Copy link
Contributor

SSE4 commented Apr 20, 2022

the suggestion might be to implement an external configuration for cross-building function. maybe just a single boolean value within profile (or conf) that overrides the result of tools.cross_building. as there are other similar cases (e.g. #10923) when conan's built-in logic is not suitable enough.

@memsharded
Copy link
Member

the suggestion might be to implement an external configuration for cross-building function. maybe just a single boolean value within profile (or conf) that overrides the result of tools.cross_building. as there are other similar cases (e.g. #10923) when conan's built-in logic is not suitable enough.

It cannot be a conf to alter the cross_building result. We still want to have the cross_building() to return True when building x86_64 in M1 computer, but still we want something else to tell that we can indeed run the binary (Note that the logic used now in recipes is if not cross_building(): run...

So the only possible reasonable alternative I see at this moment is:

  • Add a can_run() method.
  • This methods uses internally cross_building() returning False if cross_building
  • Unless there is a conf that says can_run=True and bypass the cross_building result (only for the can_run())

This might be dummy implementation, but allows recipes to have clean logic and users to control manually the execution, without needing to implement any "smart" logic inside conan.

@SSE4
Copy link
Contributor

SSE4 commented Apr 20, 2022

yes, I support that direction

@memsharded
Copy link
Member

Implemented in #11321, will be in 1.49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants