From 63f58eef0d8f901565b9ed6d8646456541fe8841 Mon Sep 17 00:00:00 2001 From: Henrik Laxhuber Date: Sat, 21 Apr 2018 18:41:41 +0200 Subject: [PATCH] Changed LINKER env var to RUSTC_LINKER, improved docs --- src/cargo/core/compiler/custom_build.rs | 5 ++++- src/doc/src/reference/environment-variables.md | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index e1e5ce92a..cb08d4a70 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -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); } diff --git a/src/doc/src/reference/environment-variables.md b/src/doc/src/reference/environment-variables.md index 455687a02..305cb8901 100644 --- a/src/doc/src/reference/environment-variables.md +++ b/src/doc/src/reference/environment-variables.md @@ -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 -- 2.30.2