Skip to content

Commit 0709167

Browse files
Rollup merge of rust-lang#117170 - he32:netbsd-i586, r=bjorn3
Add support for i586-unknown-netbsd as target. This restricts instructions to those offered by Pentium, to support e.g. AMD Geode. There is already an entry for this target in the NetBSD platform support page at src/doc/rustc/src/platform-support/netbsd.md ...so this should forestall its removal. Additional fixes are needed for some vendored modules, this is the changes in the rust compiler core itself.
2 parents 16b2b9a + f5fa36f commit 0709167

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

compiler/rustc_llvm/build.rs

+6
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ fn main() {
258258
{
259259
println!("cargo:rustc-link-lib=z");
260260
} else if target.contains("netbsd") {
261+
// On NetBSD/i386, gcc and g++ is built for i486 (to maximize backward compat)
262+
// However, LLVM insists on using 64-bit atomics.
263+
// This gives rise to a need to link rust itself with -latomic for these targets
264+
if target.starts_with("i586") || target.starts_with("i686") {
265+
println!("cargo:rustc-link-lib=atomic");
266+
}
261267
println!("cargo:rustc-link-lib=z");
262268
println!("cargo:rustc-link-lib=execinfo");
263269
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use crate::spec::{StackProbeType, Target, TargetOptions};
2+
3+
pub fn target() -> Target {
4+
let mut base = super::netbsd_base::opts();
5+
base.cpu = "pentium".into();
6+
base.max_atomic_width = Some(64);
7+
base.stack_probes = StackProbeType::Call;
8+
9+
Target {
10+
llvm_target: "i586-unknown-netbsdelf".into(),
11+
pointer_width: 32,
12+
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
13+
f64:32:64-f80:32-n8:16:32-S128"
14+
.into(),
15+
arch: "x86".into(),
16+
options: TargetOptions { mcount: "__mcount".into(), ..base },
17+
}
18+
}

compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,7 @@ supported_targets! {
15641564
("aarch64_be-unknown-netbsd", aarch64_be_unknown_netbsd),
15651565
("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf),
15661566
("armv7-unknown-netbsd-eabihf", armv7_unknown_netbsd_eabihf),
1567+
("i586-unknown-netbsd", i586_unknown_netbsd),
15671568
("i686-unknown-netbsd", i686_unknown_netbsd),
15681569
("powerpc-unknown-netbsd", powerpc_unknown_netbsd),
15691570
("riscv64gc-unknown-netbsd", riscv64gc_unknown_netbsd),

src/doc/rustc/src/platform-support.md

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ target | std | notes
152152
`i586-pc-windows-msvc` | * | 32-bit Windows w/o SSE [^x86_32-floats-x87]
153153
`i586-unknown-linux-gnu` | ✓ | 32-bit Linux w/o SSE (kernel 3.2, glibc 2.17) [^x86_32-floats-x87]
154154
`i586-unknown-linux-musl` | ✓ | 32-bit Linux w/o SSE, MUSL [^x86_32-floats-x87]
155+
[`i586-unknown-netbsd`](platform-support/netbsd.md) | ✓ | 32-bit x86, restricted to Pentium
155156
[`i686-linux-android`](platform-support/android.md) | ✓ | 32-bit x86 Android [^x86_32-floats-return-ABI]
156157
`i686-unknown-freebsd` | ✓ | 32-bit FreeBSD [^x86_32-floats-return-ABI]
157158
`i686-unknown-linux-musl` | ✓ | 32-bit Linux with MUSL [^x86_32-floats-return-ABI]

0 commit comments

Comments
 (0)