Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc_trans: Append to PATH instead of prepending #31131

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,16 @@ pub fn get_ar_prog(sess: &Session) -> String {

fn command_path(sess: &Session) -> OsString {
// The compiler's sysroot often has some bundled tools, so add it to the
// PATH for the child.
let mut new_path = sess.host_filesearch(PathKind::All)
.get_tools_search_paths();
if let Some(path) = env::var_os("PATH") {
new_path.extend(env::split_paths(&path));
}
// PATH for the child. Be sure that we *append* to the PATH so we favor the
// system tools if they're configured and otherwise just fall back to the
// bundled versions.
let path = env::var_os("PATH").unwrap_or(OsString::new());
let mut new_path = env::split_paths(&path).collect::<Vec<_>>();
if sess.target.target.options.is_like_msvc {
new_path.extend(msvc::host_dll_path());
}
new_path.extend(sess.host_filesearch(PathKind::All)
.get_tools_search_paths());
env::join_paths(new_path).unwrap()
}

Expand Down