diff --git a/src/liblibc b/src/liblibc index 0ac39c5ccf6a0..7d57bdcdbb565 160000 --- a/src/liblibc +++ b/src/liblibc @@ -1 +1 @@ -Subproject commit 0ac39c5ccf6a04395b7c40dd62321cb91f63f160 +Subproject commit 7d57bdcdbb56540f37afe5a934ce12d33a6ca7fc diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 385cb13c30a84..9db8e4a65a81a 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -253,7 +253,7 @@ top_level_options!( // Include the debug_assertions flag into dependency tracking, since it // can influence whether overflow checks are done or not. debug_assertions: bool [TRACKED], - debug_prefix_map: Option<(String, String)> [TRACKED], + debug_prefix_map: Vec<(String, String)> [TRACKED], debuginfo: DebugInfoLevel [TRACKED], lint_opts: Vec<(String, lint::Level)> [TRACKED], lint_cap: Option [TRACKED], @@ -446,7 +446,7 @@ pub fn basic_options() -> Options { libs: Vec::new(), unstable_features: UnstableFeatures::Disallow, debug_assertions: true, - debug_prefix_map: None, + debug_prefix_map: Vec::new(), actually_rustdoc: false, } } @@ -803,7 +803,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options, "optimize with possible levels 0-3, s, or z"), debug_assertions: Option = (None, parse_opt_bool, [TRACKED], "explicitly enable the cfg(debug_assertions) directive"), - debug_prefix_map: String = ("".to_string(), parse_string, [TRACKED], + debug_prefix_map: Vec = (vec![], parse_string_push, [TRACKED], "remap OLD to NEW in debug info (OLD=NEW)"), inline_threshold: Option = (None, parse_opt_uint, [TRACKED], "set the inlining threshold for"), @@ -1428,18 +1428,16 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches) }; let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No); - let debug_prefix_map = if !cg.debug_prefix_map.is_empty() { - let mut parts = cg.debug_prefix_map.splitn(2, '='); - let old = parts.next().unwrap(); - let new = match parts.next() { - Some(new) => new, - None => early_error(error_format, - "-C debug-prefix-map value must be of the format `OLD=NEW`"), - }; - Some((old.to_string(), new.to_string())) - } else { - None - }; + let debug_prefix_map = cg.debug_prefix_map.iter() + .map(|m| { + let parts = m.splitn(2, '=').collect::>(); + if parts.len() != 2 { + early_error(error_format, + "-C debug-prefix-map value must be of the format `OLD=NEW`") + } + (parts[0].to_string(), parts[1].to_string()) + }) + .collect(); let debuginfo = if matches.opt_present("g") { if cg.debuginfo.is_some() { @@ -1733,7 +1731,7 @@ mod dep_tracking { impl_dep_tracking_hash_via_hash!(Option); impl_dep_tracking_hash_via_hash!(Option); impl_dep_tracking_hash_via_hash!(Option); - impl_dep_tracking_hash_via_hash!(Option<(String, String)>); + impl_dep_tracking_hash_via_hash!(Vec<(String, String)>); impl_dep_tracking_hash_via_hash!(Option); impl_dep_tracking_hash_via_hash!(Option); impl_dep_tracking_hash_via_hash!(Option); diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index a16236fb9aee2..db21c4ea442ec 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -657,10 +657,24 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, metadata } -fn remap_path(sess: &Session, path: &str) -> String { - for (old, new) in sess.opts.debug_prefix_map.clone() { +fn remap_path(sess: &Session, dir: Option<&str>, remap_dir: Option<&str>, path: &str) -> String { + for &(ref old, ref new) in &sess.opts.debug_prefix_map { + // If `old` is not absolute and we've been given a dir, add the dir to make + // it absolute. Otherwise use `old` as-is. + let old = if dir.is_none() || Path::new(old).is_absolute() { + old.to_string() + } else { + format!("{}/{}", dir.unwrap(), old) + }; if path.starts_with(&old) { - return new + &path[old.len()..]; + // Likewise, add `remap_dir` to new if we have one and `new` isn't absolute. + let mut ret = if remap_dir.is_none() || Path::new(new).is_absolute() { + new.to_string() + } else { + format!("{}/{}", remap_dir.unwrap(), new) + }; + ret.push_str(&path[old.len()..]); + return ret; } } path.to_string() @@ -669,18 +683,23 @@ fn remap_path(sess: &Session, path: &str) -> String { pub fn file_metadata(cx: &CrateContext, path: &str, full_path: &Option) -> DIFile { // FIXME (#9639): This needs to handle non-utf8 paths let work_dir = cx.sess().working_dir.to_str().unwrap(); - let file_name = - full_path.as_ref().map(|p| p.as_str()).unwrap_or_else(|| { - if path.starts_with(work_dir) { + let sess = cx.sess(); + let remap_dir = remap_path(sess, None, None, work_dir); + + let remap_file_name = match full_path { + &None => { + // Huh: return a relative path? + let p = if path.starts_with(work_dir) { &path[work_dir.len() + 1..path.len()] } else { path - } - }); + }; + remap_path(sess, None, None, p) + }, + // Huh: return an absolute path? + &Some(ref full) => remap_path(sess, Some(work_dir), Some(&remap_dir), full), + }; - let sess = cx.sess(); - let remap_file_name = remap_path(sess, file_name); - let remap_dir = remap_path(sess, work_dir); file_metadata_(cx, path, &remap_file_name, &remap_dir) } @@ -793,7 +812,7 @@ pub fn compile_unit_metadata(scc: &SharedCrateContext, } }; - let work_dir = remap_path(sess, work_dir); + let work_dir = remap_path(sess, None, None, work_dir); debug!("compile_unit_metadata: {:?}", compile_unit_name); let producer = format!("rustc version {}", diff --git a/src/llvm b/src/llvm index d7342a9a95747..ceb177eeefa7d 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit d7342a9a957470bb62c890cf88fc655ccfb755cc +Subproject commit ceb177eeefa7d67ca29230d2e7e8584f97d4fdad