Skip to content

Commit f6337e4

Browse files
committed
Don't always enabled CPU features
1 parent 067bfc0 commit f6337e4

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/base.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,29 +103,22 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Arc<
103103
.collect();
104104

105105
let add_cpu_feature_flag = |feature: &str| {
106-
// FIXME(antoyo): some tests cause a segfault in GCC when not enabling all these
107-
// features.
108-
if (true || target_info.cpu_supports(feature)) && !disabled_features.contains(feature) {
106+
if target_info.cpu_supports(feature) && !disabled_features.contains(feature) {
109107
context.add_command_line_option(&format!("-m{}", feature));
110108
}
111109
};
112110

113111
// TODO(antoyo): only set on x86 platforms.
114112
context.add_command_line_option("-masm=intel");
115113

116-
let features = ["sse2", "avx", "avx2", "sha", "fma", "gfni", "f16c", "aes", "bmi2", "rtm",
114+
let features = ["64", "bmi", "sse2", "avx", "avx2", "sha", "fma", "fma4", "gfni", "f16c", "aes", "bmi2", "pclmul", "rtm",
117115
"vaes", "vpclmulqdq", "xsavec",
118116
];
119117

120118
for feature in &features {
121119
add_cpu_feature_flag(feature);
122120
}
123121

124-
// TODO(antoyo): only add the following cli arguments if the feature is supported.
125-
context.add_command_line_option("-mpclmul");
126-
context.add_command_line_option("-mfma4");
127-
context.add_command_line_option("-m64");
128-
context.add_command_line_option("-mbmi");
129122
//context.add_command_line_option("-mavxvnni"); // The CI doesn't support this option.
130123

131124
for arg in &tcx.sess.opts.cg.llvm_args {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
313313

314314
// Get the second TargetInfo with the correct CPU features by setting the arch.
315315
let context = Context::default();
316-
context.add_driver_option(&format!("-march={}", arch.to_str().unwrap()));
316+
context.add_command_line_option(&format!("-march={}", arch.to_str().unwrap()));
317317
Arc::new(context.get_target_info())
318318
};
319319
#[cfg(not(feature="master"))]

0 commit comments

Comments
 (0)