From 77938ac3e3f409635591e3bc0a4917edba4d78f5 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 8 Jul 2020 11:17:38 +0200 Subject: build: Ensure mandatory compiler/linker flags --- waf_libbsd.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/waf_libbsd.py b/waf_libbsd.py index 558690b1..17cab509 100644 --- a/waf_libbsd.py +++ b/waf_libbsd.py @@ -57,6 +57,10 @@ 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. @@ -182,6 +186,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): # -- cgit v1.2.3