diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2023-10-28 17:10:29 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-28 17:10:29 -0700 |
| commit | 78b04b54f870c9006f0aa2efeffca4cd9e5f63bf (patch) | |
| tree | cc25bb44b67d21ce2a16a98b729ad6fca831ae3c | |
| parent | e5cfc55477eceed1317a02189fdf77a4a98f2124 (diff) | |
| parent | f5fa36fbb72fe6d676adcb9bb7c1cba869c81c00 (diff) | |
| download | rust-78b04b54f870c9006f0aa2efeffca4cd9e5f63bf.tar.gz rust-78b04b54f870c9006f0aa2efeffca4cd9e5f63bf.zip | |
Rollup merge of #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.
| -rw-r--r-- | compiler/rustc_llvm/build.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_target/src/spec/i586_unknown_netbsd.rs | 18 | ||||
| -rw-r--r-- | compiler/rustc_target/src/spec/mod.rs | 1 | ||||
| -rw-r--r-- | src/doc/rustc/src/platform-support.md | 1 |
4 files changed, 26 insertions, 0 deletions
diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index f606fa483ca..fe13162cd4a 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -258,6 +258,12 @@ fn main() { { println!("cargo:rustc-link-lib=z"); } else if target.contains("netbsd") { + // On NetBSD/i386, gcc and g++ is built for i486 (to maximize backward compat) + // However, LLVM insists on using 64-bit atomics. + // This gives rise to a need to link rust itself with -latomic for these targets + if target.starts_with("i586") || target.starts_with("i686") { + println!("cargo:rustc-link-lib=atomic"); + } println!("cargo:rustc-link-lib=z"); println!("cargo:rustc-link-lib=execinfo"); } diff --git a/compiler/rustc_target/src/spec/i586_unknown_netbsd.rs b/compiler/rustc_target/src/spec/i586_unknown_netbsd.rs new file mode 100644 index 00000000000..0d8bdc3f89f --- /dev/null +++ b/compiler/rustc_target/src/spec/i586_unknown_netbsd.rs @@ -0,0 +1,18 @@ +use crate::spec::{StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = super::netbsd_base::opts(); + base.cpu = "pentium".into(); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::Call; + + Target { + llvm_target: "i586-unknown-netbsdelf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:32-n8:16:32-S128" + .into(), + arch: "x86".into(), + options: TargetOptions { mcount: "__mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 3541810d437..eaaaa4c08ca 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1564,6 +1564,7 @@ supported_targets! { ("aarch64_be-unknown-netbsd", aarch64_be_unknown_netbsd), ("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf), ("armv7-unknown-netbsd-eabihf", armv7_unknown_netbsd_eabihf), + ("i586-unknown-netbsd", i586_unknown_netbsd), ("i686-unknown-netbsd", i686_unknown_netbsd), ("powerpc-unknown-netbsd", powerpc_unknown_netbsd), ("riscv64gc-unknown-netbsd", riscv64gc_unknown_netbsd), diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 4e55d360430..ef373298efa 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -152,6 +152,7 @@ target | std | notes `i586-pc-windows-msvc` | * | 32-bit Windows w/o SSE [^x86_32-floats-x87] `i586-unknown-linux-gnu` | ✓ | 32-bit Linux w/o SSE (kernel 3.2, glibc 2.17) [^x86_32-floats-x87] `i586-unknown-linux-musl` | ✓ | 32-bit Linux w/o SSE, MUSL [^x86_32-floats-x87] +[`i586-unknown-netbsd`](platform-support/netbsd.md) | ✓ | 32-bit x86, restricted to Pentium [`i686-linux-android`](platform-support/android.md) | ✓ | 32-bit x86 Android [^x86_32-floats-return-ABI] `i686-unknown-freebsd` | ✓ | 32-bit FreeBSD [^x86_32-floats-return-ABI] `i686-unknown-linux-musl` | ✓ | 32-bit Linux with MUSL [^x86_32-floats-return-ABI] |
