From b80c3758e781ebbaf5b8aa2fb2b343a3dad70a57 Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 10 Jan 2017 15:30:31 -0600 Subject: [PATCH] Turn off optimizations for uvision and IAR --- tools/export/iar/__init__.py | 15 +++++++-------- tools/export/uvision/__init__.py | 28 ++++++++++------------------ tools/export/uvision/uvision.tmpl | 2 +- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/tools/export/iar/__init__.py b/tools/export/iar/__init__.py index 88bc695d54..3951d915cd 100644 --- a/tools/export/iar/__init__.py +++ b/tools/export/iar/__init__.py @@ -89,16 +89,15 @@ class IAR(Exporter): self.resources.c_sources + self.resources.cpp_sources + \ self.resources.objects + self.resources.libraries flags = self.flags - flags['c_flags'] = list(set(flags['common_flags'] + c_flags = list(set(flags['common_flags'] + flags['c_flags'] + flags['cxx_flags'])) - if '--vla' in flags['c_flags']: - flags['c_flags'].remove('--vla') - if '--no_static_destruction' in flags['c_flags']: - flags['c_flags'].remove('--no_static_destruction') - #Optimizations - if '-Oh' in flags['c_flags']: - flags['c_flags'].remove('-Oh') + # Flags set in template to be set by user in IDE + template = ["--vla", "--no_static_destruction"] + # Flag invalid if set in template + # Optimizations are also set in template + invalid_flag = lambda x: x in template or re.match("-O(\d|time|n)", x) + flags['c_flags'] = [flag for flag in c_flags if not invalid_flag(flag)] try: debugger = DeviceCMSIS(self.target).debug.replace('-','').upper() diff --git a/tools/export/uvision/__init__.py b/tools/export/uvision/__init__.py index a6dd2ef395..b26a7a13ea 100644 --- a/tools/export/uvision/__init__.py +++ b/tools/export/uvision/__init__.py @@ -155,27 +155,19 @@ class Uvision(Exporter): def format_flags(self): """Format toolchain flags for Uvision""" flags = copy.deepcopy(self.flags) + # to be preprocessed with armcc asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + \ ",".join(flags['asm_flags']) - # asm flags only, common are not valid within uvision project, - # they are armcc specific flags['asm_flags'] = asm_flag_string - # cxx flags included, as uvision have them all in one tab - flags['c_flags'] = list(set(['-D__ASSERT_MSG'] - + flags['common_flags'] - + flags['c_flags'] - + flags['cxx_flags'])) - # not compatible with c99 flag set in the template - try: flags['c_flags'].remove("--c99") - except ValueError: pass - # cpp is not required as it's implicit for cpp files - try: flags['c_flags'].remove("--cpp") - except ValueError: pass - # we want no-vla for only cxx, but it's also applied for C in IDE, - # thus we remove it - try: flags['c_flags'].remove("--no_vla") - except ValueError: pass - flags['c_flags'] =" ".join(flags['c_flags']) + # All non-asm flags are in one template field + c_flags = list(set(flags['c_flags'] + flags['cxx_flags'] +flags['common_flags'])) + # These flags are in template to be set by user i n IDE + template = ["--no_vla", "--cpp", "--c99"] + # Flag is invalid if set in template + # Optimizations are also set in the template + invalid_flag = lambda x: x in template or re.match("-O(\d|time)", x) + flags['c_flags'] = [flag for flag in c_flags if not invalid_flag(flag)] + flags['c_flags'] = " ".join(flags['c_flags']) return flags def format_src(self, srcs): diff --git a/tools/export/uvision/uvision.tmpl b/tools/export/uvision/uvision.tmpl index 9093703ca6..a27c39f8cb 100644 --- a/tools/export/uvision/uvision.tmpl +++ b/tools/export/uvision/uvision.tmpl @@ -351,7 +351,7 @@ 0 - 2 + 1 0 0 0