Go FFI to call C and Rust code.
Install linux amd64 toolchain target:
rustup target add x86_64-unknown-linux-gnu
# install pre build cross compiling tool
brew install SergioBenitez/osxct/x86_64-unknown-linux-gnu
To cross compile we need to set some environment variable CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER:
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-unknown-linux-gnu-gcc cargo build --target=x86_64-unknown-linux-gnu
To check memory usage for a program
ps -o rss= -C $pname | awk '{print $1/1024" MB"}'