[Git][NTPsec/ntpsec][master] easier-to-use conditional warning flags
Eric S. Raymond
gitlab at mg.gitlab.com
Tue Apr 11 14:08:18 UTC 2017
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
fa68a887 by Trevor N at 2017-04-11T10:08:09-04:00
easier-to-use conditional warning flags
I noticed that more flags were added into the check list, but valid flags are added to CFLAGS in a second step far away from the list and the second step was skipped. Using a loop to add the flags will prevent this from happening.
- - - - -
1 changed file:
- wafhelpers/configure.py
Changes:
=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -308,7 +308,7 @@ def cmd_configure(ctx, config):
"-Wswitch-default",
"-Wwrite-strings",
]
- cc_test_flags += [
+ cc_test_and_add_flags = [
('w_format_signedness', '-Wformat-signedness'), # fails on OpenBSD 6
('w_sign_conversion', "-Wsign-conversion"), # fails on Solaris and OpenBSD 6
('w_suggest_attribute_noreturn', "-Wsuggest-attribute=noreturn"), # fails on clang
@@ -345,6 +345,16 @@ int main(int argc, char **argv) {
msg='Checking if C compiler supports ' + name,
run_build_cls='oc')
+ for (name, ccflag) in cc_test_and_add_flags:
+ ctx.check(cflags=ccflag,
+ define_name='HAS_' + name,
+ fragment=FRAGMENT,
+ mandatory=False,
+ msg='Checking if C compiler supports ' + ccflag,
+ run_build_cls='oc')
+ if ctx.env['HAS_' + name]:
+ ctx.env.CFLAGS += [ccflag]
+
ctx.run_build_cls = old_run_build_cls
# We require some things that C99 doesn't enable, like pthreads.
@@ -387,16 +397,6 @@ int main(int argc, char **argv) {
"-flto",
]
- # debug warnings that are not available with all compilers
- if ctx.env.HAS_w_format_signedness:
- ctx.env.CFLAGS += [
- '-Wformat-signedness',
- ]
- if ctx.env.HAS_w_sign_conversion:
- ctx.env.CFLAGS += [
- '-Wsign-conversion',
- ]
-
# old gcc takes -z,relro, but then barfs if -fPIE available and used.
# ("relro", "-Wl,-z,relro"), # marks some sections read only
old_run_build_cls = ctx.run_build_cls
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/fa68a88752bb8e782cf19fb6e1bd378d0b803f21
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170411/bdc1b014/attachment.html>
More information about the vc
mailing list