Skip to content

Commit 6116b6a

Browse files
committed
Add new target for supporting Neutrino QNX 7.1 with io-socket network stack
1 parent 5bbbc09 commit 6116b6a

File tree

9 files changed

+50
-9
lines changed

9 files changed

+50
-9
lines changed

compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,7 @@ supported_targets! {
19261926

19271927
("aarch64-unknown-nto-qnx700", aarch64_unknown_nto_qnx700),
19281928
("aarch64-unknown-nto-qnx710", aarch64_unknown_nto_qnx710),
1929+
("aarch64-unknown-nto-qnx710-iosock", aarch64_unknown_nto_qnx710_iosock),
19291930
("x86_64-pc-nto-qnx710", x86_64_pc_nto_qnx710),
19301931
("i586-pc-nto-qnx700", i586_pc_nto_qnx700),
19311932

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetOptions};
2+
3+
pub(crate) fn target() -> Target {
4+
let mut target = super::aarch64_unknown_nto_qnx710::target();
5+
target.options.env = "nto71_iosock".into();
6+
target.options.pre_link_args = TargetOptions::link_args(
7+
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
8+
&["-Vgcc_ntoaarch64le_cxx", get_iosock_param()],
9+
);
10+
target
11+
}
12+
13+
// When using `io-sock` on QNX, we must add a search path for the linker so
14+
// that it prefers the io-sock version.
15+
// The path depends on the host, i.e. we cannot hard-code it here, but have
16+
// to determine it when the compiler runs.
17+
// When using the QNX toolchain, the environment variable QNX_TARGET is always set.
18+
// More information:
19+
// https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.io_sock/topic/migrate_app.html
20+
fn get_iosock_param() -> &'static str {
21+
let target_dir = std::env::var("QNX_TARGET").expect("Environment variable QNX_TARGET is set");
22+
let linker_param = format!("-L{target_dir}/aarch64le/io-sock/lib");
23+
24+
linker_param.leak()
25+
}

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ test = true
139139
level = "warn"
140140
check-cfg = [
141141
'cfg(bootstrap)',
142-
'cfg(target_arch, values("xtensa"))',
142+
'cfg(target_arch, values("xtensa", "aarch64-unknown-nto-qnx710-iosock"))',
143143
# std use #[path] imports to portable-simd `std_float` crate
144144
# and to the `backtrace` crate which messes-up with Cargo list
145145
# of declared features, we therefor expect any feature cfg

library/std/src/sys/pal/unix/process/process_unix.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::{fmt, mem, sys};
2020

2121
cfg_if::cfg_if! {
2222
// This workaround is only needed for QNX 7.0 and 7.1. The bug should have been fixed in 8.0
23-
if #[cfg(any(target_env = "nto70", target_env = "nto71"))] {
23+
if #[cfg(any(target_env = "nto70", target_env = "nto71", target_env = "nto71_iosock"))] {
2424
use crate::thread;
2525
use libc::{c_char, posix_spawn_file_actions_t, posix_spawnattr_t};
2626
use crate::time::Duration;
@@ -191,7 +191,8 @@ impl Command {
191191
target_os = "watchos",
192192
target_os = "tvos",
193193
target_env = "nto70",
194-
target_env = "nto71"
194+
target_env = "nto71",
195+
target_env = "nto71_iosock",
195196
)))]
196197
unsafe fn do_fork(&mut self) -> Result<pid_t, io::Error> {
197198
cvt(libc::fork())
@@ -202,7 +203,7 @@ impl Command {
202203
// Documentation says "... or try calling fork() again". This is what we do here.
203204
// See also https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/f/fork.html
204205
// This workaround is only needed for QNX 7.0 and 7.1. The bug should have been fixed in 8.0
205-
#[cfg(any(target_env = "nto70", target_env = "nto71"))]
206+
#[cfg(any(target_env = "nto70", target_env = "nto71", target_env = "nto71_iosock"))]
206207
unsafe fn do_fork(&mut self) -> Result<pid_t, io::Error> {
207208
use crate::sys::os::errno;
208209

src/bootstrap/src/core/sanity.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub struct Finder {
3434
// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
3535
const STAGE0_MISSING_TARGETS: &[&str] = &[
3636
// just a dummy comment so the list doesn't get onelined
37+
"aarch64-unknown-nto-qnx710-iosock"
3738
];
3839

3940
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ target | std | host | notes
257257
[`aarch64-nintendo-switch-freestanding`](platform-support/aarch64-nintendo-switch-freestanding.md) | * | | ARM64 Nintendo Switch, Horizon
258258
[`aarch64-unknown-teeos`](platform-support/aarch64-unknown-teeos.md) | ? | | ARM64 TEEOS |
259259
[`aarch64-unknown-nto-qnx700`](platform-support/nto-qnx.md) | ? | | ARM64 QNX Neutrino 7.0 RTOS |
260-
[`aarch64-unknown-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | ARM64 QNX Neutrino 7.1 RTOS |
260+
[`aarch64-unknown-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | ARM64 QNX Neutrino 7.1 RTOS with default network stack (io-pkt) |
261+
[`aarch64-unknown-nto-qnx710-iosock`](platform-support/nto-qnx.md) | ✓ | | ARM64 QNX Neutrino 7.1 RTOS with new network stack (io-sock) |
261262
`aarch64-unknown-freebsd` | ✓ | ✓ | ARM64 FreeBSD
262263
[`aarch64-unknown-hermit`](platform-support/hermit.md) | ✓ | | ARM64 Hermit
263264
`aarch64-unknown-illumos` | ✓ | ✓ | ARM64 illumos

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ Currently, the following QNX Neutrino versions and compilation targets are suppo
2222

2323
| QNX Neutrino Version | Target Architecture | Full support | `no_std` support |
2424
|----------------------|---------------------|:------------:|:----------------:|
25-
| 7.1 | AArch64 |||
25+
| 7.1 with io-pkt | AArch64 |||
26+
| 7.1 with io-sock | AArch64 |||
2627
| 7.1 | x86_64 |||
2728
| 7.0 | AArch64 | ? ||
2829
| 7.0 | x86 | ||
2930

31+
On QNX 7.0 and 7.1, `io-pkt` is used as network stack by default. QNX 7.1 includes
32+
the optional network stack `io-sock`.
33+
3034
Adding other architectures that are supported by QNX Neutrino is possible.
3135

3236
In the table above, 'full support' indicates support for building Rust applications with the full standard library.
@@ -107,7 +111,8 @@ There are no further known requirements.
107111
For conditional compilation, following QNX Neutrino specific attributes are defined:
108112

109113
- `target_os` = `"nto"`
110-
- `target_env` = `"nto71"` (for QNX Neutrino 7.1)
114+
- `target_env` = `"nto71"` (for QNX Neutrino 7.1 with "classic" network stack "io_pkt")
115+
- `target_env` = `"nto71_iosock"` (for QNX Neutrino 7.1 with network stack "io_sock")
111116
- `target_env` = `"nto70"` (for QNX Neutrino 7.0)
112117

113118
## Building the target
@@ -134,14 +139,18 @@ export build_env='
134139
CFLAGS_aarch64-unknown-nto-qnx710=-Vgcc_ntoaarch64le_cxx
135140
CXX_aarch64-unknown-nto-qnx710=qcc
136141
AR_aarch64_unknown_nto_qnx710=ntoaarch64-ar
142+
CC_aarch64-unknown-nto-qnx710-iosock=qcc
143+
CFLAGS_aarch64-unknown-nto-qnx710-iosock=-Vgcc_ntoaarch64le_cxx
144+
CXX_aarch64-unknown-nto-qnx710-iosock=qcc
145+
AR_aarch64_unknown_nto_qnx710_iosock=ntoaarch64-ar
137146
CC_x86_64-pc-nto-qnx710=qcc
138147
CFLAGS_x86_64-pc-nto-qnx710=-Vgcc_ntox86_64_cxx
139148
CXX_x86_64-pc-nto-qnx710=qcc
140149
AR_x86_64_pc_nto_qnx710=ntox86_64-ar'
141150

142151
env $build_env \
143152
./x.py build \
144-
--target aarch64-unknown-nto-qnx710,x86_64-pc-nto-qnx710,x86_64-unknown-linux-gnu \
153+
--target aarch64-unknown-nto-qnx710-iosock,aarch64-unknown-nto-qnx710,x86_64-pc-nto-qnx710,x86_64-unknown-linux-gnu \
145154
rustc library/core library/alloc library/std
146155
```
147156

tests/assembly/targets/targets-elf.rs

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
//@ revisions: aarch64_unknown_nto_qnx710
5858
//@ [aarch64_unknown_nto_qnx710] compile-flags: --target aarch64-unknown-nto-qnx710
5959
//@ [aarch64_unknown_nto_qnx710] needs-llvm-components: aarch64
60+
//@ revisions: aarch64_unknown_nto_qnx710_iosock
61+
//@ [aarch64_unknown_nto_qnx710] compile-flags: --target aarch64-unknown-nto-qnx710-iosock
62+
//@ [aarch64_unknown_nto_qnx710] needs-llvm-components: aarch64
6063
//@ revisions: aarch64_unknown_openbsd
6164
//@ [aarch64_unknown_openbsd] compile-flags: --target aarch64-unknown-openbsd
6265
//@ [aarch64_unknown_openbsd] needs-llvm-components: aarch64

tests/ui/check-cfg/well-known-values.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
156156
LL | target_env = "_UNEXPECTED_VALUE",
157157
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
158158
|
159-
= note: expected values for `target_env` are: ``, `gnu`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `relibc`, `sgx`, and `uclibc`
159+
= note: expected values for `target_env` are: ``, `gnu`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `ohos`, `p1`, `p2`, `relibc`, `sgx`, and `uclibc`
160160
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
161161

162162
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`

0 commit comments

Comments
 (0)