Skip to content

Commit 4e85203

Browse files
authored
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 2a45905 + 391b472 commit 4e85203

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

compiler/rustc_llvm/build.rs

+8
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,14 @@ 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")
265+
|| target.starts_with("i686")
266+
{
267+
println!("cargo:rustc-link-lib=atomic");
268+
}
261269
println!("cargo:rustc-link-lib=z");
262270
println!("cargo:rustc-link-lib=execinfo");
263271
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use crate::spec::{Cc, Lld, LinkerFlavor, 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.pre_link_args
8+
.entry(LinkerFlavor::Gnu(Cc::Yes, Lld::No))
9+
.or_default()
10+
.push("-m32".into());
11+
base.stack_probes = StackProbeType::Call;
12+
13+
Target {
14+
llvm_target: "i586-unknown-netbsdelf".into(),
15+
pointer_width: 32,
16+
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
17+
f64:32:64-f80:32-n8:16:32-S128"
18+
.into(),
19+
arch: "x86".into(),
20+
options: TargetOptions { mcount: "__mcount".into(), ..base },
21+
}
22+
}

compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,7 @@ supported_targets! {
14261426
("aarch64_be-unknown-netbsd", aarch64_be_unknown_netbsd),
14271427
("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf),
14281428
("armv7-unknown-netbsd-eabihf", armv7_unknown_netbsd_eabihf),
1429+
("i586-unknown-netbsd", i586_unknown_netbsd),
14291430
("i686-unknown-netbsd", i686_unknown_netbsd),
14301431
("powerpc-unknown-netbsd", powerpc_unknown_netbsd),
14311432
("riscv64gc-unknown-netbsd", riscv64gc_unknown_netbsd),

0 commit comments

Comments
 (0)