[PATCH] build: Ensure mandatory compiler/linker flags

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Jul 8 09:17:38 UTC 2020


---
 waf_libbsd.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/waf_libbsd.py b/waf_libbsd.py
index a817e574..bfe23845 100644
--- a/waf_libbsd.py
+++ b/waf_libbsd.py
@@ -55,6 +55,11 @@ if windows:
 else:
     host_shell = ''
 
+def _add_flags_if_not_present(current_flags, addional_flags):
+    for flag in addional_flags:
+        if flag not in current_flags:
+            current_flags.append(flag)
+
 #
 # The waf builder for libbsd.
 #
@@ -168,6 +173,10 @@ class Builder(builder.ModuleManager):
                                           mandatory = False)
                     else:
                         bld.fatal('invalid config test: %s' % (configTest))
+            section_flags = ["-fdata-sections", "-ffunction-sections"]
+            _add_flags_if_not_present(conf.env.CFLAGS, section_flags)
+            _add_flags_if_not_present(conf.env.CXXFLAGS, section_flags)
+            _add_flags_if_not_present(conf.env.LINKFLAGS, ["-Wl,--gc-sections"])
 
 
     def build(self, bld):
-- 
2.26.2



More information about the devel mailing list