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 Request: M1 build for macOS #469

Closed
ajmas opened this issue Nov 18, 2021 · 21 comments
Closed

Feature Request: M1 build for macOS #469

ajmas opened this issue Nov 18, 2021 · 21 comments

Comments

@ajmas
Copy link

ajmas commented Nov 18, 2021

This feature request is simply to have support for ARM build targets, for macOS.

I did search through the issues and also running 'file' against the main binary in the package suggests the target is still only x86_64. It is possible that I missed something in my search.

Given that there is already support for Android and Raspberry Pi (based on this), I would imagine the necessary adjustments would be minor?

BTW I do see that QT Creator does support 'Apple Silicon': https://www.qt.io/blog/qt-on-apple-silicon , though only from Qt 6.2 onwards, which is now released: https://www.qt.io/product/qt6

Depends on webcamoid/WebcamoidIssues#47

@hipersayanX
Copy link
Member

hipersayanX commented Nov 18, 2021

I've no problem adding support for M1 chips, but afaik, github environment runs on x86_64, and not sure how to cross compile to M1. Also, I'll be not able to test it because I haven't a M1 MacBook, so I'll keep supporting x86_64 until homebrew remove the support for it, and then, if nobody take the lead of Mac development, I'll just remove Mac support.

I would imagine the necessary adjustments would be minor?

Yes, as minor as buying a 1300 USD MacBook 😐

@ajmas
Copy link
Author

ajmas commented Nov 18, 2021

Actual user testing will depend on implicated humans being available, and we should take your comment as a request for volunteers.

At the same time, it is possible to cross compile, using Intel CPUs. I looked into this for another project, but if I remember it was XCode based. Found it: simonguest/quick-camera#21

The only thing I can see right now as a possible blocker is needing to upgrade the project to Qt6.

@hipersayanX
Copy link
Member

and we should take your comment as a request for volunteers.

Take it and multiply by 1e6.

@gandergo
Copy link

gandergo commented Dec 1, 2022

github environment runs on x86_64, and not sure how to cross compile to M1

Saw that the project has a .cirrus.yml in the root. Does this project currently uses Cirrus CI? They now offering m1 mac build environment for public projects.

I tried to modify the existing .cirrus.yml for m1 build environment and modify for current build.sh for m1 in my fork:

  1. Add necessary flags for targeting m1 for Qt5:
    -DCMAKE_OSX_ARCHITECTURES=arm64
    export CFLAGS="-arch arm64 -target arm64-apple-macos11"
    export CXXFLAGS="-arch arm64 -mmacosx-version-min=11.0 -std=c++11"
    
  2. I did not manage to properly sign the binary in CI and m1 mac would not allow the app to start without it. To make it work, similar to here, I self-signed the binary locally.

Then program can then start with the akvirtualcamera plugin compiled on the m1 too, but i did not test many other features.

If such approach is considered acceptable, I can see if i can polish the method further and submit a pull request. Thanks.

@hipersayanX
Copy link
Member

@gandergo So basically no code changes were required?

If such approach is considered acceptable, I can see if i can polish the method further and submit a pull request. Thanks.

This changes won't affect the build in FreeBSD, right? because I remember Cirrus was very limited for free builds.
Also looking at the link here

I did not manage to properly sign the binary in CI and m1 mac would not allow the app to start without it. To make it work, similar to here, I self-signed the binary locally.

Their are using the --deep flag, is this flag necessary? if so it can be added here.

Also , thanks!

@gandergo
Copy link

@hipersayanX sorry for my late reply. Have been away last week.

So basically no code changes were required?

Yes, I only changed those build configurations. But I only tried some features like using it with the M1 build of virtual camera.

This changes won't affect the build in FreeBSD, right?

The Mac M1 build can be defined as a separate build task like here. From the Cirrus CI doc here, it should not affect the existing limits for the builds of FreeBSD.

Their are using the --deep flag, is this flag necessary? if so it can be added here.

Yes, I think this flag is necessary. I did try adding this flag during the build as in here, but it does not work and Mac on M1 still refuses to open the binary, unless I self-sign the binary again locally after the build. I still have not found out the cause on why this local re-signing is necessary.

@hipersayanX
Copy link
Member

Yes, I think this flag is necessary. I did try adding this flag during the build as in here, but it does not work and Mac on M1 still refuses to open the binary, unless I self-sign the binary again locally after the build. I still have not found out the cause on why this local re-signing is necessary.

