rustc: Avoid 16-byte filenames in rlibs

In addition to avoiding 16-byte filenames with bytecode files, this commit also
avoids 16-byte filenames with object files pulled in from native libraries.
This commit is contained in:
Alex Crichton 2014-06-05 15:31:45 -07:00
parent 6a43af3f84
commit 2290dbb8cc
2 changed files with 14 additions and 4 deletions

View File

@ -166,6 +166,15 @@ impl<'a> Archive<'a> {
if filename.contains(".SYMDEF") { continue }
let filename = format!("r-{}-{}", name, filename);
// LLDB (as mentioned in back::link) crashes on filenames of exactly
// 16 bytes in length. If we're including an object file with
// exactly 16-bytes of characters, give it some prefix so that it's
// not 16 bytes.
let filename = if filename.len() == 16 {
format!("lldb-fix-{}", filename)
} else {
filename
};
let new_filename = file.with_filename(filename);
try!(fs::rename(file, &new_filename));
inputs.push(new_filename);

View File

@ -958,10 +958,11 @@ fn link_rlib<'a>(sess: &'a Session,
// For LTO purposes, the bytecode of this library is also inserted
// into the archive.
// Note that we make sure that the bytecode filename in the archive is always at least
// 16 bytes long by adding a 16 byte extension to it. This is to work around a bug in
// LLDB that would cause it to crash if the name of a file in an archive was exactly
// 16 bytes.
//
// Note that we make sure that the bytecode filename in the archive
// is never exactly 16 bytes long by adding a 16 byte extension to
// it. This is to work around a bug in LLDB that would cause it to
// crash if the name of a file in an archive was exactly 16 bytes.
let bc = obj_filename.with_extension("bc");
let bc_deflated = obj_filename.with_extension("bytecode.deflate");
match fs::File::open(&bc).read_to_end().and_then(|data| {