Skip to content

Commit 72b6642

Browse files
committed
Add support for QNX 7.1 with io-sock on x64
1 parent c8abad0 commit 72b6642

File tree

7 files changed

+39
-7
lines changed

7 files changed

+39
-7
lines changed

compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ supported_targets! {
19281928
("aarch64-unknown-nto-qnx710", aarch64_unknown_nto_qnx710),
19291929
("aarch64-unknown-nto-qnx710_iosock", aarch64_unknown_nto_qnx710_iosock),
19301930
("x86_64-pc-nto-qnx710", x86_64_pc_nto_qnx710),
1931+
("x86_64-pc-nto-qnx710_iosock", x86_64_pc_nto_qnx710_iosock),
19311932
("i586-pc-nto-qnx700", i586_pc_nto_qnx700),
19321933

19331934
("aarch64-unknown-linux-ohos", aarch64_unknown_linux_ohos),
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::x86_64_pc_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_ntox86_64_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}/x86_64/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", "aarch64-unknown-nto-qnx710_iosock"))',
142+
'cfg(target_arch, values("xtensa", "aarch64-unknown-nto-qnx710_iosock", "x86_64-pc-nto-qnx710_iosock"))',
143143
'cfg(target_env, values("nto71_iosock"))',
144144
# std use #[path] imports to portable-simd `std_float` crate
145145
# and to the `backtrace` crate which messes-up with Cargo list

src/bootstrap/src/core/sanity.rs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub struct Finder {
3535
const STAGE0_MISSING_TARGETS: &[&str] = &[
3636
// just a dummy comment so the list doesn't get onelined
3737
"aarch64-unknown-nto-qnx710_iosock",
38+
"x86_64-pc-nto-qnx710_iosock",
3839
];
3940

4041
/// 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
@@ -381,7 +381,8 @@ target | std | host | notes
381381
[`wasm64-unknown-unknown`](platform-support/wasm64-unknown-unknown.md) | ? | | WebAssembly
382382
[`x86_64-apple-tvos`](platform-support/apple-tvos.md) | ✓ | | x86 64-bit tvOS
383383
[`x86_64-apple-watchos-sim`](platform-support/apple-watchos.md) | ✓ | | x86 64-bit Apple WatchOS simulator
384-
[`x86_64-pc-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS |
384+
[`x86_64-pc-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS with default network stack (io-pkt) |
385+
[`x86_64-pc-nto-qnx710_iosock`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS with new network stack (io-sock) |
385386
[`x86_64-unikraft-linux-musl`](platform-support/unikraft-linux-musl.md) | ✓ | | 64-bit Unikraft with musl 1.2.3
386387
`x86_64-unknown-dragonfly` | ✓ | ✓ | 64-bit DragonFlyBSD
387388
`x86_64-unknown-haiku` | ✓ | ✓ | 64-bit Haiku

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ 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 with io-pkt | AArch64 |||
26-
| 7.1 with io-sock | AArch64 |||
27-
| 7.1 | x86_64 |||
28-
| 7.0 | AArch64 | ? ||
29-
| 7.0 | x86 | ||
25+
| 7.1 with io-pkt | AArch64 |||
26+
| 7.1 with io-sock | AArch64 | ? ||
27+
| 7.1 with io-pkt | x86_64 |||
28+
| 7.1 with io-sock | x86_64 | ? ||
29+
| 7.0 | AArch64 | ? ||
30+
| 7.0 | x86 | ||
3031

3132
On QNX 7.0 and 7.1, `io-pkt` is used as network stack by default. QNX 7.1 includes
3233
the optional network stack `io-sock`.

tests/assembly/targets/targets-elf.rs

+3
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,9 @@
549549
//@ revisions: x86_64_pc_nto_qnx710
550550
//@ [x86_64_pc_nto_qnx710] compile-flags: --target x86_64-pc-nto-qnx710
551551
//@ [x86_64_pc_nto_qnx710] needs-llvm-components: x86
552+
//@ revisions: x86_64_pc_nto_qnx710_iosock
553+
//@ [x86_64_pc_nto_qnx710_iosock] compile-flags: --target x86_64-pc-nto-qnx710_iosock
554+
//@ [x86_64_pc_nto_qnx710_iosock] needs-llvm-components: x86
552555
//@ revisions: x86_64_pc_solaris
553556
//@ [x86_64_pc_solaris] compile-flags: --target x86_64-pc-solaris
554557
//@ [x86_64_pc_solaris] needs-llvm-components: x86

0 commit comments

Comments
 (0)