Skip to content

Commit f692124

Browse files
committed
Handle disabled features
1 parent 5bb0d63 commit f692124

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/base.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,33 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Lock
104104
}
105105
};
106106

107+
let disable_cpu_feature = |feature: &str| {
108+
if disabled_features.contains(feature) {
109+
context.add_command_line_option(&format!("-mno-{}", feature));
110+
}
111+
};
112+
107113
// TODO(antoyo): only set on x86 platforms.
108114
context.add_command_line_option("-masm=intel");
109115

110116
// TODO: instead of setting the features manually, set the correct -march flag.
111-
/*let features = ["64", "avxvnni", "bmi", "sse2", "avx2", "sha", "fma", "fma4", "gfni", "f16c", "aes", "bmi2", "pclmul", "rtm",
117+
let features = ["64", "avxvnni", "bmi", "sse2", "avx2", "sha", "fma", "fma4", "gfni", "f16c", "aes", "bmi2", "pclmul", "rtm",
112118
"vaes", "vpclmulqdq", "xsavec",
113119
];
114120

121+
115122
for feature in &features {
116-
add_cpu_feature_flag(feature);
117-
}*/
123+
disable_cpu_feature(feature);
118124

119-
// NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for
120-
// SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead.
121-
// FIXME(antoyo): use the proper builtins for llvm.x86.sse2.cmp.pd and similar.
122-
context.add_command_line_option("-mavx");
125+
//add_cpu_feature_flag(feature);
126+
}
127+
128+
if !disabled_features.contains("avx") {
129+
// NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for
130+
// SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead.
131+
// FIXME(antoyo): use the proper builtins for llvm.x86.sse2.cmp.pd and similar.
132+
context.add_command_line_option("-mavx");
133+
}
123134

124135
for arg in &tcx.sess.opts.cg.llvm_args {
125136
context.add_command_line_option(arg);

0 commit comments

Comments
 (0)