summaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-09-03 10:35:08 +0200
committerKarolin Seeger <kseeger@samba.org>2018-09-26 13:01:08 +0200
commit7249a4e54b290bb2d3081d2cbcee3ebcd6f198a9 (patch)
treee04af22b5754f534c8c1e271cf07ab7cbee94716 /buildtools
parent7a39bcd0ba2b967d5eac58202f49d4624e739aeb (diff)
downloadsamba-7249a4e54b290bb2d3081d2cbcee3ebcd6f198a9.tar.gz
waf: Check for -fstack-protect-strong support
The -fstack-protector* flags are compiler only flags, don't pass them to the linker. https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc/ BUG: https://bugzilla.samba.org/show_bug.cgi?id=13601 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> (cherry picked from commit 38e97f8b52e85bdfcf2d74a4fb3c848fa46ba371)
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/wafsamba/samba_autoconf.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index c4391d0c4dc..bfd6f9710db 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -674,23 +674,25 @@ def SAMBA_CONFIG_H(conf, path=None):
return
# we need to build real code that can't be optimized away to test
- if conf.check(fragment='''
- #include <stdio.h>
-
- int main(void)
- {
- char t[100000];
- while (fgets(t, sizeof(t), stdin));
- return 0;
- }
- ''',
- execute=0,
- ccflags='-fstack-protector',
- ldflags='-fstack-protector',
- mandatory=False,
- msg='Checking if toolchain accepts -fstack-protector'):
- conf.ADD_CFLAGS('-fstack-protector')
- conf.ADD_LDFLAGS('-fstack-protector')
+ stack_protect_list = ['-fstack-protector-strong', '-fstack-protector']
+ for stack_protect_flag in stack_protect_list:
+ flag_supported = conf.check(fragment='''
+ #include <stdio.h>
+
+ int main(void)
+ {
+ char t[100000];
+ while (fgets(t, sizeof(t), stdin));
+ return 0;
+ }
+ ''',
+ execute=0,
+ ccflags=[ '-Werror', '-Wp,-D_FORTIFY_SOURCE=2', stack_protect_flag],
+ mandatory=False,
+ msg='Checking if compiler accepts %s' % (stack_protect_flag))
+ if flag_supported:
+ conf.ADD_CFLAGS('-Wp,-D_FORTIFY_SOURCE=2 %s' % (stack_protect_flag))
+ break
if Options.options.debug:
conf.ADD_CFLAGS('-g', testflags=True)