xref: /OK3568_Linux_fs/buildroot/package/usbredir/0002-meson-add-stack_protector-option.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 54cf1897ef3aa4d0a35b5f4eb1f5c6928b033af5 Mon Sep 17 00:00:00 2001
2From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3Date: Fri, 24 Sep 2021 17:24:43 +0200
4Subject: [PATCH] meson: add stack_protector option
5
6Add stack_protector option to allow the user to disable it as some
7embedded toolchains don't support it which will result in the following
8build failure:
9
10/home/giuliobenetti/autobuild/run/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/9.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: usbredirparser/libusbredirparser.so.1.1.0.p/usbredirparser.c.o: in function `va_log':
11usbredirparser.c:(.text+0x1c4): undefined reference to `__stack_chk_guard'
12
13Fixes:
14 - http://autobuild.buildroot.org/results/40de5443e98157ad50c6841ea70a835cd5ad4fe9
15
16Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
17[Upstream status:
18https://gitlab.freedesktop.org/spice/usbredir/-/merge_requests/53]
19---
20 meson.build       | 6 +++++-
21 meson_options.txt | 5 +++++
22 2 files changed, 10 insertions(+), 1 deletion(-)
23
24diff --git a/meson.build b/meson.build
25index a6d21b8..4350f53 100644
26--- a/meson.build
27+++ b/meson.build
28@@ -17,8 +17,12 @@ cc_flags = [
29 if host_machine.system() != 'windows'
30     cc_flags += [
31 	'-Wp,-D_FORTIFY_SOURCE=2',
32-	'-fstack-protector',
33     ]
34+    if get_option('stack_protector').enabled()
35+        cc_flags += [
36+	    '-fstack-protector',
37+        ]
38+    endif
39 endif
40
41 # Check if we are building from .git
42diff --git a/meson_options.txt b/meson_options.txt
43index 63e8c85..34dd392 100644
44--- a/meson_options.txt
45+++ b/meson_options.txt
46@@ -17,6 +17,11 @@ option('fuzzing-install-dir',
47     type : 'string',
48     description : 'Installation directory for fuzzing binaries')
49
50+option('stack_protector',
51+    type : 'feature',
52+    value : 'enabled',
53+    description : 'Build usbredir\'s with stack-protector')
54+
55 option('tools',
56     type : 'feature',
57     value : 'enabled',
58--
592.33.0
60
61