@@ -16,7 +16,6 @@ pub(crate) struct RustcCodegenFlags<'a> {
16
16
relocation_model : Option < & ' a str > ,
17
17
embed_bitcode : Option < bool > ,
18
18
force_frame_pointers : Option < bool > ,
19
- link_dead_code : Option < bool > ,
20
19
no_redzone : Option < bool > ,
21
20
soft_float : Option < bool > ,
22
21
}
@@ -138,8 +137,6 @@ impl<'this> RustcCodegenFlags<'this> {
138
137
"-Cforce-frame-pointers" => {
139
138
self . force_frame_pointers = value. map_or ( Some ( true ) , arg_to_bool)
140
139
}
141
- // https://doc.rust-lang.org/rustc/codegen-options/index.html#link-dead-code
142
- "-Clink-dead-code" => self . link_dead_code = value. map_or ( Some ( true ) , arg_to_bool) ,
143
140
// https://doc.rust-lang.org/rustc/codegen-options/index.html#no-redzone
144
141
"-Cno-redzone" => self . no_redzone = value. map_or ( Some ( true ) , arg_to_bool) ,
145
142
// https://doc.rust-lang.org/rustc/codegen-options/index.html#soft-float
@@ -180,42 +177,40 @@ impl<'this> RustcCodegenFlags<'this> {
180
177
// Flags shared between clang and gnu
181
178
if clang_or_gnu {
182
179
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mbranch-protection
180
+ // https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#index-mbranch-protection (Aarch64)
181
+ // https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-mbranch-protection-1 (ARM)
182
+ // https://developer.arm.com/documentation/101754/0619/armclang-Reference/armclang-Command-line-Options/-mbranch-protection
183
183
if let Some ( value) = self . branch_protection {
184
184
push_if_supported (
185
185
format ! ( "-mbranch-protection={}" , value. replace( "," , "+" ) ) . into ( ) ,
186
186
) ;
187
187
}
188
188
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mcmodel
189
+ // https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html (several archs, search for `-mcmodel=`).
190
+ // FIXME(madsmtm): Parse the model, to make sure we pass the correct value (depending on arch).
189
191
if let Some ( value) = self . code_model {
190
192
push_if_supported ( format ! ( "-mcmodel={value}" ) . into ( ) ) ;
191
193
}
192
194
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fno-vectorize
195
+ // https://gcc.gnu.org/onlinedocs/gnat_ugn/Vectorization-of-loops.html
193
196
if self . no_vectorize_loops {
194
197
push_if_supported ( "-fno-vectorize" . into ( ) ) ;
195
198
}
196
199
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fno-slp-vectorize
200
+ // https://gcc.gnu.org/onlinedocs/gnat_ugn/Vectorization-of-loops.html
197
201
if self . no_vectorize_slp {
198
202
push_if_supported ( "-fno-slp-vectorize" . into ( ) ) ;
199
203
}
200
- // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mguard
201
- if let Some ( value) = self . control_flow_guard {
202
- let cc_val = match value {
203
- "y" | "yes" | "on" | "true" | "checks" => Some ( "cf" ) ,
204
- "nochecks" => Some ( "cf-nochecks" ) ,
205
- "n" | "no" | "off" | "false" => Some ( "none" ) ,
206
- _ => None ,
207
- } ;
208
- if let Some ( cc_val) = cc_val {
209
- push_if_supported ( format ! ( "-mguard={cc_val}" ) . into ( ) ) ;
210
- }
211
- }
212
- // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fPIC
213
- // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fPIE
214
- // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mdynamic-no-pic
215
204
if let Some ( value) = self . relocation_model {
216
205
let cc_flag = match value {
206
+ // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fPIC
207
+ // https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fPIC
217
208
"pic" => Some ( "-fPIC" ) ,
209
+ // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fPIE
210
+ // https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fPIE
218
211
"pie" => Some ( "-fPIE" ) ,
212
+ // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mdynamic-no-pic
213
+ // https://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html#index-mdynamic-no-pic
219
214
"dynamic-no-pic" => Some ( "-mdynamic-no-pic" ) ,
220
215
_ => None ,
221
216
} ;
@@ -225,6 +220,7 @@ impl<'this> RustcCodegenFlags<'this> {
225
220
}
226
221
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fno-omit-frame-pointer
227
222
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer
223
+ // https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fomit-frame-pointer
228
224
if let Some ( value) = self . force_frame_pointers {
229
225
let cc_flag = if value {
230
226
"-fno-omit-frame-pointer"
@@ -233,23 +229,24 @@ impl<'this> RustcCodegenFlags<'this> {
233
229
} ;
234
230
push_if_supported ( cc_flag. into ( ) ) ;
235
231
}
236
- // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-dead_strip
237
- if let Some ( false ) = self . link_dead_code {
238
- push_if_supported ( "-dead_strip" . into ( ) ) ;
239
- }
240
232
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mno-red-zone
233
+ // https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-mno-red-zone
241
234
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mred-zone
235
+ // https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-mred-zone
242
236
if let Some ( value) = self . no_redzone {
243
237
let cc_flag = if value { "-mno-red-zone" } else { "-mred-zone" } ;
244
238
push_if_supported ( cc_flag. into ( ) ) ;
245
239
}
246
240
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-msoft-float
247
- // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mno-soft-float
241
+ // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mhard-float
242
+ // https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html (several archs, search for `-msoft-float`).
243
+ // https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html (several archs, search for `-mhard-float`).
248
244
if let Some ( value) = self . soft_float {
249
245
let cc_flag = if value {
250
246
"-msoft-float"
251
247
} else {
252
- "-mno-soft-float"
248
+ // Do not use -mno-soft-float, that's basically just an alias for -mno-implicit-float.
249
+ "-mhard-float"
253
250
} ;
254
251
push_if_supported ( cc_flag. into ( ) ) ;
255
252
}
@@ -287,6 +284,18 @@ impl<'this> RustcCodegenFlags<'this> {
287
284
push_if_supported ( format ! ( "-flto={cc_val}" ) . into ( ) ) ;
288
285
}
289
286
}
287
+ // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mguard
288
+ if let Some ( value) = self . control_flow_guard {
289
+ let cc_val = match value {
290
+ "y" | "yes" | "on" | "true" | "checks" => Some ( "cf" ) ,
291
+ "nochecks" => Some ( "cf-nochecks" ) ,
292
+ "n" | "no" | "off" | "false" => Some ( "none" ) ,
293
+ _ => None ,
294
+ } ;
295
+ if let Some ( cc_val) = cc_val {
296
+ push_if_supported ( format ! ( "-mguard={cc_val}" ) . into ( ) ) ;
297
+ }
298
+ }
290
299
}
291
300
ToolFamily :: Gnu { .. } => { }
292
301
ToolFamily :: Msvc { .. } => {
@@ -478,7 +487,6 @@ mod tests {
478
487
control_flow_guard : Some ( "yes" ) ,
479
488
embed_bitcode : Some ( false ) ,
480
489
force_frame_pointers : Some ( true ) ,
481
- link_dead_code : Some ( true ) ,
482
490
lto : Some ( "false" ) ,
483
491
no_redzone : Some ( true ) ,
484
492
no_vectorize_loops : true ,
0 commit comments