error: target emulation unknown: -m or at least one .o file required [possible workaround]
Steps to reproduce
- Set up env with Clang 15 and lld linker
- Try compile GTK4
- See error
Current behavior
When trying compile GTK4 (current one gtk 4.10.1 and also previous from 4.8 series) I see build error when compiling with Clang and default linker lld on OpenMandriva Cooker.
FAILED: demos/widget-factory/widgetfactory_resources.o
DEBUG util.py:445: /usr/bin/ld -z noexecstack -r -b binary demos/widget-factory/widgetfactory.gresource -o demos/widget-factory/widgetfactory_resources.o
DEBUG util.py:445: ld: error: target emulation unknown: -m or at least one .o file required
DEBUG util.py:445: ld: warning: -r and --gc-sections may not be used together, disabling --gc-sections
DEBUG util.py:445: ld: warning: -r and --icf may not be used together, disabling --icf
Full build log gtk4.8.3 : https://file-store.openmandriva.org/api/v1/file_stores/7e4cfec3f41c3919af00e4d545a4621ffc82bfb8.log?show=true
Full build log gtk4.10.1: https://file-store.openmandriva.org/api/v1/file_stores/ba7c8a7a3294199780904cec3a7858bae96ae90d.log?show=true
Worth to add, this error keeps showing even when I set env variable to other linker. So looks like linker settings is not respected.
Also we are able to workaround this by patching gtk with this diff and force it to use bfd:
| diff -uraN gtk-4.8.2/demos/gtk-demo/meson.build omv-gtk-4.8.2/demos/gtk-demo/meson.build | |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------|
| --- gtk-4.8.2/demos/gtk-demo/meson.build | 2022-10-24 19:46:56.000000000 +0200 |
| +++ omv-gtk-4.8.2/demos/gtk-demo/meson.build | 2022-10-25 17:07:07.122672672 +0200 |
| @@ -159,7 +159,7 @@ | |
| objcopy_supports_add_symbol = run_command(objcopy, '--help').stdout().contains('--add-symbol') | |
| endif | |
| | |
| -ld = find_program('ld', required : false) | |
| +ld = find_program('ld.bfd', required : false) | |
| | |
| if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found() | |
| glib_compile_resources = find_program('glib-compile-resources') | |
| diff -uraN gtk-4.8.2/demos/widget-factory/meson.build omv-gtk-4.8.2/demos/widget-factory/meson.build | |
| --- gtk-4.8.2/demos/widget-factory/meson.build | 2022-10-24 19:46:56.000000000 +0200 |
| +++ omv-gtk-4.8.2/demos/widget-factory/meson.build | 2022-10-25 17:07:47.247672181 +0200 |
| @@ -6,7 +6,7 @@ | |
| objcopy_supports_add_symbol = run_command(objcopy, '--help').stdout().contains('--add-symbol') | |
| endif | |
| | |
| -ld = find_program('ld', required : false) | |
| +ld = find_program('ld.bfd', required : false) | |
| | |
| if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found() | |
| glib_compile_resources = find_program('glib-compile-resources') | |
| diff -uraN gtk-4.8.2/gtk/meson.build omv-gtk-4.8.2/gtk/meson.build | |
| --- gtk-4.8.2/gtk/meson.build | 2022-10-24 19:46:56.000000000 +0200 |
| +++ omv-gtk-4.8.2/gtk/meson.build | 2022-10-25 17:08:47.663847295 +0200 |
| @@ -874,7 +874,7 @@ | |
| objcopy_supports_add_symbol = run_command(objcopy, '--help').stdout().contains('--add-symbol') | |
| endif | |
| | |
| -ld = find_program('ld', required : false) | |
| +ld = find_program('ld.bfd', required : false) | |
| | |
| if not meson.is_cross_build() and build_machine.cpu_family() == 'x86_64' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found() | |
| glib_compile_resources = find_program('glib-compile-resources') | |
Expected outcome
All compiles fine with Clang and default linker
Version information
GTK 4.10.1 (4.8.3 affected too)
OpenMandriva Cooker
Meson variable used to compile gtk:
-Dx11-backend=true \
-Dwayland-backend=true \
-Dbroadway-backend=true \
-Dvulkan=enabled \
-Dmedia-ffmpeg=enabled \
-Dmedia-gstreamer=enabled \
-Dsysprof=enabled \
-Dcolord=enabled \
-Dcloudproviders=disabled \
-Dgtk_doc=false \
-Dman-pages=true \
-Dtracker=enabled \
-Dinstall-tests=false