It is what it is 🤷‍♂️ , to make a binary work for other users, the binary must be code signed, and for code signing you must register with an Apple ID and pay for the service, me as many other FOSS developers won't waste their time and money on that, most FOSS developers don't make enough money to care about such things.
Just do a basic code sign, and make easy for the user to build and install with homebrew, and that's all, you don't need to worry about anything else.

@rcoenen
Copy link

rcoenen commented Mar 17, 2023

So what is the latest - can we use this on M1 Macs yes or no?

@ajmas
Copy link
Author

ajmas commented Mar 17, 2023

At this point having someone try building it on an M* Mac would be good and then identify any issues. @rcoenen if you are able to try building and documenting any build or run issues, I think that would be useful starting point.

Also there are now M1 runners and Pi compatible ARM runners:

Contributions to fix this up would be useful.

Myself, I don't have access to an ARM based Mac right now, to test locally.

Edit: Taking a quick look, but don't have much time. Seeing if this works out as a good reference:

https://github.com/mjovanc/hugin-cli/blob/a8930416e12576a03931d97e91d7a6d441b67110/.github/workflows/main-ci.yml

@hipersayanX
Copy link
Member

I was about to write an answer here but at the end I decided to create an issue webcamoid/WebcamoidIssues#60.

@ajmas

Myself, I don't have access to an ARM based Mac right now, to test locally.

Me too and don't expecting to have one in the short time, not even in long time.

@hipersayanX
Copy link
Member

Well, I've tried but

  • The hosted system images provided by github are only x86_64.
  • I can compile Webcamoid for ARM64, but it won't link with the libraries provided by homebrew because the libraries are x86_64 only.
  • Apparently I can download install ARM64 packages with arch -arm64 brew install, yet it won't work in x86_64.

So I reached a dead point with this issue. Here are the results.
Ideas welcome, otherwise we have no other option than waiting for github to add the ARM64 images.

@ajmas
Copy link
Author

ajmas commented Apr 30, 2023

I haven’t been able to contribute much recently due to day job.

@hipersayanX
Copy link
Member

I will try with Cirrus later.
@ajmas no problem.

@hipersayanX
Copy link
Member

And there you have, Webcamoid packages for the ARM based Macs, but can't test it so not sure if works or not.

@hipersayanX hipersayanX self-assigned this May 4, 2023
@boli
Copy link

boli commented May 28, 2023

And there you have, Webcamoid packages for the ARM based Macs, but can't test it so not sure if works or not.

did not work for me on macbook air m1. i guess its a code signing thing:


Exception Type:        EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid))
Exception Codes:       UNKNOWN_0x32 at 0x0000000102d94000
Exception Codes:       0x0000000000000032, 0x0000000102d94000

Termination Reason:    Namespace CODESIGNING, Code 2 Invalid Page

so i tried this
codesign --force --deep --sign - /Applications/Webcamoid.app

...but it didnt help.

webcamoid.txt <--- crash report

@hipersayanX
Copy link
Member

@boli maybe leaving it unsigned by default would help? the other option would be contacting with the guy maintaining the homebrew formulae and tell him to compile straight from the sources instead of downloading it from the binary, that way users will be able to install Webcamoid from homebrew. I can't do nothing more beside that, I can't even test Webcamoid in Mac anymore, so now the development is on Mac community hands only.

@hipersayanX
Copy link
Member

The source code compile fine and should be able to work fine in Mac, but binary packages won't be provided anymore.

@RokeJulianLockhart
Copy link

binary packages won't be provided anymore.

Why, @hipersayanX?

@hipersayanX
Copy link
Member

@RokeJulianLockhart read webcamoid/WebcamoidIssues#60, Webcamoid has $0 financial support, it's absolutely impossible for me to pay for code signing or buy a Mac, I had not any other option.

@abibars
Copy link

abibars commented Jun 20, 2023

good day gentlemen, i will be glad to support compile and sign the code, if you can guide me through the the binary files

@hipersayanX
Copy link
Member

@abibars the documentation for code signing is here (I can't help you there because I never done that), the certificate can be bought in the sites listed here.
If you want to compile for yourself, the documentation is here, also here you can find the dependencies.
If the idea is compiling and distributing officially for the project, is a matter of buying the certificate and then adding it to the pipeline, which I don't know how to do it yet.

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

No branches or pull requests

7 participants