[rtems-libbsd commit] Allow to set optimization level during configure.
Sebastian Huber
sebh at rtems.org
Mon Oct 2 12:19:22 UTC 2017
Module: rtems-libbsd
Branch: master
Commit: d18c6435c4410c3109a4d8acc6e4b48925417d90
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=d18c6435c4410c3109a4d8acc6e4b48925417d90
Author: Christian Mauderer <Christian.Mauderer at embedded-brains.de>
Date: Mon Oct 2 09:57:04 2017 +0200
Allow to set optimization level during configure.
This allows to set the optimization level for libbsd via a configure
switch. Useful for building with for example no optimization during
debug or with size optimization for space restricted targets.
---
builder.py | 3 +--
libbsd_waf.py | 2 +-
waf_generator.py | 1 +
wscript | 6 ++++++
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/builder.py b/builder.py
index b62f79d..ae2e6ee 100755
--- a/builder.py
+++ b/builder.py
@@ -156,8 +156,7 @@ class diffRecord:
# This stuff needs to move to libbsd.py.
#
def commonFlags():
- return ['-O2',
- '-g',
+ return ['-g',
'-fno-strict-aliasing',
'-ffreestanding',
'-fno-common']
diff --git a/libbsd_waf.py b/libbsd_waf.py
index a2f581f..02e8703 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -34,7 +34,7 @@ def configure(conf):
def build(bld):
# C/C++ flags
common_flags = []
- common_flags += ["-O2"]
+ common_flags += ["-O" + bld.env.OPTIMIZATION]
common_flags += ["-g"]
common_flags += ["-fno-strict-aliasing"]
common_flags += ["-ffreestanding"]
diff --git a/waf_generator.py b/waf_generator.py
index a482623..3a31597 100755
--- a/waf_generator.py
+++ b/waf_generator.py
@@ -371,6 +371,7 @@ class ModuleManager(builder.ModuleManager):
self.add('def build(bld):')
self.add(' # C/C++ flags')
self.add(' common_flags = []')
+ self.add(' common_flags += ["-O%s" % (bld.env.OPTIMIZATION)]')
for f in builder.commonFlags():
self.add(' common_flags += ["%s"]' % (f))
self.add(' if bld.env.WARNINGS:')
diff --git a/wscript b/wscript
index 7088eab..d3ce7e2 100644
--- a/wscript
+++ b/wscript
@@ -68,6 +68,11 @@ def options(opt):
default = "",
dest = "freebsd_options",
help = "Set FreeBSD options (developer option).")
+ opt.add_option("--optimization",
+ action = "store",
+ default = "2",
+ dest = "optimization",
+ help = "Set optimization level to OPTIMIZATION (-On compiler flag). Default is 2 (-O2).")
libbsd_waf.options(opt)
def bsp_configure(conf, arch_bsp):
@@ -88,6 +93,7 @@ def configure(conf):
conf.env.WARNINGS = conf.options.warnings
conf.env.NET_CONFIG = conf.options.net_config
conf.env.FREEBSD_OPTIONS =conf.options.freebsd_options
+ conf.env.OPTIMIZATION = conf.options.optimization
rtems.configure(conf, bsp_configure)
libbsd_waf.configure(conf)
More information about the vc
mailing list