Skip to content

Commit 065844b

Browse files
committed
Auto merge of rust-lang#127897 - nyurik:add-qnx-70-target, r=saethlin
add `aarch64_unknown_nto_qnx700` target - QNX 7.0 support for aarch64le This backports the QNX 7.1 aarch64 implementation to 7.0. * [x] required `-lregex` disabled, see rust-lang/libc#3775 (released in libc 0.2.156) * [x] uses `libgcc.a` instead of `libgcc_s.so` (7.0 used ancient GCC 5.4 which didn't have gcc_s) * [x] a fix in `backtrace` crate to support stack traces rust-lang/backtrace-rs#648 This PR bumps libc dependency to 0.2.158 CC: to the folks who did the [initial implementation](https://doc.rust-lang.org/rustc/platform-support/nto-qnx.html): `@flba-eb,` `@gh-tr,` `@jonathanpallant,` `@japaric` # Compile target ```bash # Configure qcc build environment source _path_/_to_/qnx7.0/qnxsdp-env.sh # Tell rust to use qcc when building QNX 7.0 targets 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' # Build rust compiler, libs, and the remote test server env $build_env ./x.py build \ --target x86_64-unknown-linux-gnu,aarch64-unknown-nto-qnx700 \ rustc library/core library/alloc library/std src/tools/remote-test-server rustup toolchain link stage1 build/host/stage1 ``` # Compile "hello world" ```bash source _path_/_to_/qnx7.0/qnxsdp-env.sh cargo new hello_world cd hello_world cargo +stage1 build --release --target aarch64-unknown-nto-qnx700 ``` # Configure a remote for testing Do this from a new shell - we will need to run more commands in the previous one. I ran into these two issues, and found some workarounds. * Temporary dir might not work properly * Default `remote-test-server` has issues binding to an address ``` # ./remote-test-server starting test server thread 'main' panicked at src/tools/remote-test-server/src/main.rs:175:29: called `Result::unwrap()` on an `Err` value: Os { code: 249, kind: AddrNotAvailable, message: "Can't assign requested address" } note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` Specifying `--bind` param actually fixes that, and so does setting `TMPDIR` properly. ```bash # Copy remote-test-server to remote device. You may need to use sftp instead. # ATTENTION: Note that the path is different from the one in the remote testing documentation for some reason scp ./build/x86_64-unknown-linux-gnu/stage1-tools-bin/remote-test-server qnxdevice:/path/ # Run ssh with port forwarding - so that rust tester can connect to the local port instead ssh -L 12345:127.0.0.1:12345 qnxdevice # on the device, run rm -rf tmp && mkdir -p tmp && TMPDIR=$PWD/tmp ./remote-test-server --bind 0.0.0.0:12345 ``` # Run test suit Assume all previous environment variables are still set, or re-init them ```bash export TEST_DEVICE_ADDR="localhost:12345" # tidy needs to be skipped due to using un-published libc dependency export exclude_tests=' --exclude src/bootstrap --exclude src/tools/error_index_generator --exclude src/tools/linkchecker --exclude src/tools/tidy --exclude tests/ui-fulldeps --exclude rustc --exclude rustdoc --exclude tests/run-make-fulldeps' env $build_env ./x.py test $exclude_tests --stage 1 --target aarch64-unknown-nto-qnx700 ``` try-job: dist-x86_64-msvc
2 parents 759399b + c664843 commit 065844b

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

Diff for: std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ miniz_oxide = { version = "0.7.0", optional = true, default-features = false }
3535
addr2line = { version = "0.22.0", optional = true, default-features = false }
3636

3737
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
38-
libc = { version = "0.2.153", default-features = false, features = [
38+
libc = { version = "0.2.156", default-features = false, features = [
3939
'rustc-dep-of-std',
4040
], public = true }
4141

Diff for: std/src/sys/pal/unix/fs.rs

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

Diff for: std/src/sys/pal/unix/process/process_unix.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use crate::sys::process::process_common::*;
1919
use crate::{fmt, mem, sys};
2020

2121
cfg_if::cfg_if! {
22-
if #[cfg(all(target_os = "nto", target_env = "nto71"))] {
22+
// 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"))] {
2324
use crate::thread;
2425
use libc::{c_char, posix_spawn_file_actions_t, posix_spawnattr_t};
2526
use crate::time::Duration;
@@ -189,7 +190,8 @@ impl Command {
189190
#[cfg(not(any(
190191
target_os = "watchos",
191192
target_os = "tvos",
192-
all(target_os = "nto", target_env = "nto71"),
193+
target_env = "nto70",
194+
target_env = "nto71"
193195
)))]
194196
unsafe fn do_fork(&mut self) -> Result<pid_t, io::Error> {
195197
cvt(libc::fork())
@@ -199,7 +201,8 @@ impl Command {
199201
// or closed a file descriptor while the fork() was occurring".
200202
// Documentation says "... or try calling fork() again". This is what we do here.
201203
// See also https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/f/fork.html
202-
#[cfg(all(target_os = "nto", target_env = "nto71"))]
204+
// 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"))]
203206
unsafe fn do_fork(&mut self) -> Result<pid_t, io::Error> {
204207
use crate::sys::os::errno;
205208

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

Diff for: unwind/src/lib.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,15 @@ extern "C" {}
165165
extern "C" {}
166166

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

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

0 commit comments

Comments
 (0)