Bug 454506 - Dbus fails to build on arm64 macOS (Apple sillicon / M1 hardware)
Summary: Dbus fails to build on arm64 macOS (Apple sillicon / M1 hardware)
Status: RESOLVED FIXED
Alias: None
Product: Craft
Classification: Unmaintained
Component: Blueprints (show other bugs)
Version: stable
Platform: Other macOS
: NOR normal
Target Milestone: ---
Assignee: Hannah von Reth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-27 21:07 UTC by Javier O. Cordero Pérez (Cuperino)
Modified: 2024-09-21 18:52 UTC (History)
3 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 Javier O. Cordero Pérez (Cuperino) 2022-05-27 21:07:25 UTC
SUMMARY
Dbus fails to build on arm64 macOS (Apple sillicon / M1 hardware). 

STEPS TO REPRODUCE
1. On an arm64 Mac, create a new Craft prefix:
> curl https://raw.githubusercontent.com/KDE/craft/master/setup/CraftBootstrap.py -o setup.py && python3 setup.py --prefix ~/CraftRoot
2. Start  the prefix:
> source ~/CraftRoot/craft/craftenv.sh
3. Install any KDE Framework, I've chosen extra-cmake-modules
> craft extra-cmake-modules

OBSERVED RESULT
While dbus is getting built, you get the following warning and errors:
>ld: warning: ignoring file /Users/javier/CraftRoot/lib/libexpat.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
>ld: warning: ignoring file /Users/javier/CraftRoot/lib/libexpat.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
>Undefined symbols for architecture arm64:
>  "_XML_ErrorString", referenced from:
>      _bus_config_load in libdbus-daemon-internal.a(config-loader-expat.o)
>  "_XML_GetCurrentColumnNumber", referenced from:
>      _bus_config_load in libdbus-daemon-internal.a(config-loader-expat.o)
>  "_XML_GetCurrentLineNumber", referenced from:
>      _bus_config_load in libdbus-daemon-internal.a(config-loader-expat.o)
>  "_XML_GetErrorCode", referenced from:
>      _bus_config_load in libdbus-daemon-internal.a(config-loader-expat.o)
>  "_XML_Parse", referenced from:
>      _bus_config_load in libdbus-daemon-internal.a(config-loader-expat.o)
>  "_XML_ParserCreate_MM", referenced from:
>      _bus_config_load in libdbus-daemon-internal.a(config-loader-expat.o)
>  "_XML_ParserFree", referenced from:
>      _bus_config_load in libdbus-daemon-internal.a(config-loader-expat.o)
>  "_XML_SetCharacterDataHandler", referenced from:
>      _bus_config_load in libdbus-daemon-internal.a(config-loader-expat.o)
>  "_XML_SetElementHandler", referenced from:
>      _bus_config_load in libdbus-daemon-internal.a(config-loader-expat.o)
>  "_XML_SetUserData", referenced from:
>      _bus_config_load in libdbus-daemon-internal.a(config-loader-expat.o)
>ld: symbol(s) not found for architecture arm64
>clang: error: linker command failed with exit code 1 (use -v to see invocation)
>make[2]: *** [dbus-daemon] Error 1
>make[2]: *** Waiting for unfinished jobs....
>Undefined symbols for architecture arm64:
>  "_XML_ErrorString", referenced from:
>      _bus_config_load in liblaunch-helper-internal.a(config-loader-expat.o)
>  "_XML_GetCurrentColumnNumber", referenced from:
>      _bus_config_load in liblaunch-helper-internal.a(config-loader-expat.o)
>  "_XML_GetCurrentLineNumber", referenced from:
>      _bus_config_load in liblaunch-helper-internal.a(config-loader-expat.o)
>  "_XML_GetErrorCode", referenced from:
>      _bus_config_load in liblaunch-helper-internal.a(config-loader-expat.o)
>  "_XML_Parse", referenced from:
>      _bus_config_load in liblaunch-helper-internal.a(config-loader-expat.o)
>  "_XML_ParserCreate_MM", referenced from:
>      _bus_config_load in liblaunch-helper-internal.a(config-loader-expat.o)
>  "_XML_ParserFree", referenced from:
>      _bus_config_load in liblaunch-helper-internal.a(config-loader-expat.o)
>  "_XML_SetCharacterDataHandler", referenced from:
>      _bus_config_load in liblaunch-helper-internal.a(config-loader-expat.o)
>  "_XML_SetElementHandler", referenced from:
>      _bus_config_load in liblaunch-helper-internal.a(config-loader-expat.o)
>  "_XML_SetUserData", referenced from:
>      _bus_config_load in liblaunch-helper-internal.a(config-loader-expat.o)
>ld: symbol(s) not found for architecture arm64
>clang: error: linker command failed with exit code 1 (use -v to see invocation)
>make[2]: *** [dbus-daemon-launch-helper] Error 1
>make[1]: *** [all-recursive] Error 1
>make: *** [all] Error 2
>Action: compile for libs/dbus:1.14.0 FAILED
>*** Craft all failed: libs/dbus after 26 seconds ***
>fatal error: package libs/dbus all failed
>Craft stopped with out completing ['libs/dbus', 'libs/libzstd', 'libs/libpng', 'dev-utils/nasm', 'libs/libjpeg-turbo', 'libs/sqlite', 'libs/libbzip2', 'libs/pcre2', 'libs/freetype', 'dev-utils/gperf', 'libs/fontconfig', 'libs/pixman', 'libs/cairo', 'libs/harfbuzz', 'dev-utils/flex', 'dev-utils/texinfo', 'dev-utils/help2man', 'dev-utils/bison', 'dev-utils/flexbison', 'libs/qt5/qtbase', 'libs/qt5/qtsvg', 'libs/qt5/qtdeclarative', 'libs/qt5/qttools', 'libs/qt5/qttranslations', 'dev-utils/icoutils', 'kde/frameworks/extra-cmake-modules']

