Bug 448443 - Support blueprint building on M1 darwin arm64
Summary: Support blueprint building on M1 darwin arm64
Status: RESOLVED FIXED
Alias: None
Product: Craft
Classification: Unmaintained
Component: Blueprints (show other bugs)
Version: stable
Platform: Compiled Sources macOS
: NOR major
Target Milestone: ---
Assignee: Hannah von Reth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-14 07:55 UTC by Ruixuan Tu
Modified: 2024-03-16 18:34 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ruixuan Tu 2022-01-14 07:55:15 UTC
I am building KDE Connect for M1 Mac (darwin arm64), but I found KDE Craft deliberately builds packages for x86_64 which is incompatible with arm64, and a number of the prebuilt binaries delivered are x86_64 only, while arm64 versions are available by Homebrew or manually compilation. This causes a lot of compilation errors in linking like “ld: warning: ignoring file /Users/turx/CraftRoot/lib/libKF5IconThemes.5.89.0.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64” or the inverse (when it incorrectly trying to build for x86_64 with arm64 libs), causing "clang: error: linker command failed with exit code 1".

I am using macOS 12.1, and a part of my "uname -a" info is "Darwin 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 arm64".
Comment 1 Ruixuan Tu 2022-01-14 07:55:51 UTC
One way I found to solve it is to add the following to each CMakeLists.txt

if(APPLE)
  option(OSX_FRAMEWORK "Build a Mac OS X Framework" ON)
  set(CMAKE_OSX_ARCHITECTURES “x86_64;arm64" CACHE STRING "Build architectures for Mac OS X" FORCE)
else()
  set(OSX_FRAMEWORK OFF)
endif()

or pass -DCMAKE_OSX_ARCHITECTURES=x86_64;arm64 to cmake

The current build system builds for x86_64 anytime, and the above command is to enable the universal binary build. If we only want to build for one arch at a time, we can change it to “arm64” in case of a build for M1.
Comment 2 Ruixuan Tu 2022-01-14 07:57:22 UTC
I am happy to help solve this problem if you can give me some hints, considering we may not have many developers with an M1 Mac available.
Comment 3 Jasem Mutlaq 2022-01-14 07:58:21 UTC
We have tens of CMakeLists.txt so this solution isn't viable. is there a way to set this in CraftSettings.ini ?
Comment 4 Jasem Mutlaq 2022-01-14 07:59:09 UTC
We also tried to build KStars on M1 Macs and failed due to this exact issue as well.
Comment 5 Hannah von Reth 2022-01-14 09:39:56 UTC
For now:
arch -arch x86_64 zsh -li
. craftenv.sh

Now craft will build everything in x86_64 mode.
Comment 6 Hannah von Reth 2022-01-14 09:42:56 UTC
And Qt5 has no support for arm builds for that reason we won't try to implement it.
Some where this year I'll play with qt6 and m1 builds.
Comment 7 Julius Künzel 2024-03-16 18:34:34 UTC
Craft can build software for macOS ARM now.