@@ -84,14 +84,17 @@ foreach target : targets
84
84
crt0_minimal_name = ' crt0_minimal' + target
85
85
crt0_semihost_name = ' crt0_semihost' + target
86
86
87
+ _c_args = value[1 ] + arg_fnobuiltin + [' -ffreestanding' ]
88
+ _link_args = value[1 ] + [' -r' , ' -ffreestanding' ]
89
+
87
90
# The normal variant does not call 'exit' after return from main (c lingo: freestanding execution environment)
88
91
_crt = executable (crt_name,
89
92
src_picocrt,
90
93
include_directories : inc,
91
94
install : true ,
92
95
install_dir : instdir,
93
- c_args : value[ 1 ] + c_args + arg_fnobuiltin + [ ' -ffreestanding ' ] ,
94
- link_args : value[ 1 ] + [ ' -r ' , ' -ffreestanding ' ] )
96
+ c_args : _c_args ,
97
+ link_args : _link_args )
95
98
96
99
set_variable (crt0_name,
97
100
_crt.extract_objects(src_picocrt)
@@ -100,11 +103,12 @@ foreach target : targets
100
103
if enable_picocrt_lib
101
104
static_library (libcrt_name,
102
105
[],
106
+ include_directories : inc,
103
107
install : true ,
104
108
install_dir : instdir,
105
- pic : false ,
106
- c_args : value[ 1 ] + c_args ,
107
- objects : [_crt.extract_objects(src_picocrt)] )
109
+ c_args : _c_args ,
110
+ objects : get_variable (crt0_name) ,
111
+ pic : false )
108
112
endif
109
113
110
114
# The 'hosted' variant calls 'exit' after return from main (c lingo: hosted execution environment)
@@ -113,8 +117,8 @@ foreach target : targets
113
117
include_directories : inc,
114
118
install : true ,
115
119
install_dir : instdir,
116
- c_args : value[ 1 ] + c_args + arg_fnobuiltin + [ ' -ffreestanding ' , ' -DCRT0_EXIT' ],
117
- link_args : value[ 1 ] + [ ' -r ' , ' -ffreestanding ' ] )
120
+ c_args : _c_args + [ ' -DCRT0_EXIT' ],
121
+ link_args : _link_args )
118
122
119
123
set_variable (crt0_hosted_name,
120
124
_crt.extract_objects(src_picocrt)
@@ -123,11 +127,12 @@ foreach target : targets
123
127
if enable_picocrt_lib
124
128
static_library (libcrt_hosted_name,
125
129
[],
130
+ include_directories : inc,
126
131
install : true ,
127
132
install_dir : instdir,
128
133
pic : false ,
129
- c_args : value[ 1 ] + c_args ,
130
- objects : [_crt.extract_objects(src_picocrt) ])
134
+ objects : get_variable (crt0_hosted_name) ,
135
+ c_args : value[ 1 ] + [ ' -DCRT0_EXIT ' ])
131
136
endif
132
137
133
138
# The 'minimal' variant doesn't call exit, nor does it invoke any constructors
@@ -136,8 +141,8 @@ foreach target : targets
136
141
include_directories : inc,
137
142
install : true ,
138
143
install_dir : instdir,
139
- c_args : value[ 1 ] + c_args + arg_fnobuiltin + [ ' -ffreestanding ' , ' -DCONSTRUCTORS=0' ],
140
- link_args : value[ 1 ] + [ ' -r ' , ' -ffreestanding ' ] )
144
+ c_args : _c_args + [ ' -DCONSTRUCTORS=0' ],
145
+ link_args : _link_args )
141
146
142
147
set_variable (crt0_minimal_name,
143
148
_crt.extract_objects(src_picocrt)
@@ -146,11 +151,12 @@ foreach target : targets
146
151
if enable_picocrt_lib
147
152
static_library (libcrt_minimal_name,
148
153
[],
154
+ include_directories : inc,
149
155
install : true ,
150
156
install_dir : instdir,
151
157
pic : false ,
152
- c_args : value[ 1 ] + c_args ,
153
- objects : [_crt.extract_objects(src_picocrt) ])
158
+ objects : get_variable (crt0_minimal_name) ,
159
+ c_args : _c_args + [ ' -DCONSTRUCTORS=0 ' ])
154
160
endif
155
161
156
162
if has_arm_semihost
@@ -161,8 +167,8 @@ foreach target : targets
161
167
include_directories : inc,
162
168
install : true ,
163
169
install_dir : instdir,
164
- c_args : value[ 1 ] + c_args + arg_fnobuiltin + [ ' -ffreestanding ' , ' -DCRT0_EXIT' , ' -DCRT0_SEMIHOST' ],
165
- link_args : value[ 1 ] + [ ' -r ' , ' -ffreestanding ' ] )
170
+ c_args : _c_args + [ ' -DCRT0_EXIT' , ' -DCRT0_SEMIHOST' ],
171
+ link_args : _link_args )
166
172
167
173
set_variable (crt0_semihost_name,
168
174
_crt.extract_objects(src_picocrt)
@@ -171,11 +177,12 @@ foreach target : targets
171
177
if enable_picocrt_lib
172
178
static_library (libcrt_semihost_name,
173
179
[],
180
+ include_directories : inc,
174
181
install : true ,
175
182
install_dir : instdir,
176
183
pic : false ,
177
- c_args : value[ 1 ] + c_args ,
178
- objects : [_crt.extract_objects(src_picocrt) ])
184
+ objects : get_variable (crt0_semihost_name) ,
185
+ c_args : value[ 1 ] + [ ' -DCRT0_EXIT ' , ' -DCRT0_SEMIHOST ' ])
179
186
endif
180
187
endif
181
188
endforeach
0 commit comments