5 [BlackBerry® QNX®][BlackBerry] Neutrino (nto) Real-time operating system.
6 The support has been implemented jointly by [Elektrobit Automotive GmbH][Elektrobit]
7 and [BlackBerry][BlackBerry].
9 [BlackBerry]: https://blackberry.qnx.com
10 [Elektrobit]: https://www.elektrobit.com
14 - Florian Bartels, `Florian.Bartels@elektrobit.com`, https://github.com/flba-eb
15 - Tristan Roach, `TRoach@blackberry.com`, https://github.com/gh-tr
19 Currently, only cross-compilation for QNX Neutrino on AArch64 and x86_64 are supported (little endian).
20 Adding other architectures that are supported by QNX Neutrino is possible.
22 The standard library does not yet support QNX Neutrino. Therefore, only `no_std` code can
25 `core` and `alloc` (with default allocator) are supported.
27 Applications must link against `libc.so` (see example). This is required because applications
28 always link against the `crt` library and `crt` depends on `libc.so`.
30 The correct version of `qcc` must be available by setting the `$PATH` variable (e.g. by sourcing `qnxsdp-env.sh` of the
31 QNX Neutrino toolchain).
33 ### Small example application
35 ```rust,ignore (platform-specific)
38 #![feature(lang_items)]
40 // We must always link against libc, even if no external functions are used
41 // "extern C" - Block can be empty but must be present
44 pub fn printf(format: *const core::ffi::c_char, ...) -> core::ffi::c_int;
48 pub extern "C" fn main(_argc: isize, _argv: *const *const u8) -> isize {
49 const HELLO: &'static str = "Hello World, the answer is %d\n\0";
51 printf(HELLO.as_ptr() as *const _, 42);
56 use core::panic::PanicInfo;
59 fn panic(_panic: &PanicInfo<'_>) -> ! {
63 #[lang = "eh_personality"]
65 pub extern "C" fn rust_eh_personality() {}
68 The QNX Neutrino support of Rust has been tested with QNX Neutrino 7.1.
70 There are no further known requirements.
72 ## Conditional compilation
74 For conditional compilation, following QNX Neutrino specific attributes are defined:
76 - `target_os` = `"nto"`
77 - `target_env` = `"nto71"` (for QNX Neutrino 7.1)
79 ## Building the target
81 1. Create a `config.toml`
90 2. Compile the Rust toolchain for an `x86_64-unknown-linux-gnu` host (for both `aarch64` and `x86_64` targets)
96 CC_aarch64-unknown-nto-qnx710="qcc" \
97 CFLAGS_aarch64-unknown-nto-qnx710="-Vgcc_ntoaarch64le_cxx" \
98 CXX_aarch64-unknown-nto-qnx710="qcc" \
99 AR_aarch64_unknown_nto_qnx710="ntoaarch64-ar" \
100 CC_x86_64-pc-nto-qnx710="qcc" \
101 CFLAGS_x86_64-pc-nto-qnx710="-Vgcc_ntox86_64_cxx" \
102 CXX_x86_64-pc-nto-qnx710="qcc" \
103 AR_x86_64_pc_nto_qnx710="ntox86_64-ar" \
104 ./x.py build --target aarch64-unknown-nto-qnx710 --target x86_64-pc-nto-qnx710 --target x86_64-unknown-linux-gnu rustc library/core library/alloc/
107 ## Building Rust programs
109 Rust does not yet ship pre-compiled artifacts for this target. To compile for this target, you must either build Rust with the target enabled (see "Building the target" above), or build your own copy of `core` by using
110 `build-std` or similar.
114 Compiled executables can directly be run on QNX Neutrino.
116 ## Cross-compilation toolchains and C code
118 Compiling C code requires the same environment variables to be set as compiling the Rust toolchain (see above), to ensure `qcc` is used with proper arguments. To ensure compatibility, do not specify any further arguments that for example change calling conventions or memory layout.