Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Cargo's environment variables RUSTC and RUSTC_WRAPPER?

Cargo's environment variables are explained here.

  • RUSTC - Instead of running rustc, Cargo will execute this specified compiler instead.
  • RUSTC_WRAPPER - Instead of simply running rustc, Cargo will execute this specified wrapper instead, passing as its commandline arguments the rustc invocation, with the first argument being rustc.

RUSTC and RUSTC_WRAPPER variables look like they are doing the same thing. How are they different?

like image 762
eonil Avatar asked Oct 15 '25 20:10

eonil


1 Answers

As the documentation states:

  • If RUSTC is defined, Cargo will not execute this line:

    rustc <parameters>
    

    but this one:

    $RUSTC <parameters>
    

    That is like the variable CC in Makefiles to set an alternative compiler.

  • If RUSTC_WRAPPER is defined, Cargo will not call the compiler itself. It will instead call the following line:

    $RUSTC_WRAPPER rustc <parameters>
    

    You can add the options you want, or do whatever you want before the compilation, but you have to call the compiler yourself. Well, that's the purpose of a wrapper.

like image 163
Boiethios Avatar answered Oct 18 '25 00:10

Boiethios



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!