Skip to content

Commit 2552cd4

Browse files
committed
WIP: add QNX 7.0 support for aarch64le
# Compile target ```bash source /path/to/qnx7.0/qnxsdp-env.sh export build_env=' CC_aarch64-unknown-nto-qnx700=qcc CFLAGS_aarch64-unknown-nto-qnx700=-Vgcc_ntoaarch64le_cxx CXX_aarch64-unknown-nto-qnx700=qcc AR_aarch64_unknown_nto_qnx700=ntoaarch64-ar' env $build_env \ ./x.py build \ --target x86_64-unknown-linux-gnu,aarch64-unknown-nto-qnx700 \ rustc library/core library/alloc library/std rustup toolchain link stage1 build/host/stage1 ``` # Compile "hello world" ```bash # In a separate terminal, without env vars cargo new hello_world cd hello_world cargo +stage1 build --release --target aarch64-unknown-nto-qnx700 ```
1 parent 73a2281 commit 2552cd4

File tree

7 files changed

+60
-7
lines changed

7 files changed

+60
-7
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,7 @@ supported_targets! {
18301830

18311831
("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl),
18321832

1833+
("aarch64-unknown-nto-qnx700", aarch64_unknown_nto_qnx700),
18331834
("aarch64-unknown-nto-qnx710", aarch64_unknown_nto_qnx710),
18341835
("x86_64-pc-nto-qnx710", x86_64_pc_nto_qnx710),
18351836
("i586-pc-nto-qnx700", i586_pc_nto_qnx700),
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
use crate::spec::{base, Cc, LinkerFlavor, Target, TargetOptions};
2+
3+
pub fn target() -> Target {
4+
Target {
5+
llvm_target: "aarch64-unknown-unknown".into(),
6+
metadata: crate::spec::TargetMetadata {
7+
description: Some("ARM64 QNX Neutrino 7.0 RTOS".into()),
8+
tier: Some(3),
9+
host_tools: Some(false),
10+
std: Some(true),
11+
},
12+
pointer_width: 64,
13+
// from: https://llvm.org/docs/LangRef.html#data-layout
14+
// e = little endian
15+
// m:e = ELF mangling: Private symbols get a .L prefix
16+
// i8:8:32 = 8-bit-integer, minimum_alignment=8, preferred_alignment=32
17+
// i16:16:32 = 16-bit-integer, minimum_alignment=16, preferred_alignment=32
18+
// i64:64 = 64-bit-integer, minimum_alignment=64, preferred_alignment=64
19+
// i128:128 = 128-bit-integer, minimum_alignment=128, preferred_alignment=128
20+
// n32:64 = 32 and 64 are native integer widths; Elements of this set are considered to support most general arithmetic operations efficiently.
21+
// S128 = 128 bits are the natural alignment of the stack in bits.
22+
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
23+
arch: "aarch64".into(),
24+
options: TargetOptions {
25+
// TODO: need?
26+
linker: Some("qcc".into()),
27+
// TODO: need?
28+
linker_flavor: LinkerFlavor::Unix(Cc::Yes),
29+
features: "+v8a".into(),
30+
max_atomic_width: Some(128),
31+
pre_link_args: TargetOptions::link_args(
32+
// TODO: Unix or Gnu(Yes,No)?
33+
LinkerFlavor::Unix(Cc::Yes),
34+
&["-Vgcc_ntoaarch64le_cxx"],
35+
),
36+
// relocation_model: crate::spec::RelocModel::Pie,
37+
env: "nto70".into(),
38+
..base::nto_qnx::opts()
39+
},
40+
}
41+
}

library/std/src/sys/pal/unix/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> {
17421742
run_path_with_cstr(original, &|original| {
17431743
run_path_with_cstr(link, &|link| {
17441744
cfg_if::cfg_if! {
1745-
if #[cfg(any(target_os = "vxworks", target_os = "redox", target_os = "android", target_os = "espidf", target_os = "horizon", target_os = "vita"))] {
1745+
if #[cfg(any(target_os = "vxworks", target_os = "redox", target_os = "android", target_os = "espidf", target_os = "horizon", target_os = "vita", target_os = "nto"))] {
17461746
// VxWorks, Redox and ESP-IDF lack `linkat`, so use `link` instead. POSIX leaves
17471747
// it implementation-defined whether `link` follows symlinks, so rely on the
17481748
// `symlink_hard_link` test in library/std/src/fs/tests.rs to check the behavior.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use libc::{c_int, pid_t};
2424
use libc::{gid_t, uid_t};
2525

2626
cfg_if::cfg_if! {
27-
if #[cfg(all(target_os = "nto", target_env = "nto71"))] {
27+
if #[cfg(target_os = "nto")] {
2828
use crate::thread;
2929
use libc::{c_char, posix_spawn_file_actions_t, posix_spawnattr_t};
3030
use crate::time::Duration;
@@ -194,7 +194,7 @@ impl Command {
194194
#[cfg(not(any(
195195
target_os = "watchos",
196196
target_os = "tvos",
197-
all(target_os = "nto", target_env = "nto71"),
197+
target_os = "nto",
198198
)))]
199199
unsafe fn do_fork(&mut self) -> Result<pid_t, io::Error> {
200200
cvt(libc::fork())
@@ -204,7 +204,7 @@ impl Command {
204204
// or closed a file descriptor while the fork() was occurring".
205205
// Documentation says "... or try calling fork() again". This is what we do here.
206206
// See also https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/f/fork.html
207-
#[cfg(all(target_os = "nto", target_env = "nto71"))]
207+
#[cfg(target_os = "nto")]
208208
unsafe fn do_fork(&mut self) -> Result<pid_t, io::Error> {
209209
use crate::sys::os::errno;
210210

@@ -541,7 +541,7 @@ impl Command {
541541
// or closed a file descriptor while the posix_spawn() was occurring".
542542
// Documentation says "... or try calling posix_spawn() again". This is what we do here.
543543
// See also http://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/p/posix_spawn.html
544-
#[cfg(all(target_os = "nto", target_env = "nto71"))]
544+
#[cfg(target_os = "nto")]
545545
unsafe fn retrying_libc_posix_spawnp(
546546
pid: *mut pid_t,
547547
file: *const c_char,

library/unwind/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,15 @@ extern "C" {}
166166
extern "C" {}
167167

168168
#[cfg(target_os = "nto")]
169-
#[link(name = "gcc_s")]
170-
extern "C" {}
169+
cfg_if::cfg_if! {
170+
if #[cfg(target_env = "nto70")] {
171+
#[link(name = "gcc")]
172+
extern "C" {}
173+
} else {
174+
#[link(name = "gcc_s")]
175+
extern "C" {}
176+
}
177+
}
171178

172179
#[cfg(target_os = "hurd")]
173180
#[link(name = "gcc_s")]

src/bootstrap/src/core/sanity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub struct Finder {
3838
// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
3939
#[cfg(not(feature = "bootstrap-self-test"))]
4040
const STAGE0_MISSING_TARGETS: &[&str] = &[
41+
"aarch64-unknown-nto-qnx700"
4142
// just a dummy comment so the list doesn't get onelined
4243
];
4344

tests/assembly/targets/targets-elf.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
//@ revisions: aarch64_unknown_none_softfloat
5555
//@ [aarch64_unknown_none_softfloat] compile-flags: --target aarch64-unknown-none-softfloat
5656
//@ [aarch64_unknown_none_softfloat] needs-llvm-components: aarch64
57+
//@ revisions: aarch64_unknown_nto_qnx700
58+
//@ [aarch64_unknown_nto_qnx700] compile-flags: --target aarch64-unknown-nto-qnx700
59+
//@ [aarch64_unknown_nto_qnx700] needs-llvm-components: aarch64
5760
//@ revisions: aarch64_unknown_nto_qnx710
5861
//@ [aarch64_unknown_nto_qnx710] compile-flags: --target aarch64-unknown-nto-qnx710
5962
//@ [aarch64_unknown_nto_qnx710] needs-llvm-components: aarch64

0 commit comments

Comments
 (0)