@@ -19,7 +19,7 @@ use rustc_codegen_ssa::traits::DebugInfoMethods;
1919use rustc_session:: config:: DebugInfo ;
2020use rustc_span:: Symbol ;
2121
22- use crate :: LockedTargetInfo ;
22+ use crate :: { LockedTargetInfo , gcc_util } ;
2323use crate :: GccContext ;
2424use crate :: builder:: Builder ;
2525use crate :: context:: CodegenCx ;
@@ -101,8 +101,6 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Lock
101101 // TODO(antoyo): only set on x86 platforms.
102102 context. add_command_line_option ( "-masm=intel" ) ;
103103
104- // TODO(antoyo): set the correct -march flag.
105-
106104 if !disabled_features. contains ( "avx" ) {
107105 // NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for
108106 // SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead.
@@ -127,6 +125,11 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Lock
127125 context. add_command_line_option ( "-fno-pie" ) ;
128126 }
129127
128+ let target_cpu = gcc_util:: target_cpu ( tcx. sess ) ;
129+ if target_cpu != "generic" {
130+ context. add_command_line_option ( & format ! ( "-march={}" , target_cpu) ) ;
131+ }
132+
130133 if tcx. sess . opts . unstable_opts . function_sections . unwrap_or ( tcx. sess . target . function_sections ) {
131134 context. add_command_line_option ( "-ffunction-sections" ) ;
132135 context. add_command_line_option ( "-fdata-sections" ) ;
0 commit comments