Skip to content

Commit

Permalink
Add riscv64gc-unknown-freebsd
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Kortkamp committed Nov 27, 2021
1 parent 3e018ce commit 47474f1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ fn main() {
};

// RISC-V requires libatomic for sub-word atomic operations
if target.starts_with("riscv") {
if !target.contains("freebsd") && target.starts_with("riscv") {
println!("cargo:rustc-link-lib=atomic");
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ supported_targets! {
("powerpc-unknown-freebsd", powerpc_unknown_freebsd),
("powerpc64-unknown-freebsd", powerpc64_unknown_freebsd),
("powerpc64le-unknown-freebsd", powerpc64le_unknown_freebsd),
("riscv64gc-unknown-freebsd", riscv64gc_unknown_freebsd),
("x86_64-unknown-freebsd", x86_64_unknown_freebsd),

("x86_64-unknown-dragonfly", x86_64_unknown_dragonfly),
Expand Down
18 changes: 18 additions & 0 deletions compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use crate::spec::{CodeModel, Target, TargetOptions};

pub fn target() -> Target {
Target {
llvm_target: "riscv64-unknown-freebsd".to_string(),
pointer_width: 64,
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".to_string(),
arch: "riscv64".to_string(),
options: TargetOptions {
code_model: Some(CodeModel::Medium),
cpu: "generic-rv64".to_string(),
features: "+m,+a,+f,+d,+c".to_string(),
llvm_abiname: "lp64d".to_string(),
max_atomic_width: Some(64),
..super::freebsd_base::opts()
},
}
}
6 changes: 4 additions & 2 deletions library/std/src/os/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ type_alias! { "char.md", c_char = u8, NonZero_c_char = NonZeroU8;
target_arch = "aarch64",
target_arch = "arm",
target_arch = "powerpc",
target_arch = "powerpc64"
target_arch = "powerpc64",
target_arch = "riscv64"
)
),
all(
Expand Down Expand Up @@ -112,7 +113,8 @@ type_alias! { "char.md", c_char = i8, NonZero_c_char = NonZeroI8;
target_arch = "aarch64",
target_arch = "arm",
target_arch = "powerpc",
target_arch = "powerpc64"
target_arch = "powerpc64",
target_arch = "riscv64"
)
),
all(
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def default_build_triple(verbose):
err = "unknown OS type: {}".format(ostype)
sys.exit(err)

if cputype == 'powerpc' and ostype == 'unknown-freebsd':
if cputype in ['powerpc', 'riscv'] and ostype == 'unknown-freebsd':
cputype = subprocess.check_output(
['uname', '-p']).strip().decode(default_encoding)
cputype_mapper = {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl Step for Llvm {
}
}

if target.starts_with("riscv") {
if !target.contains("freebsd") && target.starts_with("riscv") {
// In RISC-V, using C++ atomics require linking to `libatomic` but the LLVM build
// system check cannot detect this. Therefore it is set manually here.
if !builder.config.llvm_tools_enabled {
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ target | std | host | notes
`riscv32gc-unknown-linux-gnu` | | | RISC-V Linux (kernel 5.4, glibc 2.33)
`riscv32gc-unknown-linux-musl` | | | RISC-V Linux (kernel 5.4, musl + RISCV32 support patches)
`riscv32imc-esp-espidf` | ✓ | | RISC-V ESP-IDF
`riscv64gc-unknown-freebsd` | | | RISC-V FreeBSD
`riscv64gc-unknown-linux-musl` | | | RISC-V Linux (kernel 4.20, musl 1.2.0)
`s390x-unknown-linux-musl` | | | S390x Linux (kernel 2.6.32, MUSL)
`sparc-unknown-linux-gnu` | ✓ | | 32-bit SPARC Linux
Expand Down

0 comments on commit 47474f1

Please sign in to comment.