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

Fix wrong directories in PATH on Windows #7482

Merged
merged 1 commit into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
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
43 changes: 22 additions & 21 deletions src/cargo/core/compiler/build_context/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ pub struct TargetInfo {
crate_types: RefCell<HashMap<String, Option<(String, String)>>>,
/// `cfg` information extracted from `rustc --print=cfg`.
cfg: Vec<Cfg>,
/// Path to the "lib" directory in the sysroot.
pub sysroot_libdir: PathBuf,
/// Path to the "lib" or "bin" directory that rustc uses for its dynamic
/// libraries.
pub sysroot_host_libdir: PathBuf,
/// Path to the "lib" directory in the sysroot which rustc uses for linking
/// target libraries.
pub sysroot_target_libdir: PathBuf,
/// Extra flags to pass to `rustc`, see `env_args`.
pub rustflags: Vec<String>,
/// Extra flags to pass to `rustdoc`, see `env_args`.
Expand Down Expand Up @@ -127,24 +131,20 @@ impl TargetInfo {
output_err_info(&process, &output, &error)
),
};
let mut rustlib = PathBuf::from(line);
let sysroot_libdir = match kind {
CompileKind::Host => {
if cfg!(windows) {
rustlib.push("bin");
} else {
rustlib.push("lib");
}
rustlib
}
CompileKind::Target(target) => {
rustlib.push("lib");
rustlib.push("rustlib");
rustlib.push(target.short_name());
rustlib.push("lib");
rustlib
}
};
let mut sysroot_host_libdir = PathBuf::from(line);
if cfg!(windows) {
sysroot_host_libdir.push("bin");
} else {
sysroot_host_libdir.push("lib");
}
let mut sysroot_target_libdir = PathBuf::from(line);
sysroot_target_libdir.push("lib");
sysroot_target_libdir.push("rustlib");
sysroot_target_libdir.push(match &kind {
CompileKind::Host => rustc.host.as_str(),
CompileKind::Target(target) => target.short_name(),
});
sysroot_target_libdir.push("lib");

let cfg = lines
.map(|line| Ok(Cfg::from_str(line)?))
Expand All @@ -159,7 +159,8 @@ impl TargetInfo {
Ok(TargetInfo {
crate_type_process,
crate_types: RefCell::new(map),
sysroot_libdir,
sysroot_host_libdir,
sysroot_target_libdir,
// recalculate `rustflags` from above now that we have `cfg`
// information
rustflags: env_args(
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ impl<'cfg> Compilation<'cfg> {
root_output: PathBuf::from("/"),
deps_output: PathBuf::from("/"),
host_deps_output: PathBuf::from("/"),
host_dylib_path: bcx.info(CompileKind::Host).sysroot_libdir.clone(),
target_dylib_path: bcx.info(default_kind).sysroot_libdir.clone(),
host_dylib_path: bcx.info(default_kind).sysroot_host_libdir.clone(),
target_dylib_path: bcx.info(default_kind).sysroot_target_libdir.clone(),
tests: Vec::new(),
binaries: Vec::new(),
extra_env: HashMap::new(),
Expand Down