Friday, April 18, 2025

Rust on QNX

Rust on QNX

This blog shows how to build a Rust toolchain for QNX 7.1 OS.

Below is my environment:
Host OS: Linux Mint 22.1
QNX: 7.1

To get started, let's get lastest Rust so we can use it to bootstrap the new toolchain
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Install development dependencies
$ sudo apt install build-essential cmake python3 perl git llvm-dev
Setup
$ source ~/qnx710/qnxsdp-env.sh
$ mkdir ~/repo
$ cd ~/repo
$ git clone https://github.com/rust-lang/rust.git
$ cd rust
$ #create config.toml
$ echo 'profile = "compiler"' > config.toml
$ echo change-id = 999999 >> config.toml
Update environment variables for CC_/CF_FLAGS/CXX_/AR_, this is targetting x8_64
$ export build_env='
    CC_x86_64_unknown_nto_qnx710=qcc
    CFLAGS_x86_64_unknown_nto_qnx710=-Vgcc_ntox86_64_cxx
    CXX_x86_64_unknown_nto_qnx710=qcc
    AR_x86_64_unknown_nto_qnx710=ntox86_64-ar
    '
Build the toolchain
$ env $build_env \
    ./x.py build \
        --target x86_64-unknown-linux-gnu,x86_64-pc-nto-qnx710 \
        rustc library/core library/alloc library/std
Now, let's tell Rust that there is a toolchain we call qnx-toolchain
$ rustup toolchain link qnx-toolchain ~/repo/rust/build/x86_64-unknown-linux-gnu/stage1/
And for convenience, make it the default:
$ rustup default qnx-toolchain
There should be a Rust binary located like below:
$ ls ~/prj/hello-world/target/x86_64-pc-nto-qnx710/debug/hello-word
Now copy this file into QNX 7.1 OS (x86_64) target and run the hello-world

No comments:

Configuring TUN/TAP virtual network interface for use with QEMU on Xubuntu 24.04

Configuring TUN/TAP virtual network interface for use with QEMU on Xubuntu 24.04 I am planning to run qemu-system-ppc to play around QEMU ...