EXPECTED RESULT
a) Arm64 binaries are provided and the build completes successfully, outputing an arm64 binary.
b) Alternatively, I would expect the source code for all dependencies to be downloaded and compiled locally, also resulting in an arm64 binary.
c) If making arm64 binaries for macOS were not a viable option with Qt5, I would expect Craft to successfully output an x86_64 build from the arm64 mac through emulation.

SOFTWARE/OS VERSIONS
macOS: macOS Monterrey 12.3.1

ADDITIONAL INFORMATION
Several months ago, Craft would run on macOS Big Sur and compile x86_64 binaries without an issue on the same hardware.
Comment 1 Javier O. Cordero Pérez (Cuperino) 2022-06-12 20:30:08 UTC
I've managed to successfully build Qt 5.15.3 and KF5 5.93.0 on macOS Big Sur 11.6 using clang compiler on an M1 Mac. No version of Qt 5.15 (tested 5.15.2 through 5.15.4) can be build on later versions of MacOS because of API changes in macOS 12. You have to use macOS Big Sur to create M1 builds of Qt 5.

After getting a working development environment on my system, I went back and tried getting Craft to work with Apple Silicon by making the following changes to `CraftSettings.ini`:
> ABI = macOS-arm64-clang
> UseCache = False

Then attempted to install kcoreaddons by running `craft --no-cache kcoreaddons`. Various dependencies installed successfully, but the build stopped early when glib failed to compile due to architecture mismatch while linking dependency libglib. Here are notable parts of compilation output, in case they're of any use:
>[130/1287] Compiling C object glib/tests/bitlock.p/bitlock.c.o
>[131/1287] Compiling Objective-C object glib/libglib-2.0.0.dylib.p/gosxutils.m.o
>[132/1287] Compiling C object glib/tests/cache.p/cache.c.o
>[133/1287] Compiling C object glib/tests/base64.p/base64.c.o
>[134/1287] Compiling C object glib/tests/charset.p/charset.c.o
>[135/1287] Compiling C object glib/tests/bytes.p/bytes.c.o
>[136/1287] Linking target glib/libglib-2.0.0.dylib
>FAILED: glib/libglib-2.0.0.dylib 
>cc  -o glib/libglib-2.0.0.dylib glib/libglib-2.0.0.dylib.p/deprecated_gallocator.c.o glib/libglib-2.0.0.dylib.p/deprecated_gcache.c.o glib/libglib-2.0.0.dylib.p/deprecated_gcompletion.c.o glib/libglib-2.0.0.dylib.p/deprecated_grel.c.o glib/libglib-2.0.0.dylib.p/deprecated_gthread-deprecated.c.o glib/libglib-2.0.0.dylib.p/garcbox.c.o glib/libglib-2.0.0.dylib.p/garray.c.o glib/libglib-2.0.0.dylib.p/gasyncqueue.c.o glib/libglib-2.0.0.dylib.p/gatomic.c.o glib/libglib-2.0.0.dylib.p/gbacktrace.c.o glib/libglib-2.0.0.dylib.p/gbase64.c.o glib/libglib-2.0.0.dylib.p/gbitlock.c.o glib/libglib-2.0.0.dylib.p/gbookmarkfile.c.o glib/libglib-2.0.0.dylib.p/gbytes.c.o glib/libglib-2.0.0.dylib.p/gcharset.c.o glib/libglib-2.0.0.dylib.p/gchecksum.c.o glib/libglib-2.0.0.dylib.p/gconvert.c.o glib/libglib-2.0.0.dylib.p/gdataset.c.o glib/libglib-2.0.0.dylib.p/gdate.c.o glib/libglib-2.0.0.dylib.p/gdatetime.c.o glib/libglib-2.0.0.dylib.p/gdir.c.o glib/libglib-2.0.0.dylib.p/genviron.c.o glib/libglib-2.0.0.dylib.p/gerror.c.o glib/libglib-2.0.0.dylib.p/gfileutils.c.o glib/libglib-2.0.0.dylib.p/ggettext.c.o glib/libglib-2.0.0.dylib.p/ghash.c.o glib/libglib-2.0.0.dylib.p/ghmac.c.o glib/libglib-2.0.0.dylib.p/ghook.c.o glib/libglib-2.0.0.dylib.p/ghostutils.c.o glib/libglib-2.0.0.dylib.p/giochannel.c.o glib/libglib-2.0.0.dylib.p/gkeyfile.c.o glib/libglib-2.0.0.dylib.p/glib-init.c.o glib/libglib-2.0.0.dylib.p/glib-private.c.o glib/libglib-2.0.0.dylib.p/glist.c.o glib/libglib-2.0.0.dylib.p/gmain.c.o glib/libglib-2.0.0.dylib.p/gmappedfile.c.o glib/libglib-2.0.0.dylib.p/gmarkup.c.o glib/libglib-2.0.0.dylib.p/gmem.c.o glib/libglib-2.0.0.dylib.p/gmessages.c.o glib/libglib-2.0.0.dylib.p/gnode.c.o glib/libglib-2.0.0.dylib.p/goption.c.o glib/libglib-2.0.0.dylib.p/gpattern.c.o glib/libglib-2.0.0.dylib.p/gpoll.c.o glib/libglib-2.0.0.dylib.p/gprimes.c.o glib/libglib-2.0.0.dylib.p/gqsort.c.o glib/libglib-2.0.0.dylib.p/gquark.c.o glib/libglib-2.0.0.dylib.p/gqueue.c.o glib/libglib-2.0.0.dylib.p/grand.c.o glib/libglib-2.0.0.dylib.p/grcbox.c.o glib/libglib-2.0.0.dylib.p/grefcount.c.o glib/libglib-2.0.0.dylib.p/grefstring.c.o glib/libglib-2.0.0.dylib.p/gregex.c.o glib/libglib-2.0.0.dylib.p/gscanner.c.o glib/libglib-2.0.0.dylib.p/gsequence.c.o glib/libglib-2.0.0.dylib.p/gshell.c.o glib/libglib-2.0.0.dylib.p/gslice.c.o glib/libglib-2.0.0.dylib.p/gslist.c.o glib/libglib-2.0.0.dylib.p/gstdio.c.o glib/libglib-2.0.0.dylib.p/gstrfuncs.c.o glib/libglib-2.0.0.dylib.p/gstring.c.o glib/libglib-2.0.0.dylib.p/gstringchunk.c.o glib/libglib-2.0.0.dylib.p/gtestutils.c.o glib/libglib-2.0.0.dylib.p/gthread.c.o glib/libglib-2.0.0.dylib.p/gthreadpool.c.o glib/libglib-2.0.0.dylib.p/gtimer.c.o glib/libglib-2.0.0.dylib.p/gtimezone.c.o glib/libglib-2.0.0.dylib.p/gtrace.c.o glib/libglib-2.0.0.dylib.p/gtranslit.c.o glib/libglib-2.0.0.dylib.p/gtrashstack.c.o glib/libglib-2.0.0.dylib.p/gtree.c.o glib/libglib-2.0.0.dylib.p/guniprop.c.o glib/libglib-2.0.0.dylib.p/gutf8.c.o glib/libglib-2.0.0.dylib.p/gunibreak.c.o glib/libglib-2.0.0.dylib.p/gunicollate.c.o glib/libglib-2.0.0.dylib.p/gunidecomp.c.o glib/libglib-2.0.0.dylib.p/guri.c.o glib/libglib-2.0.0.dylib.p/gutils.c.o glib/libglib-2.0.0.dylib.p/guuid.c.o glib/libglib-2.0.0.dylib.p/gvariant.c.o glib/libglib-2.0.0.dylib.p/gvariant-core.c.o glib/libglib-2.0.0.dylib.p/gvariant-parser.c.o glib/libglib-2.0.0.dylib.p/gvariant-serialiser.c.o glib/libglib-2.0.0.dylib.p/gvarianttypeinfo.c.o glib/libglib-2.0.0.dylib.p/gvarianttype.c.o glib/libglib-2.0.0.dylib.p/gversion.c.o glib/libglib-2.0.0.dylib.p/gwakeup.c.o glib/libglib-2.0.0.dylib.p/gprintf.c.o glib/libglib-2.0.0.dylib.p/glib-unix.c.o glib/libglib-2.0.0.dylib.p/gspawn.c.o glib/libglib-2.0.0.dylib.p/giounix.c.o glib/libglib-2.0.0.dylib.p/gosxutils.m.o glib/libglib-2.0.0.dylib.p/gthread-posix.c.o glib/libcharset/libcharset.a.p/localcharset.c.o glib/gnulib/libgnulib.a.p/asnprintf.c.o glib/gnulib/libgnulib.a.p/printf.c.o glib/gnulib/libgnulib.a.p/printf-args.c.o glib/gnulib/libgnulib.a.p/printf-parse.c.o glib/gnulib/libgnulib.a.p/printf-frexp.c.o glib/gnulib/libgnulib.a.p/printf-frexpl.c.o glib/gnulib/libgnulib.a.p/vasnprintf.c.o glib/gnulib/libgnulib.a.p/xsize.c.o glib/gnulib/libgnulib.a.p/isnand.c.o glib/gnulib/libgnulib.a.p/isnanf.c.o glib/gnulib/libgnulib.a.p/isnanl.c.o glib/pcre/libpcre.a.p/pcre_byte_order.c.o glib/pcre/libpcre.a.p/pcre_chartables.c.o glib/pcre/libpcre.a.p/pcre_compile.c.o glib/pcre/libpcre.a.p/pcre_config.c.o glib/pcre/libpcre.a.p/pcre_dfa_exec.c.o glib/pcre/libpcre.a.p/pcre_exec.c.o glib/pcre/libpcre.a.p/pcre_fullinfo.c.o glib/pcre/libpcre.a.p/pcre_get.c.o glib/pcre/libpcre.a.p/pcre_globals.c.o glib/pcre/libpcre.a.p/pcre_jit_compile.c.o glib/pcre/libpcre.a.p/pcre_newline.c.o glib/pcre/libpcre.a.p/pcre_ord2utf8.c.o glib/pcre/libpcre.a.p/pcre_string_utils.c.o glib/pcre/libpcre.a.p/pcre_study.c.o glib/pcre/libpcre.a.p/pcre_tables.c.o glib/pcre/libpcre.a.p/pcre_valid_utf8.c.o glib/pcre/libpcre.a.p/pcre_version.c.o glib/pcre/libpcre.a.p/pcre_xclass.c.o -L/Users/javier/CraftRoot/lib -I/opt/homebrew/opt/qt@5/include -Wl,-dead_strip_dylibs -Wl,-headerpad_max_install_names -Wl,-undefined,error -shared -install_name @rpath/libglib-2.0.0.dylib -compatibility_version 6601 -current_version 6601.4 -Wl,-framework,CoreFoundation -Wl,-framework,Carbon -Wl,-framework,Foundation -Wl,-framework,AppKit -lintl -Wl,-rpath,/Users/javier/CraftRoot/lib -liconv -lm
>ld: warning: ignoring file /Users/javier/CraftRoot/lib/libintl.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
>Undefined symbols for architecture x86_64:
>  "_libintl_bind_textdomain_codeset", referenced from:
>      _glib_gettext in ggettext.c.o
>      _glib_pgettext in ggettext.c.o
>  "_libintl_bindtextdomain", referenced from:
>      _glib_gettext in ggettext.c.o
>      _glib_pgettext in ggettext.c.o
>  "_libintl_dcgettext", referenced from:
>      _g_dcgettext in ggettext.c.o
>  "_libintl_dgettext", referenced from:
>      _glib_gettext in ggettext.c.o
>      _g_dgettext in ggettext.c.o
>      _g_dpgettext in ggettext.c.o
>      _g_dpgettext2 in ggettext.c.o
>  "_libintl_dngettext", referenced from:
>      _g_dngettext in ggettext.c.o
>  "_libintl_gettext", referenced from:
>      __g_dgettext_should_translate in ggettext.c.o
>  "_libintl_newlocale", referenced from:
>      _g_strtod in gstrfuncs.c.o
>      _g_ascii_strtod in gstrfuncs.c.o
>      _g_ascii_formatd in gstrfuncs.c.o
>      _g_ascii_strtoull in gstrfuncs.c.o
>      _g_ascii_strtoll in gstrfuncs.c.o
>      _g_ascii_string_to_signed in gstrfuncs.c.o
>      _g_ascii_string_to_unsigned in gstrfuncs.c.o
>      ...
>  "_libintl_setlocale", referenced from:
>      __g_dgettext_should_translate in ggettext.c.o
>  "_libintl_textdomain", referenced from:
>      __g_dgettext_should_translate in ggettext.c.o
>ld: symbol(s) not found for architecture x86_64
>clang: error: linker command failed with exit code 1 (use -v to see invocation)
>[137/1287] Compiling C object glib/tests/checksum.p/checksum.c.o
>[138/1287] Compiling C object glib/tests/bookmarkfile.p/bookmarkfile.c.o
>[139/1287] Compiling C object glib/tests/collate.p/collate.c.o
>[140/1287] Compiling C object glib/tests/cond.p/cond.c.o
>[141/1287] Compiling C object glib/tests/array-test.p/array-test.c.o
>[142/1287] Compiling C object glib/tests/dataset.p/dataset.c.o
>[143/1287] Compiling C object glib/tests/convert.p/convert.c.o
>ninja: build stopped: subcommand failed.
>Action: compile for libs/glib:2.66.4-1 FAILED
>*** Craft all failed: libs/glib after 22 seconds ***
>fatal error: package libs/glib all failed
>Craft stopped with out completing ['libs/glib', 'libs/dbus', 'libs/libzstd', 'libs/libpng', 'dev-utils/nasm', 'libs/libjpeg-turbo', 'libs/sqlite', 'libs/libbzip2', 'libs/pcre2', 'libs/freetype', 'dev-utils/gperf', 'libs/fontconfig', 'libs/pixman', 'libs/cairo', 'libs/harfbuzz', 'dev-utils/flex', 'dev-utils/texinfo', 'dev-utils/help2man', 'dev-utils/bison', 'dev-utils/flexbison', 'libs/qt5/qtbase', 'libs/qt5/qtsvg', 'libs/qt5/qtdeclarative', 'libs/qt5/qttools', 'libs/qt5/qttranslations', 'perl-modules/xml-parser', 'dev-utils/intltool', 'libs/shared-mime-info', 'dev-utils/icoutils', 'kde/frameworks/extra-cmake-modules', 'kde/frameworks/tier1/kcoreaddons']
Comment 2 Jeremy Whiting 2022-06-12 23:18:23 UTC
>ld: warning: ignoring file /Users/javier/CraftRoot/lib/libexpat.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64


that's the key, it's trying to build a x86_64 build but trying to link to arm libraries. It seems the craft ini file change to arm isn't taking effect in this case. Since it's built with cmake the key is to add https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_ARCHITECTURES.html somehow. Maybe cmake is already setting this (or craft is using cmake to set that) but that's the key.
Comment 3 Christoph Cullmann 2024-09-21 18:52:24 UTC
Tested it, that works with Qt6 and in addition most stuff no longer needs it there thanks to the last patch rounds.