debug!(?support_lib_deps);
debug!(?support_lib_deps_deps);
+ let mut host_dylib_env_paths = String::new();
+ host_dylib_env_paths.push_str(&cwd.join(&self.config.compile_lib_path).to_string_lossy());
+ host_dylib_env_paths.push(':');
+ host_dylib_env_paths.push_str(&env::var(dylib_env_var()).unwrap());
+
let res = self.cmd2procres(
Command::new(&self.config.rustc_path)
.arg("-o")
.env("RUSTC", cwd.join(&self.config.rustc_path))
.env("TMPDIR", &tmpdir)
.env("LD_LIB_PATH_ENVVAR", dylib_env_var())
+ .env(dylib_env_var(), &host_dylib_env_paths)
.env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path))
.env("TARGET_RPATH_DIR", cwd.join(&self.config.run_lib_path))
.env("LLVM_COMPONENTS", &self.config.llvm_components)
fn setup_common_build_cmd() -> Command {
let rustc = env::var("RUSTC").unwrap();
let mut cmd = Command::new(rustc);
+ set_host_rpath(&mut cmd);
cmd.arg("--out-dir").arg(out_dir()).arg("-L").arg(out_dir());
cmd
}
std::process::exit(1)
}
+/// Set the runtime library path as needed for running the host rustc/rustdoc/etc.
+pub fn set_host_rpath(cmd: &mut Command) {
+ let ld_lib_path_envvar = env::var("LD_LIB_PATH_ENVVAR").unwrap();
+ cmd.env(&ld_lib_path_envvar, {
+ let mut paths = vec![];
+ paths.push(PathBuf::from(env::var("TMPDIR").unwrap()));
+ paths.push(PathBuf::from(env::var("HOST_RPATH_DIR").unwrap()));
+ for p in env::split_paths(&env::var(&ld_lib_path_envvar).unwrap()) {
+ paths.push(p.to_path_buf());
+ }
+ env::join_paths(paths.iter()).unwrap()
+ });
+}
+
pub fn rustc() -> RustcInvocationBuilder {
RustcInvocationBuilder::new()
}