Change:
No destdir is passed to in
That causes fail in Gentoo build
As far as I understand, we need to to pass to function and add value of to prefix here

Discussion:
cargo.env("CFG_RELEASE", &build.release) .env("CFG_RELEASE_CHANNEL", &build.config.channel) .env("CFG_VERSION", &build.version) <del> .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or(String::new())) </del> <ins> .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or(PathBuf::new())) </ins> .env("CFG_LIBDIR_RELATIVE", "lib"); if let Some(ref ver_date) = build.ver_date {

pub quiet_tests: bool, // Fallback musl-root for all targets pub musl_root: Option<PathBuf>, <del> pub prefix: Option<String>, pub docdir: Option<String>, pub libdir: Option<String>, pub mandir: Option<String>, </del> <ins> pub prefix: Option<PathBuf>, pub docdir: Option<PathBuf>, pub libdir: Option<PathBuf>, pub mandir: Option<PathBuf>, </ins> pub codegen_tests: bool, pub nodejs: Option<PathBuf>, pub gdb: Option<PathBuf>,

#[derive(RustcDecodable, Default, Clone)] struct Install { prefix: Option<String>, <ins> mandir: Option<String>, docdir: Option<String>, libdir: Option<String>, </ins> } /// TOML representation of how the LLVM build is configured.

set(&mut config.vendor, build.vendor); if let Some(ref install) = toml.install { <del> config.prefix = install.prefix.clone(); </del> <ins> config.prefix = install.prefix.clone().map(PathBuf::from); config.mandir = install.mandir.clone().map(PathBuf::from); config.docdir = install.docdir.clone().map(PathBuf::from); config.libdir = install.libdir.clone().map(PathBuf::from); </ins> } if let Some(ref llvm) = toml.llvm {

self.channel = value.to_string(); } "CFG_PREFIX" => { <del> self.prefix = Some(value.to_string()); </del> <ins> self.prefix = Some(PathBuf::from(value)); </ins> } "CFG_DOCDIR" => { <del> self.docdir = Some(value.to_string()); </del> <ins> self.docdir = Some(PathBuf::from(value)); </ins> } "CFG_LIBDIR" => { <del> self.libdir = Some(value.to_string()); </del> <ins> self.libdir = Some(PathBuf::from(value)); </ins> } "CFG_MANDIR" => { <del> self.mandir = Some(value.to_string()); </del> <ins> self.mandir = Some(PathBuf::from(value)); </ins> } "CFG_LLVM_ROOT" if value.len() > 0 => { let target = self.target_config.entry(self.build.clone())

[install] # Instead of installing to /usr/local, install to this path instead. <del> #prefix = "/path/to/install" </del> <ins> #prefix = "/usr/local" # Where to install libraries in `prefix` above #libdir = "lib" # Where to install man pages in `prefix` above #mandir = "share/man" # Where to install documentation in `prefix` above #docdir = "share/doc/rust" </ins> # ============================================================================= # Options for compiling Rust code itself

//! This module is responsible for installing the standard library, //! compiler, and documentation. <ins> use std::env; </ins> use std::fs; <del> use std::borrow::Cow; use std::path::Path; </del> <ins> use std::path::{Path, PathBuf, Component}; </ins> use std::process::Command; use Build;

/// Installs everything. pub fn install(build: &Build, stage: u32, host: &str) { <del> let prefix = build.config.prefix.as_ref().clone().map(|x| Path::new(x)) .unwrap_or(Path::new("/usr/local")); let docdir = build.config.docdir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x))) .unwrap_or(Cow::Owned(prefix.join("share/doc/rust"))); let libdir = build.config.libdir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x))) .unwrap_or(Cow::Owned(prefix.join("lib"))); let mandir = build.config.mandir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x))) .unwrap_or(Cow::Owned(prefix.join("share/man"))); </del> <ins> let prefix_default = PathBuf::from("/usr/local"); let docdir_default = PathBuf::from("share/doc/rust"); let mandir_default = PathBuf::from("share/man"); let libdir_default = PathBuf::from("lib"); let prefix = build.config.prefix.as_ref().unwrap_or(&prefix_default); let docdir = build.config.docdir.as_ref().unwrap_or(&docdir_default); let libdir = build.config.libdir.as_ref().unwrap_or(&libdir_default); let mandir = build.config.mandir.as_ref().unwrap_or(&mandir_default); let docdir = prefix.join(docdir); let libdir = prefix.join(libdir); let mandir = prefix.join(mandir); let destdir = env::var_os("DESTDIR").map(PathBuf::from); let prefix = add_destdir(&prefix, &destdir); let docdir = add_destdir(&docdir, &destdir); let libdir = add_destdir(&libdir, &destdir); let mandir = add_destdir(&mandir, &destdir); </ins> let empty_dir = build.out.join("tmp/empty_dir"); t!(fs::create_dir_all(&empty_dir)); if build.config.docs { <del> install_sh(&build, "docs", "rust-docs", stage, host, prefix, </del> <ins> install_sh(&build, "docs", "rust-docs", stage, host, &prefix, </ins> &docdir, &libdir, &mandir, &empty_dir); } <del> install_sh(&build, "std", "rust-std", stage, host, prefix, </del> <ins> install_sh(&build, "std", "rust-std", stage, host, &prefix, </ins> &docdir, &libdir, &mandir, &empty_dir); <del> install_sh(&build, "rustc", "rustc", stage, host, prefix, </del> <ins> install_sh(&build, "rustc", "rustc", stage, host, &prefix, </ins> &docdir, &libdir, &mandir, &empty_dir); t!(fs::remove_dir_all(&empty_dir)); }

.arg("--disable-ldconfig"); build.run(&mut cmd); } <ins> fn add_destdir(path: &Path, destdir: &Option<PathBuf>) -> PathBuf { let mut ret = match *destdir { Some(ref dest) => dest.clone(), None => return path.to_path_buf(), }; for part in path.components() { match part { Component::Normal(s) => ret.push(s), _ => {} } } return ret } </ins>