Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Universal Build for Big Sur #18094

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

Merged
merged 3 commits into from
Aug 29, 2020
Merged

Conversation

komakai
Copy link
Contributor

@komakai komakai commented Aug 13, 2020

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under OpenCV (BSD) License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work

This PR resolves #18049

  • add --archs parameter to the MacOS build
  • add handling for cross-compiling cases x86_64 -> arm64 and arm64 -> x86_64

Comment on lines 253 to 254
if arch != "arm64":
cmakecmd.append("-DENABLE_NEON=OFF")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should re-check CMake scripts (toolchain?) to ensure that this is default value.

Copy link
Contributor Author

@komakai komakai Aug 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that there is an issue in CMake which overwrites the value set for CMAKE_SYSTEM_PROCESSOR when building for macOS. This meant that when building for arm64 on Intel or for x86_64 on ARM we were getting incorrect information for supported compiler optimizations, which was causing the various weird build errors we were seeing. I have added a work-around for this.

if args.legacy_build:
args.framework_name = "opencv2"
if not "objc" in args.without:
args.without.append("objc")

b = OSXBuilder(args.opencv, args.contrib, False, False, args.without, args.disable, args.enablenonfree,
[
(["x86_64"], "MacOSX")
(archs, "MacOSX")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use this form here:

("x86_64", "MacOSX"),
("arm64", "MacOSX"),

(as result)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OSXBuilder shares code with the iOSBuilder so we need to pass the parameters in a way that is consistent with how it is done on iOS:

[
    (["armv7, "armv7s", "arm64"], "iPhoneOS"),
    (["x86_64", "i386"], "iPhoneSimulator"),
]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right.
I have confused by arch = archs[0] line in makeCMakeCmd().

For each arch we should have own dedicated CMake pass.
It is impossible to "merge" them - current CMake scripts are targeted to single configuration at once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have confused by arch = archs[0] line in makeCMakeCmd()

OK I understand what you mean - I can fix that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was only one set of conditions where multiple architectures were being built at the same time but the changes in #17665 meant actually it wasn't necessary any more - so I have modified the iOS and macOS builds to always just build one architecture at a time.

@komakai komakai force-pushed the macos-universal-binary branch from 723e376 to fdcbd8d Compare August 23, 2020 13:14
Copy link
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Thank you for contribution 👍

@alalek alalek merged commit 60354e3 into opencv:master Aug 29, 2020
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
* Universal Build for Big Sur

* Refactor MacOS/iOS build to only ever build one architecture at a time + improve code readability

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

Successfully merging this pull request may close these issues.

Needs universal framework build on macOS Big Sur
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.