@@ -74,7 +74,7 @@ impl Zig {
7474 let is_windows_msvc = target
7575 . map ( |x| x. contains ( "windows-msvc" ) )
7676 . unwrap_or_default ( ) ;
77- let is_arm = target. map ( |x| x. contains ( "arm" ) ) . unwrap_or_default ( ) ;
77+ let is_arm = target. map ( |x| x. starts_with ( "arm" ) ) . unwrap_or_default ( ) ;
7878 let is_macos = target. map ( |x| x. contains ( "macos" ) ) . unwrap_or_default ( ) ;
7979
8080 let rustc_ver = rustc_version:: version ( ) ?;
@@ -115,6 +115,10 @@ impl Zig {
115115 return None ;
116116 }
117117 }
118+ // Ignore `-march` option for arm* targets, we use `generic` + cpu features instead
119+ if is_arm && arg. starts_with ( "-march=" ) {
120+ return None ;
121+ }
118122 Some ( arg. to_string ( ) )
119123 } ;
120124 let has_undefined_dynamic_lookup = |args : & [ String ] | {
@@ -546,10 +550,27 @@ pub fn prepare_zig_linker(target: &str) -> Result<ZigWrapper> {
546550 let zig_cxx = format ! ( "zigcxx-{}.{}" , file_target, file_ext) ;
547551 let cc_args = "-g" ; // prevent stripping
548552 let mut cc_args = match triple. operating_system {
549- OperatingSystem :: Linux => format ! (
550- "-target {}-linux-{}{} {}" ,
551- arch, target_env, abi_suffix, cc_args,
552- ) ,
553+ OperatingSystem :: Linux => {
554+ let ( zig_arch, zig_cpu) = match arch. as_str ( ) {
555+ // zig uses _ instead of - in cpu features
556+ "arm" => match target_env {
557+ Environment :: Gnueabi | Environment :: Musleabi => {
558+ ( "arm" , "-mcpu=generic+v6+strict_align" )
559+ }
560+ Environment :: Gnueabihf | Environment :: Musleabihf => {
561+ ( "arm" , "-mcpu=generic+v6+strict_align+vfp2-d32" )
562+ }
563+ _ => ( "arm" , "" ) ,
564+ } ,
565+ "armv5te" => ( "arm" , "-mcpu=generic+soft_float+strict_align" ) ,
566+ "armv7" => ( "arm" , "-mcpu=generic+v7a+vfp3-d32+thumb2-neon" ) ,
567+ _ => ( arch. as_str ( ) , "" ) ,
568+ } ;
569+ format ! (
570+ "-target {}-linux-{}{} {} {}" ,
571+ zig_arch, target_env, abi_suffix, zig_cpu, cc_args,
572+ )
573+ }
553574 OperatingSystem :: MacOSX { .. } | OperatingSystem :: Darwin => {
554575 let zig_version = Zig :: zig_version ( ) ?;
555576 // Zig 0.10.0 switched macOS ABI to none
0 commit comments