summaryrefslogtreecommitdiff
path: root/gio/tests/meson.build
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2023-01-08 11:14:35 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2023-01-28 10:46:50 +0000
commit6d93568e3670e8c9920e02781eeec011d0c1c759 (patch)
tree0ac281484bdf4d3462ad893bf65ca8a524a300c3 /gio/tests/meson.build
parenteafd19da298f2d97232d73a366291f8026a979bd (diff)
downloadglib-6d93568e3670e8c9920e02781eeec011d0c1c759.tar.gz
Fix building gio/tests/test_resources.o with LLVM ld
Unlike GNU ld which has a default target architecture, ld.lld is always a cross-linker and has the same behaviour for all targets. If you don't tell ld.lld what the target architecture is it can't infer the right ELF flags for the resulting object file. ``` $ ~/cheri/output/sdk/bin/ld -r -b binary gio/tests/test5.gresource -o gio/tests/test_resources.o -v LLD 14.0.0 (compatible with GNU linkers) ld: error: target emulation unknown: -m or at least one .o file required ``` As you can see from the error message it can't infer the target architecture (you need a least one valid .o file or the -m flag). If you use the compiler instead of directly invoking the linker it will pass the appropriate flags: ``` $ ~/cheri/output/sdk/bin/clang -r -Wl,-b,binary gio/tests/test5.gresource -o gio/tests/test_resources.o -v clang version 14.0.0 (https://github.com/CTSRD-CHERI/llvm-project.git ff66b683475fc44355b2010dbcbe1202d785e6f8) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/alexrichardson/cheri/output/sdk/bin Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12 Candidate multilib: .;@m64 Selected multilib: .;@m64 "/home/alexrichardson/cheri/output/sdk/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o gio/tests/test_resources.o -L/usr/lib/gcc/x86_64-linux-gnu/12 -L/usr/lib/gcc/x86_64-linux-gnu/12/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -L/home/alexrichardson/cheri/output/sdk/bin/../lib -L/lib -L/usr/lib -r -b binary gio/tests/test5.gresource ❯ file gio/tests/test_resources.o gio/tests/test_resources.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped ``` This works for most architectures, but ones that need additional metadata sections to encode the used ABI, etc. will require a different approach using .incbin. However, that is a change for another MR. Partially fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2720
Diffstat (limited to 'gio/tests/meson.build')
-rw-r--r--gio/tests/meson.build8
1 files changed, 2 insertions, 6 deletions
diff --git a/gio/tests/meson.build b/gio/tests/meson.build
index de5b80d72..3557b6944 100644
--- a/gio/tests/meson.build
+++ b/gio/tests/meson.build
@@ -928,12 +928,8 @@ if not meson.is_cross_build()
test_resources_binary = custom_target('test_resources.o',
input : test_gresource_binary,
output : 'test_resources.o',
- command : [ld,
- '-z', 'noexecstack',
- '-r',
- '-b','binary',
- '@INPUT@',
- '-o','@OUTPUT@'])
+ command : cc.cmd_array() + ['-Wl,-z,noexecstack', '-r', '-Wl,-b,binary',
+ '@INPUT@', '-o','@OUTPUT@'])
# Rename symbol to match the one in the C file
if cc.get_id() == 'gcc' and host_system == 'windows'