QOwnNotes icon indicating copy to clipboard operation
QOwnNotes copied to clipboard

Build For Apple Silicon (new Github runners)

Open gal064 opened this issue 2 years ago • 49 comments

Github runners for M1 are now available and I'm not familiar with QT, but it looks like you could even build an M1 version on intel silicon.

Would it be possible to have an M1 build?

gal064 avatar Dec 04 '23 01:12 gal064

The build process for macos would need to work on Qt6 to do that I guess. And I don't know if you could get two different architectures in one disk image with the Qt tooling. But I also have no idea if the update script would be able to handle that.

And I'm lacking M1 hardware to be able to test the result 😁

pbek avatar Dec 04 '23 05:12 pbek

I'm happy to help however I can. Unfortunately know nothing about QT to actually prepare a full PR, but if you want me to run a certain GitHub action or script, or test the result happy to do so.

BTW QTOwnNotes do sometimes freeze for a few seconds on M1. I don't know if it's just a bug, or related to not being built for apple Silicon, but in the past I've seen weird behaviors like this happen on intel apps run on M1

gal064 avatar Dec 04 '23 06:12 gal064

I'm happy to help however I can. Unfortunately know nothing about QT to actually prepare a full PR, but if you want me to run a certain GitHub action or script, or test the result happy to do so.

Thank you! If anyone wants to pick this up, this is where the current release build process is started (uses Qt5): https://github.com/pbek/QOwnNotes/blob/952a3684e9840995673545b1509e7b1f286faadc/.github/workflows/build-release.yml#L331-L395 Most of the actual process is abstracted to https://github.com/pbek/QOwnNotes/blob/main/build-systems/github/macos/create-dmg.sh.

In case Qt6 is needed, this is where I experimentally build the macOS build with Qt6: https://github.com/pbek/QOwnNotes/blob/952a3684e9840995673545b1509e7b1f286faadc/.github/workflows/build-release-qt6.yml#L355-L410

BTW QTOwnNotes do sometimes freeze for a few seconds on M1. I don't know if it's just a bug, or related to not being built for apple Silicon, but in the past I've seen weird behaviors like this happen on intel apps run on M1

Any debug logs?

pbek avatar Dec 04 '23 08:12 pbek

Building should maybe even work with Qt5 and qmake says: https://doc-snapshots.qt.io/qt5-5.15/macos.html#architectures

@gal064, so in theory you could try to fork the QOwnNotes repository and add QMAKE_APPLE_DEVICE_ARCHS="x86_64 arm64" to this line:

https://github.com/pbek/QOwnNotes/blob/952a3684e9840995673545b1509e7b1f286faadc/.github/workflows/build-release.yml#L377

If you enabled GitHub actions and push your changes to the release branch, that should trigger building a release for you. Of course, that would result in an app for only the M1 (if it works).

pbek avatar Dec 04 '23 08:12 pbek

Tried to run it but I'm getting: "Trying to compile Botan configured as x86_64 with non-x86_64 compiler."

Also tried to comment out the x86 config in botan.pri and received the following: ld: symbol(s) not found for architecture arm64

I'm not sure if that error is unrelated or making changes to the pri file created that error. I was pretty much guessing

gal064 avatar Dec 04 '23 19:12 gal064

I guess Botan is able to compile for ARM, so it must be something with the settings... 🤔

pbek avatar Dec 04 '23 19:12 pbek

Yep. I have no idea how to push forward here, so if you or anyone else want to pick this up would be greatly appreciated.

Anyway I'll submit a bug on the small freezes when it happens next

gal064 avatar Dec 04 '23 19:12 gal064

I tried just adding QMAKE_APPLE_DEVICE_ARCHS = x86_64 arm64 to the project file in https://github.com/pbek/QOwnNotes/commit/fdd5e059473a27f8e26a802fdf624b94f522017e, but the build on macOS failed, without telling why. 🤔 https://github.com/pbek/QOwnNotes/actions/runs/7685776723/job/20943900082

pbek avatar Jan 28 '24 12:01 pbek

I wonder if any of the notes here on cross compilation might help/work?

https://github.com/qbittorrent/qBittorrent/wiki/Compilation:-macOS-(x86_64,-arm64,-cross-compilation)#qt

spoelstraethan avatar Jan 28 '24 20:01 spoelstraethan

Looking at the logs, can the failure might be due to this:

:17:
libraries/botan/botan.h:293:6: error: "Trying to compile Botan configured as x86_64 with non-x86_64 compiler."
    #error "Trying to compile Botan configured as x86_64 with non-x86_64 compiler."
     ^

gal064 avatar Jan 29 '24 18:01 gal064

I ran into the same issue but wasn't sure how to set it up

gal064 avatar Jan 29 '24 18:01 gal064

Ah, good find! Hm... 🤔

pbek avatar Jan 29 '24 18:01 pbek

I have a MBPro M3 Pro and was able to build for Apple Silicon. I did the fallowing: git clone https://github.com/pbek/QOwnNotes.git -b release --depth=1 cd QOwnNotes git submodule update --init

brew install qt-creator

brew install qt You can add Homebrew's Qt to QtCreator's "Qt Versions" in: Preferences > Qt Versions > Link with Qt... pressing "Choose..." and selecting as the Qt installation path: /opt/homebrew

brew install qt@5 fallow procedure to add qt5 to QT Creator: You can add Homebrew's Qt to QtCreator's "Qt Versions" in: Preferences > Qt Versions > Link with Qt... pressing "Choose..." and selecting as the Qt installation path: /opt/homebrew/opt/qt@5

open QT Creator open the project file src/QOwnNotes.pro

then I think there was a 'configure project' button but it's not there now and I don't recall exactly, sorry. But that did it's thing for a while. I've never used QT Creator before so going by memory.

then I built it and ran it and it worked, building an Apple Silicon version

KwisatzJim avatar Apr 13 '24 20:04 KwisatzJim

hmmm... ran into a hitch, I copied the .app to my Mac Mini M2 and it crashed on start until I installed qt@5

KwisatzJim avatar Apr 13 '24 20:04 KwisatzJim

You could try to use the package manager nix to install QOwnNotes on the mac. 🤔

pbek avatar Apr 14 '24 05:04 pbek

You could try to use the package manager nix to install QOwnNotes on the mac. 🤔

ok, not bad idea, but the nix version is 24.4.0 and current release is 24.4.2. But it is Apple Silicon which is nice.

KwisatzJim avatar Apr 14 '24 11:04 KwisatzJim

Will be surely in the build pipeline. QOwnNotes is at 24.4.2 in nix.

pbek avatar Apr 14 '24 12:04 pbek

I'd like to know if it worked in case you try 😉

pbek avatar Apr 14 '24 12:04 pbek