@@ -29,6 +29,20 @@ class GCC(mbedToolchain):
29
29
STD_LIB_NAME = "lib%s.a"
30
30
DIAGNOSTIC_PATTERN = re .compile ('((?P<file>[^:]+):(?P<line>\d+):)(\d+:)? (?P<severity>warning|error): (?P<message>.+)' )
31
31
32
+ DEFAULT_FLAGS = {
33
+ 'common' : ["-c" , "-Wall" , "-Wextra" ,
34
+ "-Wno-unused-parameter" , "-Wno-missing-field-initializers" ,
35
+ "-fmessage-length=0" , "-fno-exceptions" , "-fno-builtin" ,
36
+ "-ffunction-sections" , "-fdata-sections" ,
37
+ "-MMD" , "-fno-delete-null-pointer-checks" , "-fomit-frame-pointer"
38
+ ],
39
+ 'asm' : ["-x" , "assembler-with-cpp" ],
40
+ 'c' : ["-std=gnu99" ],
41
+ 'cxx' : ["-std=gnu++98" , "-fno-rtti" ],
42
+ 'ld' : ["-Wl,--gc-sections" , "-Wl,--wrap,main" ,
43
+ "-Wl,--wrap,_malloc_r" , "-Wl,--wrap,_free_r" , "-Wl,--wrap,_realloc_r" ],
44
+ }
45
+
32
46
def __init__ (self , target , options = None , notify = None , macros = None , silent = False , tool_path = "" , extra_verbose = False ):
33
47
mbedToolchain .__init__ (self , target , options , notify , macros , silent , extra_verbose = extra_verbose )
34
48
@@ -63,33 +77,31 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
63
77
64
78
# Note: We are using "-O2" instead of "-Os" to avoid this known GCC bug:
65
79
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46762
66
- common_flags = ["-c" , "-Wall" , "-Wextra" ,
67
- "-Wno-unused-parameter" , "-Wno-missing-field-initializers" ,
68
- "-fmessage-length=0" , "-fno-exceptions" , "-fno-builtin" ,
69
- "-ffunction-sections" , "-fdata-sections" ,
70
- "-fno-delete-null-pointer-checks" , "-fomit-frame-pointer"
71
- ] + self .cpu
80
+ self .flags ["common" ] += self .cpu
72
81
73
82
if "save-asm" in self .options :
74
- common_flags .append ("-save-temps" )
83
+ self . flags [ "common" ] .append ("-save-temps" )
75
84
76
85
if "debug-info" in self .options :
77
- common_flags .append ("-g" )
78
- common_flags .append ("-O0" )
86
+ self . flags [ "common" ] .append ("-g" )
87
+ self . flags [ "common" ] .append ("-O0" )
79
88
else :
80
- common_flags .append ("-O2" )
89
+ self . flags [ "common" ] .append ("-O2" )
81
90
82
91
main_cc = join (tool_path , "arm-none-eabi-gcc" )
83
92
main_cppc = join (tool_path , "arm-none-eabi-g++" )
84
- self .asm = [main_cc , "-x" , "assembler-with-cpp" ] + common_flags
93
+ self .asm = [main_cc ] + self . flags [ 'asm' ] + self . flags [ "common" ]
85
94
if not "analyze" in self .options :
86
- self .cc = [main_cc , "-std=gnu99" ] + common_flags
87
- self .cppc = [main_cppc , "-std=gnu++98" , "-fno-rtti" ] + common_flags
95
+ self .cc = [main_cc ]
96
+ self .cppc = [main_cppc ]
88
97
else :
89
- self .cc = [join (GOANNA_PATH , "goannacc" ), "--with-cc=" + main_cc .replace ('\\ ' , '/' ), "-std=gnu99" , "--dialect=gnu" , '--output-format="%s"' % self .GOANNA_FORMAT ] + common_flags
90
- self .cppc = [join (GOANNA_PATH , "goannac++" ), "--with-cxx=" + main_cppc .replace ('\\ ' , '/' ), "-std=gnu++98" , "-fno-rtti" , "--dialect=gnu" , '--output-format="%s"' % self .GOANNA_FORMAT ] + common_flags
98
+ self .cc = [join (GOANNA_PATH , "goannacc" ), "--with-cc=" + main_cc .replace ('\\ ' , '/' ), "--dialect=gnu" , '--output-format="%s"' % self .GOANNA_FORMAT ]
99
+ self .cppc = [join (GOANNA_PATH , "goannac++" ), "--with-cxx=" + main_cppc .replace ('\\ ' , '/' ), "--dialect=gnu" , '--output-format="%s"' % self .GOANNA_FORMAT ]
100
+ self .cc += self .flags ['c' ] + self .flags ['common' ]
101
+ self .cppc += self .flags ['cxx' ] + self .flags ['common' ]
91
102
92
- self .ld = [join (tool_path , "arm-none-eabi-gcc" ), "-Wl,--gc-sections" , "-Wl,--wrap,main" , "-Wl,--wrap,_malloc_r" , "-Wl,--wrap,_free_r" , "-Wl,--wrap,_realloc_r" ] + self .cpu
103
+ self .flags ['ld' ] += self .cpu
104
+ self .ld = [join (tool_path , "arm-none-eabi-gcc" )] + self .flags ['ld' ]
93
105
self .sys_libs = ["stdc++" , "supc++" , "m" , "c" , "gcc" ]
94
106
95
107
self .ar = join (tool_path , "arm-none-eabi-ar" )
0 commit comments