@@ -74,7 +74,7 @@ impl Zig {
74
74
let is_windows_msvc = target
75
75
. map ( |x| x. contains ( "windows-msvc" ) )
76
76
. 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 ( ) ;
78
78
let is_macos = target. map ( |x| x. contains ( "macos" ) ) . unwrap_or_default ( ) ;
79
79
80
80
let rustc_ver = rustc_version:: version ( ) ?;
@@ -115,6 +115,10 @@ impl Zig {
115
115
return None ;
116
116
}
117
117
}
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
+ }
118
122
Some ( arg. to_string ( ) )
119
123
} ;
120
124
let has_undefined_dynamic_lookup = |args : & [ String ] | {
@@ -546,10 +550,27 @@ pub fn prepare_zig_linker(target: &str) -> Result<ZigWrapper> {
546
550
let zig_cxx = format ! ( "zigcxx-{}.{}" , file_target, file_ext) ;
547
551
let cc_args = "-g" ; // prevent stripping
548
552
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
+ }
553
574
OperatingSystem :: MacOSX { .. } | OperatingSystem :: Darwin => {
554
575
let zig_version = Zig :: zig_version ( ) ?;
555
576
// Zig 0.10.0 switched macOS ABI to none
0 commit comments