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 e500c08ce6e32..9db8e4a65a81a 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -253,6 +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: Vec<(String, String)> [TRACKED], debuginfo: DebugInfoLevel [TRACKED], lint_opts: Vec<(String, lint::Level)> [TRACKED], lint_cap: Option [TRACKED], @@ -445,6 +446,7 @@ pub fn basic_options() -> Options { libs: Vec::new(), unstable_features: UnstableFeatures::Disallow, debug_assertions: true, + debug_prefix_map: Vec::new(), actually_rustdoc: false, } } @@ -801,6 +803,8 @@ 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: 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"), panic: Option = (None, parse_panic_strategy, @@ -1423,6 +1427,18 @@ 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 = 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() { early_error(error_format, "-g and -C debuginfo both provided"); @@ -1539,6 +1555,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches) libs: libs, unstable_features: UnstableFeatures::from_environment(), debug_assertions: debug_assertions, + debug_prefix_map: debug_prefix_map, actually_rustdoc: false, }, cfg) @@ -1714,6 +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!(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 5022e0750e38e..db21c4ea442ec 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -657,19 +657,50 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, metadata } +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) { + // 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() +} + 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), + }; - file_metadata_(cx, path, file_name, &work_dir) + file_metadata_(cx, path, &remap_file_name, &remap_dir) } pub fn unknown_file_metadata(cx: &CrateContext) -> DIFile { @@ -759,7 +790,7 @@ pub fn compile_unit_metadata(scc: &SharedCrateContext, debug_context: &CrateDebugContext, sess: &Session) -> DIDescriptor { - let work_dir = &sess.working_dir; + let work_dir = sess.working_dir.to_str().unwrap(); let compile_unit_name = match sess.local_crate_source_file { None => fallback_path(scc), Some(ref abs_path) => { @@ -781,12 +812,14 @@ pub fn compile_unit_metadata(scc: &SharedCrateContext, } }; + let work_dir = remap_path(sess, None, None, work_dir); + debug!("compile_unit_metadata: {:?}", compile_unit_name); let producer = format!("rustc version {}", (option_env!("CFG_VERSION")).expect("CFG_VERSION")); let compile_unit_name = compile_unit_name.as_ptr(); - let work_dir = path2cstr(&work_dir); + let work_dir = CString::new(work_dir).unwrap(); let producer = CString::new(producer).unwrap(); let flags = "\0"; let split_name = "\0"; 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