summaryrefslogtreecommitdiffstats
path: root/meson.build
diff options
context:
space:
mode:
authorPaolo Bonzini2022-03-15 15:57:15 +0100
committerPaolo Bonzini2022-10-01 21:16:36 +0200
commite4333d14c574631029e2d9d00bcb94b81a8df800 (patch)
tree64978fd788f42f10d22004e0c5e45e10600d1f0d /meson.build
parentconfigure, meson: move C++ compiler detection to meson.build (diff)
downloadqemu-e4333d14c574631029e2d9d00bcb94b81a8df800.tar.gz
qemu-e4333d14c574631029e2d9d00bcb94b81a8df800.tar.xz
qemu-e4333d14c574631029e2d9d00bcb94b81a8df800.zip
configure, meson: move linker flag detection to meson
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build13
1 files changed, 13 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index 9c57ebdfb9..e9b0125b41 100644
--- a/meson.build
+++ b/meson.build
@@ -183,6 +183,14 @@ qemu_cflags = config_host['QEMU_CFLAGS'].split()
qemu_objcflags = config_host['QEMU_OBJCFLAGS'].split()
qemu_ldflags = config_host['QEMU_LDFLAGS'].split()
+if enable_static
+ qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static'
+endif
+
+# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
+# The combination is known as "full relro", because .got.plt is read-only too.
+qemu_ldflags += cc.get_supported_link_arguments('-Wl,-z,relro', '-Wl,-z,now')
+
if targetos == 'windows'
qemu_ldflags += cc.get_supported_link_arguments('-Wl,--no-seh', '-Wl,--nxcompat')
# Disable ASLR for debug builds to allow debugging with gdb
@@ -265,6 +273,11 @@ if add_languages('cpp', required: false, native: false)
endif
endif
+# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
+if targetos != 'sunos' and not config_host.has_key('CONFIG_TSAN')
+ qemu_ldflags += linker.get_supported_link_arguments('-Wl,--warn-common')
+endif
+
add_global_link_arguments(qemu_ldflags, native: false, language: ['c', 'cpp', 'objc'])
if targetos == 'linux'