Skip to content

Support VS 2017 #42225

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

Merged
merged 1 commit into from
Jun 3, 2017
Merged
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
35 changes: 18 additions & 17 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion src/liballoc_jemalloc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 = []
2 changes: 1 addition & 1 deletion src/libcompiler_builtins/Cargo.toml
Original file line number Diff line number Diff line change
@@ -16,4 +16,4 @@ core = { path = "../libcore" }

[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3.27"
gcc = "0.3.50"
2 changes: 1 addition & 1 deletion src/libflate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -11,4 +11,4 @@ crate-type = ["dylib"]

[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3.27"
gcc = "0.3.50"
2 changes: 1 addition & 1 deletion src/librustc_llvm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -17,4 +17,4 @@ rustc_bitflags = { path = "../librustc_bitflags" }

[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3.27"
gcc = "0.3.50"
3 changes: 3 additions & 0 deletions src/librustc_trans/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
41 changes: 31 additions & 10 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
@@ -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) {
56 changes: 0 additions & 56 deletions src/librustc_trans/back/msvc/arch.rs

This file was deleted.

305 changes: 0 additions & 305 deletions src/librustc_trans/back/msvc/mod.rs

This file was deleted.

136 changes: 0 additions & 136 deletions src/librustc_trans/back/msvc/registry.rs

This file was deleted.

6 changes: 4 additions & 2 deletions src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@
#![feature(slice_patterns)]
#![feature(unicode)]
#![feature(conservative_impl_trait)]
#![feature(command_envs)]

#![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
#![cfg_attr(stage0, feature(rustc_private))]
@@ -62,6 +63,8 @@ extern crate rustc_bitflags;
extern crate syntax_pos;
extern crate rustc_errors as errors;
extern crate serialize;
#[cfg(windows)]
extern crate gcc; // Used to locate MSVC, not gcc :)

pub use base::trans_crate;
pub use back::symbol_names::provide;
@@ -77,8 +80,7 @@ pub mod back {
pub(crate) mod symbol_export;
pub(crate) mod symbol_names;
pub mod write;
mod msvc;
mod rpath;
pub mod rpath;
}

mod diagnostics;
2 changes: 1 addition & 1 deletion src/librustdoc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -30,4 +30,4 @@ pulldown-cmark = { version = "0.0.14", default-features = false }

[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3.27"
gcc = "0.3.50"
2 changes: 1 addition & 1 deletion src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ rustc_tsan = { path = "../librustc_tsan" }

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

[features]
backtrace = []