[Git][NTPsec/ntpsec][master] 2 commits: waf: improve test for bad linker flags.

Gary E. Miller gitlab at mg.gitlab.com
Fri Feb 24 16:48:06 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
4bed6cb6 by Gary E. Miller at 2017-02-23T19:20:49-08:00
waf: improve test for bad linker flags.

- - - - -
175e4f8e by Gary E. Miller at 2017-02-24T08:46:06-08:00
waf: improve CFLAGS and LDFLAGS tests.  Save -fPIE for bins.

Not supposed to build shared libs with -fPIE, so don't.

- - - - -


1 changed file:

- wafhelpers/configure.py


Changes:

=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -21,7 +21,7 @@ class oc(Build.BuildContext):
             self.logger.debug('WafError')
             return e.returncode
         if (len(out) and any(word in out for word
-                             in ['ignored', 'illegal', 'unknown',
+                             in ['err', 'ignored', 'illegal', 'unknown',
                                  'unrecognized', 'warning'])):
             self.logger.debug('noooo %r' % out)
             return 1
@@ -286,12 +286,11 @@ int main(int argc, char **argv) {
             ]
 
     if ctx.env.HAS_PIE:
-        ctx.env.CFLAGS += [
+        ctx.env.CFLAGS_bin += [
             "-fPIE",
             "-pie",
             ]
         ld_hardening_flags += [
-            ('PIE', "-fPIE"),           # hardening
             ('relro', "-Wl,-z,relro"),  # hardening, marks some read only,
             ]
 
@@ -314,20 +313,24 @@ int main(int argc, char **argv) {
 
     # old gcc takes -z,relro, but then barfs if -fPIE available and used.
     # ("relro", "-Wl,-z,relro"), # marks some sections read only
-
     for (name, ldflag) in ld_hardening_flags:
         cmd = [ctx.env.CC_NAME, ldflag]
         # print("cmd: %s" % cmd)
         ctx.start_msg("Checking if linker supports hardening flag: %s" % name)
+        err = 0
         try:
-            ctx.cmd_and_log(cmd)
+            err, out = ctx.cmd_and_log(cmd)
         except Exception as e:
-            if not any(word in e.stderr for word
-                       in ['ignored', 'illegal', 'unknown', 'unrecognized']):
-                ctx.env.LDFLAGS += [ldflag]
-                ctx.end_msg("yes")
-            else:
-                ctx.end_msg("no", color="YELLOW")
+            if any(word in e.stderr for word
+                       in ['err', 'ignored', 'illegal', 'unknown',
+                           'unrecognized', 'warning']):
+                err = 1
+
+        if err:
+            ctx.end_msg("no", color="YELLOW")
+        else:
+            ctx.env.LDFLAGS += [ldflag]
+            ctx.end_msg("yes")
 
     if ctx.env.CC_NAME == "sun":
         # we are sun, placeholder



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/b392b7e5923596b7f5827f55485a8e4a57b5da27...175e4f8e27b304eebfbc12599cae074d1c309105
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170224/e9ba9c83/attachment.html>


More information about the vc mailing list