Changed LINKER env var to RUSTC_LINKER, improved docs
authorHenrik Laxhuber <henrik@laxhuber.com>
Sat, 21 Apr 2018 16:41:41 +0000 (18:41 +0200)
committerHenrik Laxhuber <henrik@laxhuber.com>
Sat, 21 Apr 2018 16:41:41 +0000 (18:41 +0200)
src/cargo/core/compiler/custom_build.rs
src/doc/src/reference/environment-variables.md

index e1e5ce92a63807a43946a227a46da4731c65d218..cb08d4a705da48960a16481f89f68dc2f2fce3f5 100644 (file)
@@ -144,9 +144,12 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes
         .env("HOST", &cx.build_config.host_triple())
         .env("RUSTC", &cx.build_config.rustc.path)
         .env("RUSTDOC", &*cx.config.rustdoc()?)
-        .env("LINKER", &cx.build_config.target.linker.as_ref().unwrap_or(&PathBuf::new()))
         .inherit_jobserver(&cx.jobserver);
 
+    if cx.build_config.target.linker.is_some() {
+        cmd.env("RUSTC_LINKER", &cx.build_config.target.linker.as_ref().unwrap());
+    }
+
     if let Some(links) = unit.pkg.manifest().links() {
         cmd.env("CARGO_MANIFEST_LINKS", links);
     }
index 455687a02b3a4c6e52edfa79a8d43676d8151fe1..305cb8901a05a5c33955862d4866fb7e668b2e41 100644 (file)
@@ -123,14 +123,18 @@ let out_dir = env::var("OUT_DIR").unwrap();
 * `RUSTC`, `RUSTDOC` - the compiler and documentation generator that Cargo has
                        resolved to use, passed to the build script so it might
                        use it as well.
-* `LINKER` - The linker that rust has resolved to use for the current target,
-             passed to the build script so it might use it as well.
+* `RUSTC_LINKER` - The path to the linker binary that Cargo has resolved to use
+                   for the current target, if specified. The linker can be
+                   changed by editing `.cargo/config`; see the documentation
+                   about [cargo configuration][cargo-config] for more
+                   information.
 
 [links]: reference/build-scripts.html#the-links-manifest-key
 [profile]: reference/manifest.html#the-profile-sections
 [configuration]: https://doc.rust-lang.org/reference/attributes.html#conditional-compilation
 [clang]: http://clang.llvm.org/docs/CrossCompilation.html#target-triple
 [jobserver]: https://www.gnu.org/software/make/manual/html_node/Job-Slots.html
+[cargo-config]: reference/config
 
 ### Environment variables Cargo sets for 3rd party subcommands