Skip to content

Commit 0fee731

Browse files
authored
Rollup merge of #101025 - semarie:openbsd-archs, r=petrochenkov
Add tier-3 support for powerpc64 and riscv64 openbsd # powerpc64 - MCP for [powerpc64-unknown-openbsd tier-3 support](rust-lang/compiler-team#551) - only need to add spec definition in rustc_target # riscv64 - MCP for [riscv64-unknown-openbsd tier-3 support](rust-lang/compiler-team#552) - add spec definition in rustc_target - follow freebsd about avoiding linking with `libatomic`
2 parents 1484742 + 1de5b22 commit 0fee731

File tree

7 files changed

+47
-5
lines changed

7 files changed

+47
-5
lines changed

compiler/rustc_llvm/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ fn main() {
342342
};
343343

344344
// RISC-V GCC erroneously requires libatomic for sub-word
345-
// atomic operations. FreeBSD uses Clang as its system
345+
// atomic operations. Some BSD uses Clang as its system
346346
// compiler and provides no libatomic in its base system so
347347
// does not want this.
348-
if !target.contains("freebsd") && target.starts_with("riscv") {
348+
if target.starts_with("riscv") && !target.contains("freebsd") && !target.contains("openbsd") {
349349
println!("cargo:rustc-link-lib=atomic");
350350
}
351351

compiler/rustc_target/src/spec/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -944,9 +944,11 @@ supported_targets! {
944944

945945
("aarch64-unknown-openbsd", aarch64_unknown_openbsd),
946946
("i686-unknown-openbsd", i686_unknown_openbsd),
947+
("powerpc-unknown-openbsd", powerpc_unknown_openbsd),
948+
("powerpc64-unknown-openbsd", powerpc64_unknown_openbsd),
949+
("riscv64gc-unknown-openbsd", riscv64gc_unknown_openbsd),
947950
("sparc64-unknown-openbsd", sparc64_unknown_openbsd),
948951
("x86_64-unknown-openbsd", x86_64_unknown_openbsd),
949-
("powerpc-unknown-openbsd", powerpc_unknown_openbsd),
950952

951953
("aarch64-unknown-netbsd", aarch64_unknown_netbsd),
952954
("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::abi::Endian;
2+
use crate::spec::{LinkerFlavor, Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
let mut base = super::openbsd_base::opts();
6+
base.cpu = "ppc64".into();
7+
base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
8+
base.max_atomic_width = Some(64);
9+
10+
Target {
11+
llvm_target: "powerpc64-unknown-openbsd".into(),
12+
pointer_width: 64,
13+
data_layout: "E-m:e-i64:64-n32:64".into(),
14+
arch: "powerpc64".into(),
15+
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use crate::spec::{CodeModel, Target, TargetOptions};
2+
3+
pub fn target() -> Target {
4+
Target {
5+
llvm_target: "riscv64-unknown-openbsd".into(),
6+
pointer_width: 64,
7+
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
8+
arch: "riscv64".into(),
9+
options: TargetOptions {
10+
code_model: Some(CodeModel::Medium),
11+
cpu: "generic-rv64".into(),
12+
features: "+m,+a,+f,+d,+c".into(),
13+
llvm_abiname: "lp64d".into(),
14+
max_atomic_width: Some(64),
15+
..super::openbsd_base::opts()
16+
},
17+
}
18+
}

src/bootstrap/native.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,13 @@ impl Step for Llvm {
432432
cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
433433
}
434434

435-
if target.starts_with("riscv") && !target.contains("freebsd") {
435+
if target.starts_with("riscv") && !target.contains("freebsd") && !target.contains("openbsd")
436+
{
436437
// RISC-V GCC erroneously requires linking against
437438
// `libatomic` when using 1-byte and 2-byte C++
438439
// atomics but the LLVM build system check cannot
439440
// detect this. Therefore it is set manually here.
440-
// FreeBSD uses Clang as its system compiler and
441+
// Some BSD uses Clang as its system compiler and
441442
// provides no libatomic in its base system so does
442443
// not want this.
443444
ldflags.exe.push(" -latomic");

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

+2
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,15 @@ target | std | host | notes
277277
`powerpc64-unknown-linux-musl` | ? | |
278278
`powerpc64-wrs-vxworks` | ? | |
279279
`powerpc64le-unknown-linux-musl` | ? | |
280+
[`powerpc64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/powerpc64
280281
`riscv32gc-unknown-linux-gnu` | | | RISC-V Linux (kernel 5.4, glibc 2.33)
281282
`riscv32gc-unknown-linux-musl` | | | RISC-V Linux (kernel 5.4, musl + RISCV32 support patches)
282283
`riscv32im-unknown-none-elf` | * | | Bare RISC-V (RV32IM ISA)
283284
[`riscv32imac-unknown-xous-elf`](platform-support/riscv32imac-unknown-xous-elf.md) | ? | | RISC-V Xous (RV32IMAC ISA)
284285
`riscv32imc-esp-espidf` | ✓ | | RISC-V ESP-IDF
285286
`riscv64gc-unknown-freebsd` | | | RISC-V FreeBSD
286287
`riscv64gc-unknown-linux-musl` | | | RISC-V Linux (kernel 4.20, musl 1.2.0)
288+
[`riscv64gc-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/riscv64
287289
`s390x-unknown-linux-musl` | | | S390x Linux (kernel 3.2, MUSL)
288290
`sparc-unknown-linux-gnu` | ✓ | | 32-bit SPARC Linux
289291
`sparc64-unknown-netbsd` | ✓ | ✓ | NetBSD/sparc64

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

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The target names follow this format: `$ARCH-unknown-openbsd`, where `$ARCH` spec
1212
|--------------------------------|-------------|------------------|
1313
| `aarch64-unknown-openbsd` | libc++ | [64-bit ARM systems](https://www.openbsd.org/arm64.html) |
1414
| `i686-unknown-openbsd` | libc++ | [Standard PC and clones based on the Intel i386 architecture and compatible processors](https://www.openbsd.org/i386.html) |
15+
| `powerpc64-unknown-openbsd` | libc++ | [IBM POWER-based PowerNV systems](https://www.openbsd.org/powerpc64.html) |
16+
| `riscv64gc-unknown-openbsd` | libc++ | [64-bit RISC-V systems](https://www.openbsd.org/riscv64.html) |
1517
| `sparc64-unknown-openbsd` | estdc++ | [Sun UltraSPARC and Fujitsu SPARC64 systems](https://www.openbsd.org/sparc64.html) |
1618
| `x86_64-unknown-openbsd` | libc++ | [AMD64-based systems](https://www.openbsd.org/amd64.html) |
1719

0 commit comments

Comments
 (0)