utsaslab / rustfs

A Rust user-space file system [WIP]
Other
28 stars 7 forks source link

Using RUSTFLAGS to do linking instead of .cargo/config #14

Closed djarotech closed 6 years ago

djarotech commented 6 years ago

name: Using RUSTFLAGS to do linking instead of .cargo/config about: Using RUSTFLAGS environmental variable that cargo reads from, to link to the libspdk.so so that it is able to compile and run.


Problem Description https://github.com/utsaslab/rustfs/issues/13

Solution Using .cargo/config is redundant, I have removed this file and enforced usage of RUSTFLAGS environmental variable. Since the .cargo/config does not allow environmental variables, except for some predefined list. To run it with this modification, need to set the RUSTFLAGS environmental variable to add a link arg pointing to the libspdk.so. Please ensure that libspdk.so exists in the $SPDK_INSTALL_DIR/lib directory. If it does not exist, copy it into this location, from spdk repo (e.g. $HOME/spdk/build/lib/libspdk.so).

$ export SPDK_INSTALL_DIR=$HOME/spdk_install
$ export RUSTFLAGS="-C link-arg=$SPDK_INSTALL_DIR/lib/libspdk.so"
$ sudo -E $HOME/.cargo/bin/cargo run

Verification To verify, I ran cargo run, in hello_nvme_bdev_rust and received the identical output as the configuration with the .cargo/config.

References https://rurust.github.io/cargo-docs-ru/environment-variables.html https://doc.rust-lang.org/cargo/reference/environment-variables.html

djarotech commented 6 years ago

Ok, sure.