Skip to content
Permalink
Browse files

Support VS 2017

Fixes #38584
  • Loading branch information
brson committed Jun 1, 2017
1 parent f89d8d1 commit da100fe0bb7ba77dbcc346018068dbfdba053f6b

Some generated files are not rendered by default. Learn more.

@@ -36,5 +36,5 @@ num_cpus = "1.0"
toml = "0.1"
getopts = "0.2"
rustc-serialize = "0.3"
gcc = "0.3.46"
gcc = "0.3.50"
libc = "0.2"
@@ -17,7 +17,7 @@ libc = { path = "../rustc/libc_shim" }

[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3.27"
gcc = "0.3.50"

[features]
debug = []
@@ -16,4 +16,4 @@ core = { path = "../libcore" }

[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3.27"
gcc = "0.3.50"
@@ -11,4 +11,4 @@ crate-type = ["dylib"]

[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3.27"
gcc = "0.3.50"
@@ -17,4 +17,4 @@ rustc_bitflags = { path = "../librustc_bitflags" }

[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3.27"
gcc = "0.3.50"
@@ -25,3 +25,6 @@ rustc_platform_intrinsics = { path = "../librustc_platform_intrinsics" }
serialize = { path = "../libserialize" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }

[target."cfg(windows)".dependencies]
gcc = "0.3.50"
@@ -12,7 +12,6 @@ use super::archive::{ArchiveBuilder, ArchiveConfig};
use super::linker::Linker;
use super::rpath::RPathConfig;
use super::rpath;
use super::msvc;
use metadata::METADATA_FILENAME;
use rustc::session::config::{self, NoDebugInfo, OutputFilenames, Input, OutputType};
use rustc::session::filesearch;
@@ -142,20 +141,41 @@ pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap) -> LinkMet
return r;
}

// The third parameter is for an extra path to add to PATH for MSVC
// cross linkers for host toolchain DLL dependencies
pub fn get_linker(sess: &Session) -> (String, Command, Option<PathBuf>) {
// The third parameter is for an env vars, used to set up the path for MSVC
// to find its DLLs
pub fn get_linker(sess: &Session) -> (String, Command, Vec<(OsString, OsString)>) {
if let Some(ref linker) = sess.opts.cg.linker {
(linker.clone(), Command::new(linker), None)
(linker.clone(), Command::new(linker), vec![])
} else if sess.target.target.options.is_like_msvc {
let (cmd, host) = msvc::link_exe_cmd(sess);
("link.exe".to_string(), cmd, host)
let (cmd, envs) = msvc_link_exe_cmd(sess);
("link.exe".to_string(), cmd, envs)
} else {
(sess.target.target.options.linker.clone(),
Command::new(&sess.target.target.options.linker), None)
Command::new(&sess.target.target.options.linker), vec![])
}
}

#[cfg(windows)]
pub fn msvc_link_exe_cmd(sess: &Session) -> (Command, Vec<(OsString, OsString)>) {
use gcc::windows_registry;

let target = &sess.opts.target_triple;
let tool = windows_registry::find_tool(target, "link.exe");

if let Some(tool) = tool {
let envs = tool.env().to_vec();
(tool.to_command(), envs)
} else {
debug!("Failed to locate linker.");
(Command::new("link.exe"), vec![])
}
}

#[cfg(not(windows))]
pub fn msvc_link_exe_cmd(_sess: &Session) -> (Command, Vec<(OsString, OsString)>) {
(Command::new("link.exe"), vec![])
}

pub fn get_ar_prog(sess: &Session) -> String {
sess.opts.cg.ar.clone().unwrap_or_else(|| {
sess.target.target.options.ar.clone()
@@ -706,8 +726,9 @@ fn link_natively(sess: &Session,
let flavor = sess.linker_flavor();

// The invocations of cc share some flags across platforms
let (pname, mut cmd, extra) = get_linker(sess);
cmd.env("PATH", command_path(sess, extra));
let (pname, mut cmd, envs) = get_linker(sess);
// This will set PATH on MSVC
cmd.envs(envs);

let root = sess.target_filesearch(PathKind::Native).get_lib_path();
if let Some(args) = sess.target.target.options.pre_link_args.get(&flavor) {

This file was deleted.

0 comments on commit da100fe

Please sign in to comment.
You can’t perform that action at this time.