From 178681e5fd6fc169fa3313b5263151de2b4a1d5c Mon Sep 17 00:00:00 2001 From: Henrik Gramner Date: Thu, 8 Sep 2022 16:45:46 +0200 Subject: build: Improve Windows linking options --- meson.build | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/meson.build b/meson.build index 0501ef2..3369d03 100644 --- a/meson.build +++ b/meson.build @@ -87,6 +87,7 @@ cdata.set10('CONFIG_LOG', get_option('logging')) test_args = [] optional_arguments = [] +optional_link_arguments = [] if host_machine.system() == 'linux' test_args += '-D_GNU_SOURCE' @@ -112,6 +113,18 @@ if host_machine.system() == 'windows' cdata.set('ftello', '_ftelli64') endif + if host_machine.cpu_family() == 'x86_64' + if cc.get_argument_syntax() != 'msvc' + optional_link_arguments += '-Wl,--dynamicbase,--nxcompat,--tsaware,--high-entropy-va' + endif + elif host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'arm' + if cc.get_argument_syntax() == 'msvc' + optional_link_arguments += '/largeaddressaware' + else + optional_link_arguments += '-Wl,--dynamicbase,--nxcompat,--tsaware,--large-address-aware' + endif + endif + # On Windows, we use a compatibility layer to emulate pthread thread_dependency = [] thread_compat_dep = declare_dependency(sources : files('src/win32/thread.c')) @@ -296,6 +309,7 @@ if (host_machine.system() == 'darwin' and cc.get_id() == 'clang' and endif add_project_arguments(cc.get_supported_arguments(optional_arguments), language : 'c') +add_project_link_arguments(cc.get_supported_link_arguments(optional_link_arguments), language : 'c') # libFuzzer related things fuzzing_engine = get_option('fuzzing_engine') -- cgit v1.2.3