Move Compiler - set stdlib root


The Move compiler can not run on other computer because of the stdlib root has been set when rust gens the compiler.

I make a PR to set stdlib root, then compiler can run on the other computer with stdlib folder.


  1. cargo build --bin compiler
  2. run compiler on other computer
$ ./compiler ~/hello.mvir
thread 'main' panicked at 'Unable to read file: "/Volumes/backup/repos/libra/language/stdlib/modules/hash.mvir"', language/compiler/src/
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
  1. with this PR
$ ./compiler --stdlib-root ~/repos/bcx/libra/language/stdlib/ ~/hello.mvir



Very nice! :ok_hand: has support compile Move contract locally.

0.0.9 has been released.

Hi @yinjimmy,

Thanks for bringing this up! I had a discussion with the team and we all welcome this change. Right now we do not merge pull requests unless they are tiny, but I’ll port/reimplement your changes manually and credit you – most likely in the commit message. (Taking my words back for now. Checking with the team on how we’ll do this.) There’s also some related cleanup we’d like to do together with this.

Again good catch and thanks for your contribution!

1 Like

Hi Victor, glad to help! Please let me know how the clean up goes.

Hi vgao,
how is the cleanup going ?

I think we can use -L to add library searching path. such as gcc -L option.

Then compiler can search stdlib/modules/hash.mvir with every library path.

function find_mvirs(mvirs):
    ret = []
    for mvir in mvirs:
        for path in lib_paths:
            if path.exists: ret.append(path)
    return ret

# build stdlib
function build_stdlib:
    for mvir in find_mvirs(["stdlib/modules/hash.mvir", ...]):

// build stdio
function build_stdio:
    for mvir in find_mvirs(["stdio/modules/hash.mvir", ...]):


./compiler -L ~/repos/bcx/libra/language/stdlib/ -L ~/repos/bcx/libra/language/others_lib ~/hello.mvir

# or 
./compiler -L~/repos/bcx/libra/language/stdlib/ -L~/repos/bcx/libra/language/others_lib ~/hello.mvir

is it ok?

maybe -I is better.

Hi @vgao, how is it going?
Does it support set stdlib root path?