Skip to content

Commit

Permalink
add nto80 x86-64 and aarch64 target
Browse files Browse the repository at this point in the history
  • Loading branch information
AkhilTThomas authored and flba-eb committed Dec 10, 2024
1 parent 3d8d21a commit 3255971
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 14 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,8 +1927,10 @@ supported_targets! {
("aarch64-unknown-nto-qnx700", aarch64_unknown_nto_qnx700),
("aarch64-unknown-nto-qnx710", aarch64_unknown_nto_qnx710),
("aarch64-unknown-nto-qnx710_iosock", aarch64_unknown_nto_qnx710_iosock),
("aarch64-unknown-nto-qnx800", aarch64_unknown_nto_qnx800),
("x86_64-pc-nto-qnx710", x86_64_pc_nto_qnx710),
("x86_64-pc-nto-qnx710_iosock", x86_64_pc_nto_qnx710_iosock),
("x86_64-pc-nto-qnx800", x86_64_pc_nto_qnx800),
("i586-pc-nto-qnx700", i586_pc_nto_qnx700),

("aarch64-unknown-linux-ohos", aarch64_unknown_linux_ohos),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use crate::spec::Target;
use crate::spec::base::nto_qnx;

pub(crate) fn target() -> Target {
let mut target = nto_qnx::aarch64();
target.metadata.description = Some("ARM64 QNX Neutrino 8.0 RTOS".into());
target.options.pre_link_args =
nto_qnx::pre_link_args(nto_qnx::ApiVariant::Default, nto_qnx::Arch::Aarch64);
target.options.env = "nto80".into();
target
}
11 changes: 11 additions & 0 deletions compiler/rustc_target/src/spec/targets/x86_64_pc_nto_qnx800.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use crate::spec::Target;
use crate::spec::base::nto_qnx;

pub(crate) fn target() -> Target {
let mut target = nto_qnx::x86_64();
target.metadata.description = Some("x86 64-bit QNX Neutrino 8.0 RTOS".into());
target.options.pre_link_args =
nto_qnx::pre_link_args(nto_qnx::ApiVariant::Default, nto_qnx::Arch::X86_64);
target.options.env = "nto80".into();
target
}
4 changes: 2 additions & 2 deletions library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ test = true
level = "warn"
check-cfg = [
'cfg(bootstrap)',
'cfg(target_arch, values("xtensa", "aarch64-unknown-nto-qnx710_iosock", "x86_64-pc-nto-qnx710_iosock"))',
'cfg(target_env, values("nto71_iosock"))',
'cfg(target_arch, values("xtensa", "aarch64-unknown-nto-qnx710_iosock", "x86_64-pc-nto-qnx710_iosock", "x86_64-pc-nto-qnx800","aarch64-unknown-nto-qnx800"))',
'cfg(target_env, values("nto71_iosock", "nto80"))',
# std use #[path] imports to portable-simd `std_float` crate
# and to the `backtrace` crate which messes-up with Cargo list
# of declared features, we therefor expect any feature cfg
Expand Down
14 changes: 3 additions & 11 deletions library/std/src/sys/pal/unix/process/process_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ use crate::sys::process::process_common::*;
use crate::{fmt, mem, sys};

cfg_if::cfg_if! {
// This workaround is only needed for QNX 7.0 and 7.1. The bug should have been fixed in 8.0
if #[cfg(any(target_env = "nto70", target_env = "nto71", target_env = "nto71_iosock"))] {
if #[cfg(target_os = "nto")] {
use crate::thread;
use libc::{c_char, posix_spawn_file_actions_t, posix_spawnattr_t};
use crate::time::Duration;
Expand Down Expand Up @@ -187,13 +186,7 @@ impl Command {

// Attempts to fork the process. If successful, returns Ok((0, -1))
// in the child, and Ok((child_pid, -1)) in the parent.
#[cfg(not(any(
target_os = "watchos",
target_os = "tvos",
target_env = "nto70",
target_env = "nto71",
target_env = "nto71_iosock",
)))]
#[cfg(not(any(target_os = "watchos", target_os = "tvos", target_os = "nto")))]
unsafe fn do_fork(&mut self) -> Result<pid_t, io::Error> {
cvt(libc::fork())
}
Expand All @@ -202,8 +195,7 @@ impl Command {
// or closed a file descriptor while the fork() was occurring".
// Documentation says "... or try calling fork() again". This is what we do here.
// See also https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/f/fork.html
// This workaround is only needed for QNX 7.0 and 7.1. The bug should have been fixed in 8.0
#[cfg(any(target_env = "nto70", target_env = "nto71", target_env = "nto71_iosock"))]
#[cfg(target_os = "nto")]
unsafe fn do_fork(&mut self) -> Result<pid_t, io::Error> {
use crate::sys::os::errno;

Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[
// just a dummy comment so the list doesn't get onelined
"aarch64-unknown-nto-qnx710_iosock",
"x86_64-pc-nto-qnx710_iosock",
"x86_64-pc-nto-qnx800",
"aarch64-unknown-nto-qnx800",
];

/// Minimum version threshold for libstdc++ required when using prebuilt LLVM
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/platform-support/nto-qnx.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ For conditional compilation, following QNX Neutrino specific attributes are defi
- `target_env` = `"nto71"` (for QNX Neutrino 7.1 with "classic" network stack "io_pkt")
- `target_env` = `"nto71_iosock"` (for QNX Neutrino 7.1 with network stack "io_sock")
- `target_env` = `"nto70"` (for QNX Neutrino 7.0)
- `target_env` = `"nto80"` (for QNX Neutrino 8.0)

## Building the target

Expand Down
6 changes: 6 additions & 0 deletions tests/assembly/targets/targets-elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
//@ revisions: aarch64_unknown_nto_qnx710_iosock
//@ [aarch64_unknown_nto_qnx710_iosock] compile-flags: --target aarch64-unknown-nto-qnx710_iosock
//@ [aarch64_unknown_nto_qnx710_iosock] needs-llvm-components: aarch64
//@ revisions: aarch64_unknown_nto_qnx800
//@ [aarch64_unknown_nto_qnx800] compile-flags: --target aarch64-unknown-nto-qnx800
//@ [aarch64_unknown_nto_qnx800] needs-llvm-components: aarch64
//@ revisions: aarch64_unknown_openbsd
//@ [aarch64_unknown_openbsd] compile-flags: --target aarch64-unknown-openbsd
//@ [aarch64_unknown_openbsd] needs-llvm-components: aarch64
Expand Down Expand Up @@ -552,6 +555,9 @@
//@ revisions: x86_64_pc_nto_qnx710_iosock
//@ [x86_64_pc_nto_qnx710_iosock] compile-flags: --target x86_64-pc-nto-qnx710_iosock
//@ [x86_64_pc_nto_qnx710_iosock] needs-llvm-components: x86
//@ revisions: x86_64_pc_nto_qnx800
//@ [x86_64_pc_nto_qnx800] compile-flags: --target x86_64-pc-nto-qnx800
//@ [x86_64_pc_nto_qnx800] needs-llvm-components: x86
//@ revisions: x86_64_pc_solaris
//@ [x86_64_pc_solaris] compile-flags: --target x86_64-pc-solaris
//@ [x86_64_pc_solaris] needs-llvm-components: x86
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/well-known-values.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
LL | target_env = "_UNEXPECTED_VALUE",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `gnu`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `ohos`, `p1`, `p2`, `relibc`, `sgx`, and `uclibc`
= note: expected values for `target_env` are: ``, `gnu`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `nto80`, `ohos`, `p1`, `p2`, `relibc`, `sgx`, and `uclibc`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
Expand Down

0 comments on commit 3255971

Please sign in to comment.