Skip to content

Commit 377b3d1

Browse files
authored
Merge pull request #321 from hsivonen/neon
Add awareness of armv7neon-*, thumbv7-* and thumbv7neon-* targets
2 parents c279df7 + b25a873 commit 377b3d1

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

src/lib.rs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,19 +1157,27 @@ impl Build {
11571157
}
11581158

11591159
// armv7 targets get to use armv7 instructions
1160-
if target.starts_with("armv7-") && target.contains("-linux-") {
1160+
if (target.starts_with("armv7") || target.starts_with("thumbv7")) && target.contains("-linux-") {
11611161
cmd.args.push("-march=armv7-a".into());
11621162
}
11631163

1164-
// On android we can guarantee some extra float instructions
1165-
// (specified in the android spec online)
1166-
if target.starts_with("armv7-linux-androideabi") {
1167-
cmd.args.push("-march=armv7-a".into());
1164+
// (x86 Android doesn't say "eabi")
1165+
if target.contains("-androideabi") && target.contains("v7") {
1166+
// -march=armv7-a handled above
11681167
cmd.args.push("-mthumb".into());
1169-
cmd.args.push("-mfpu=vfpv3-d16".into());
1168+
if !target.contains("neon") {
1169+
// On android we can guarantee some extra float instructions
1170+
// (specified in the android spec online)
1171+
// NEON guarantees even more; see below.
1172+
cmd.args.push("-mfpu=vfpv3-d16".into());
1173+
}
11701174
cmd.args.push("-mfloat-abi=softfp".into());
11711175
}
11721176

1177+
if target.contains("neon") {
1178+
cmd.args.push("-mfpu=neon-vfpv4".into());
1179+
}
1180+
11731181
if target.starts_with("armv4t-unknown-linux-") {
11741182
cmd.args.push("-march=armv4t".into());
11751183
cmd.args.push("-marm".into());
@@ -1586,7 +1594,15 @@ impl Build {
15861594
format!("{}.exe", gnu)
15871595
}
15881596
} else if target.contains("android") {
1589-
format!("{}-{}", target.replace("armv7", "arm"), gnu)
1597+
format!(
1598+
"{}-{}",
1599+
target
1600+
.replace("armv7", "arm")
1601+
.replace("armv7neon", "arm")
1602+
.replace("thumbv7", "arm")
1603+
.replace("thumbv7neon", "arm"),
1604+
gnu
1605+
)
15901606
} else if target.contains("cloudabi") {
15911607
format!("{}-{}", target, traditional)
15921608
} else if self.get_host()? != target {
@@ -1607,6 +1623,12 @@ impl Build {
16071623
"armv6-unknown-netbsd-eabihf" => Some("armv6--netbsdelf-eabihf"),
16081624
"armv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
16091625
"armv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
1626+
"armv7neon-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
1627+
"armv7neon-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
1628+
"thumbv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
1629+
"thumbv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
1630+
"thumbv7neon-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
1631+
"thumbv7neon-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
16101632
"armv7-unknown-netbsd-eabihf" => Some("armv7--netbsdelf-eabihf"),
16111633
"i586-unknown-linux-musl" => Some("musl"),
16121634
"i686-pc-windows-gnu" => Some("i686-w64-mingw32"),

0 commit comments

Comments
 (0)