forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#127897 - nyurik:add-qnx-70-target, r=<try>
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
- Loading branch information
Showing
10 changed files
with
84 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
compiler/rustc_target/src/spec/targets/aarch64_unknown_nto_qnx700.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use crate::spec::{base, Cc, LinkerFlavor, Lld, Target, TargetOptions}; | ||
|
||
pub fn target() -> Target { | ||
// In QNX, libc does not provide a compatible ABI between versions. | ||
// To distinguish between QNX versions, we needed a stable conditional compilation switch, | ||
// which is why we needed to implement different targets in the compiler. | ||
Target { | ||
llvm_target: "aarch64-unknown-unknown".into(), | ||
metadata: crate::spec::TargetMetadata { | ||
description: Some("ARM64 QNX Neutrino 7.0 RTOS".into()), | ||
tier: Some(3), | ||
host_tools: Some(false), | ||
std: Some(true), | ||
}, | ||
pointer_width: 64, | ||
// from: https://llvm.org/docs/LangRef.html#data-layout | ||
// e = little endian | ||
// m:e = ELF mangling: Private symbols get a .L prefix | ||
// i8:8:32 = 8-bit-integer, minimum_alignment=8, preferred_alignment=32 | ||
// i16:16:32 = 16-bit-integer, minimum_alignment=16, preferred_alignment=32 | ||
// i64:64 = 64-bit-integer, minimum_alignment=64, preferred_alignment=64 | ||
// i128:128 = 128-bit-integer, minimum_alignment=128, preferred_alignment=128 | ||
// n32:64 = 32 and 64 are native integer widths; Elements of this set are considered to support most general arithmetic operations efficiently. | ||
// S128 = 128 bits are the natural alignment of the stack in bits. | ||
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), | ||
arch: "aarch64".into(), | ||
options: TargetOptions { | ||
features: "+v8a".into(), | ||
max_atomic_width: Some(128), | ||
pre_link_args: TargetOptions::link_args( | ||
LinkerFlavor::Gnu(Cc::Yes, Lld::No), | ||
&["-Vgcc_ntoaarch64le_cxx"], | ||
), | ||
env: "nto70".into(), | ||
..base::nto_qnx::opts() | ||
}, | ||
} | ||
} |
37 changes: 5 additions & 32 deletions
37
compiler/rustc_target/src/spec/targets/aarch64_unknown_nto_qnx710.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,8 @@ | ||
use crate::spec::{base, Cc, LinkerFlavor, Lld, Target, TargetOptions}; | ||
use crate::spec::Target; | ||
|
||
pub fn target() -> Target { | ||
Target { | ||
llvm_target: "aarch64-unknown-unknown".into(), | ||
metadata: crate::spec::TargetMetadata { | ||
description: Some("ARM64 QNX Neutrino 7.1 RTOS".into()), | ||
tier: Some(3), | ||
host_tools: Some(false), | ||
std: Some(true), | ||
}, | ||
pointer_width: 64, | ||
// from: https://llvm.org/docs/LangRef.html#data-layout | ||
// e = little endian | ||
// m:e = ELF mangling: Private symbols get a .L prefix | ||
// i8:8:32 = 8-bit-integer, minimum_alignment=8, preferred_alignment=32 | ||
// i16:16:32 = 16-bit-integer, minimum_alignment=16, preferred_alignment=32 | ||
// i64:64 = 64-bit-integer, minimum_alignment=64, preferred_alignment=64 | ||
// i128:128 = 128-bit-integer, minimum_alignment=128, preferred_alignment=128 | ||
// n32:64 = 32 and 64 are native integer widths; Elements of this set are considered to support most general arithmetic operations efficiently. | ||
// S128 = 128 bits are the natural alignment of the stack in bits. | ||
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), | ||
arch: "aarch64".into(), | ||
options: TargetOptions { | ||
features: "+v8a".into(), | ||
max_atomic_width: Some(128), | ||
pre_link_args: TargetOptions::link_args( | ||
LinkerFlavor::Gnu(Cc::Yes, Lld::No), | ||
&["-Vgcc_ntoaarch64le_cxx"], | ||
), | ||
env: "nto71".into(), | ||
..base::nto_qnx::opts() | ||
}, | ||
} | ||
let mut base = super::aarch64_unknown_nto_qnx700::target(); | ||
base.metadata.description = Some("ARM64 QNX Neutrino 7.1 RTOS".into()); | ||
base.options.env = "nto71".into(); | ||
base | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters