Skip to content

Commit 066b83b

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

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

compiler/rustc_target/src/spec/mod.rs

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

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

tests/assembly/targets/targets-elf.rs

Lines changed: 3 additions & 0 deletions
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)