]> xenbits.xensource.com Git - libvirt.git/commitdiff
meson: Adjust -fstack-protector use
authorAndrea Bolognani <abologna@redhat.com>
Sat, 20 Jan 2024 16:06:38 +0000 (17:06 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Wed, 31 Jan 2024 10:25:32 +0000 (11:25 +0100)
Back in 2014, -fstack-protector was reported not to work on
aarch64, so fe881ae086ec disabled it on that target. OS-wise,
its use is currently limited to just Linux, FreeBSD and Windows.

Looking at the situation today, it seems that whatever issue was
affecting aarch64 a decade ago has been resolved; moreover,
macOS can also use the feature these days.

I haven't checked any of the other BSDs, but since the feature
works on FreeBSD it's pretty safe to assume that they can use
it too. If we get reports that it's not the case, we can always
further restrict its usage accordingly.

Best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
meson.build

index 611cc582c0a3ef404818bd77df6c9131b98e4bd7..e1c70fce92d5eec2fa8c0f3cd058bbc291dd89f5 100644 (file)
@@ -442,22 +442,17 @@ supported_cc_flags = []
 if get_option('warning_level') == '2'
   supported_cc_flags = cc.get_supported_arguments(cc_flags)
 
-  # on aarch64 error: -fstack-protector not supported for this target
-  if host_machine.cpu_family() != 'aarch64'
-    if host_machine.system() in [ 'linux', 'freebsd', 'windows' ]
-      # we prefer -fstack-protector-strong but fallback to -fstack-protector-all
-      fstack_cflags = cc.first_supported_argument([
-        '-fstack-protector-strong',
-        '-fstack-protector-all',
-      ])
-      supported_cc_flags += fstack_cflags
-
-      # When building with mingw using -fstack-protector requires libssp library
-      # which is included by using -fstack-protector with linker.
-      if fstack_cflags.length() == 1 and host_machine.system() == 'windows'
-        add_project_link_arguments(fstack_cflags, language: 'c')
-      endif
-    endif
+  # we prefer -fstack-protector-strong but fallback to -fstack-protector-all
+  fstack_cflags = cc.first_supported_argument([
+    '-fstack-protector-strong',
+    '-fstack-protector-all',
+  ])
+  supported_cc_flags += fstack_cflags
+
+  # When building with mingw using -fstack-protector requires libssp library
+  # which is included by using -fstack-protector with linker.
+  if fstack_cflags.length() == 1 and host_machine.system() == 'windows'
+    add_project_link_arguments(fstack_cflags, language: 'c')
   endif
 
   if supported_cc_flags.contains('-Wlogical-op')