Custom linker args for compiling the Cargo build script?

Hello!

I am wondering what is the best way to pass a linker arg when compiling a cargo build script itself?

Some background: I'm on a rather nonstandard Linux system (in fact, a Cray SUSE distro), and compiling Rust binaries is a bit tricky. With some help from the IRC, I've managed to compile regular binaries by calling cargo rustc with -C link-args="...". However I am unfortunately unaware of a way to pass a similar argument to cargo for compiling the build script itself, short of modifying the cargo source directly.

Does setting the RUSTFLAGS environment variable work? Based on its
documentation, it looks promising:
http://doc.crates.io/environment-variables.html

Cool, it works, thanks!

As an aside, the motivation for passing extra flags to the linker is that the (modified?) gcc 4.9 setup on my system doesn't quite like the cc linking invocation generated by rustc. It complains about "crtbeginT.o" in particular, but my understanding is that the linker should actually be using "crtbeginS.o" for PIEs like what rustc produces? Anyway, passing "-shared" to the linker seems to do the trick.