about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-06-05 15:31:45 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-06-06 19:51:19 -0700
commit2290dbb8cc9c72e1b6b64b7325430f031e2cd87b (patch)
tree9d26468fe10806fd6e28a124da0db6a95c8146dd
parent6a43af3f84ef97d4d0e5b55c5336a4256bd1ebb7 (diff)
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.
-rw-r--r--src/librustc/back/archive.rs9
-rw-r--r--src/librustc/back/link.rs9
2 files changed, 14 insertions, 4 deletions
diff --git a/src/librustc/back/archive.rs b/src/librustc/back/archive.rs
index edb0a538a03..4d921fb97dc 100644
--- a/src/librustc/back/archive.rs
+++ b/src/librustc/back/archive.rs
@@ -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);
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index b432034b81b..14369c7bbcd 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -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| {