Skip to content

Commit efe53dd

Browse files
committed
Add support for QNX 7.1 with io-sock on x64
Signed-off-by: Florian Bartels <[email protected]>
1 parent 84c8015 commit efe53dd

File tree

7 files changed

+41
-7
lines changed

7 files changed

+41
-7
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,7 @@ supported_targets! {
19651965
("aarch64-unknown-nto-qnx710", aarch64_unknown_nto_qnx710),
19661966
("aarch64-unknown-nto-qnx710_iosock", aarch64_unknown_nto_qnx710_iosock),
19671967
("x86_64-pc-nto-qnx710", x86_64_pc_nto_qnx710),
1968+
("x86_64-pc-nto-qnx710_iosock", x86_64_pc_nto_qnx710_iosock),
19681969
("i586-pc-nto-qnx700", i586_pc_nto_qnx700),
19691970

19701971
("aarch64-unknown-linux-ohos", aarch64_unknown_linux_ohos),
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 =
7+
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[
8+
"-Vgcc_ntox86_64_cxx",
9+
get_iosock_param(),
10+
]);
11+
target
12+
}
13+
14+
// When using `io-sock` on QNX, we must add a search path for the linker so
15+
// that it prefers the io-sock version.
16+
// The path depends on the host, i.e. we cannot hard-code it here, but have
17+
// to determine it when the compiler runs.
18+
// When using the QNX toolchain, the environment variable QNX_TARGET is always set.
19+
// More information:
20+
// https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.io_sock/topic/migrate_app.html
21+
fn get_iosock_param() -> &'static str {
22+
let target_dir =
23+
std::env::var("QNX_TARGET").unwrap_or_else(|_| "PLEASE_SET_ENV_VAR_QNX_TARGET".into());
24+
let linker_param = format!("-L{target_dir}/x86_64/io-sock/lib");
25+
26+
linker_param.leak()
27+
}

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ target | std | host | notes
406406
[`wasm64-unknown-unknown`](platform-support/wasm64-unknown-unknown.md) | ? | | WebAssembly
407407
[`x86_64-apple-tvos`](platform-support/apple-tvos.md) | ✓ | | x86 64-bit tvOS
408408
[`x86_64-apple-watchos-sim`](platform-support/apple-watchos.md) | ✓ | | x86 64-bit Apple WatchOS simulator
409-
[`x86_64-pc-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS |
409+
[`x86_64-pc-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS with default network stack (io-pkt) |
410+
[`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) |
410411
[`x86_64-unikraft-linux-musl`](platform-support/unikraft-linux-musl.md) | ✓ | | 64-bit Unikraft with musl 1.2.3
411412
`x86_64-unknown-dragonfly` | ✓ | ✓ | 64-bit DragonFlyBSD
412413
`x86_64-unknown-haiku` | ✓ | ✓ | 64-bit Haiku

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

Lines changed: 6 additions & 5 deletions
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,9 @@
567567
//@ revisions: x86_64_pc_nto_qnx710
568568
//@ [x86_64_pc_nto_qnx710] compile-flags: --target x86_64-pc-nto-qnx710
569569
//@ [x86_64_pc_nto_qnx710] needs-llvm-components: x86
570+
//@ revisions: x86_64_pc_nto_qnx710_iosock
571+
//@ [x86_64_pc_nto_qnx710_iosock] compile-flags: --target x86_64-pc-nto-qnx710_iosock
572+
//@ [x86_64_pc_nto_qnx710_iosock] needs-llvm-components: x86
570573
//@ revisions: x86_64_pc_solaris
571574
//@ [x86_64_pc_solaris] compile-flags: --target x86_64-pc-solaris
572575
//@ [x86_64_pc_solaris] needs-llvm-components: x86

0 commit comments

Comments
 (0)