so what does this mean exactly? is rust suddenly out of thin air supported in aix? significant crates still missing aix support and https://github.com/smol-rs/polling/issues/89 has no pushes? this anouncement is somewhat missleading IMHO:
Original Message:
Sent: Fri June 07, 2024 11:06 AM
From: Aditya Kamath
Subject: RUST on AIX toolbox
RUST on AIX toolbox
Hi all,
Greetings from AIX toolbox team. We have released rust version 1.77.0 from AIX toolbox.
A brief description of rust programming language.
Rust is a systems programming language designed for performance, safety, and concurrency. Developed by Mozilla, it aims to provide memory safety without a garbage collector, thus preventing common bugs like null pointer dereferencing and buffer overflows. Rust is particularly used in developing operating systems, game engines, and web browsers due to its ability to handle low-level tasks efficiently. Its advantages include a robust type of system, ownership model, and strong compile-time checks, which ensure thread safety and eliminate data races. Rust's modern syntax and tooling also make it a preferred choice for developers seeking reliable and efficient codebases.
To install rust in your LPAR, one needs to have the following prerequisites:
1. A minimum 7.2 TL 5, SP3
2. Users needs to have the following three filesets:
a. libunwind.rte
To check the same, you can use:
# lslpp -i | grep libunwind
libunwind.rte 17.1.1.4
i. 5725-C7201 libunwind.rte
b. libc++
To check the same one can use:-
# lslpp -i | grep libc++
libc++.adt.include 17.1.1.4
i. 5725-C7201 libc++.adt
libc++.rte 17.1.1.4 5725-C7201 libc++.rte
libc++abi.rte 17.1.1.4
ii. 5725-C7201 libc++abi.rte
c. libbsd [Should exist by default]
To check the same one can use:-
ls -l /usr/lib/libbsd.a
To install Rust from the AIX toolbox run:
dnf install rust*
One should get the below 5 RPMS, which includes rust's package manager cargo as well.
1. rust-1.77.0-1.ppc [This RPM contains the main rustc binary, its man page and its dependent libraries/drivers]
2. rust-cargo-1.77.0-1.ppc [This RPM contains cargo binary, libraries and the man page of cargo. Cargo is the package manager for rust projects]
3. rust-debugger-common-1.77.0-1.noarch [This RPM contains the files used for debugging rust common to both GDB and LLDB]
4. rust-gdb-1.77.0-1.noarch [This RPM contains the files used for debugging rust using GDB]
5. rust-std-static-1.77.0-1.ppc [This RPM has the static libraries which implement the standard rust functions like println]
Note: Rust programs can be compiled in 64-bit mode only.
To run a simple rust program, run rustc <program_name>.rs . Post this, we can run the binary with name <program_name>.
For example, for the below program in Rust, we can do:
# cat test.rs
fn main() {
println!("Hello, world!");
}
# rustc test.rs
# ./test
Hello, world!
To build rust projects using cargo:
cd <project_name>
export CARGO_HOME=<path_to_install_binary>
cargo update
cargo build
cargo install --path .
CARGO_HOME is where the binary will be installed.
Note: The below flags are optional, for information only and need to be used if your project needs them. They need not be used to run simple programs.
Some important flags to set while building rust projects in AIX:
export CRATE_CC_NO_DEFAULTS=true #This switches off the default compiler flags.
export OBJECT_MODE=64 #rust can compile in 64 bit only.
export RUSTFLAGS="-C link-arg=-bbigtoc -L/opt/freeware/lib -D_ALL_SOURCE -lpython3.9" #One might need to link python or other libraries.
Other examples of standard flags:
export LIBPATH=/usr/local/lib:/opt/freeware/lib
export CC=gcc
export CFLAGS="-maix64 -I/usr/local/include -I/opt/freeware/include -D_ALL_SOURCE -std=c++17 -pthread"
export CXX=g++
export CXXFLAGS="-maix64 -I/usr/local/include -I/opt/freeware/include -D_ALL_SOURCE -std=c++17 -pthread"
If a RUST project has OpenSSL dependency, you may use the below flags:
export OPENSSL_DIR=/usr
export OPENSSL_STATIC=0
export OPENSSL_NO_VENDOR=1
If a RUST project has Zlib dependency, you may use the below flags:
export LIBZ_SYS_STATIC=0
export DEP_Z_INCLUDE=/opt/freeware/include
For any questions on rust or requests for packages that use rust in AIX toolbox, kindly let us know.
Have a nice day ahead.
Thanks and regards,
AIX toolbox team.
References:-
· More about rust and rust programming examples can be read at https://doc.rust-lang.org/book/
· More about Cargo can be read at https://doc.rust-lang.org/cargo/index.html
------------------------------
Aditya Kamath
------------------------------