This commit is contained in:
bjorn3 2019-06-11 16:59:42 +02:00
parent 07bb89a02d
commit 44a3550799
2 changed files with 1 additions and 46 deletions

View File

@ -1,45 +0,0 @@
//! ```cargo
//! [dependencies]
//! ar = "0.6.2"
//! ```
use std::io::Read;
// 64 gives Invalid file size field in entry header
// 32 gives unexpected EOF in the middle of archive entry header
const METADATA_LEN: usize = 64;
fn main() {
let mut builder = ar::Builder::new(std::fs::File::create("test.a").expect("create"));
// Remove this append and there is no problem.
let header = ar::Header::new(b"core-fc675.rcgu.o".to_vec(), 0);
// Remove any of the characters in the filename and ! from will show up in the error message.
// Making it shorter than 17 chars will fix the problem though.
builder.append(&header, &mut (&[] as &[u8])).expect("add rcgu");
let mut buf: Vec<u8> = vec!['!' as u8; 28];
buf.extend(b"hello worl");
buf.extend(&['*' as u8; 26] as &[u8]);
assert!(buf.len() >= METADATA_LEN);
let header = ar::Header::new(b"rust.metadata.bin".to_vec(), METADATA_LEN as u64);
builder.append(&header, &mut (&buf[0..METADATA_LEN])).expect("add meta");
std::mem::drop(builder);
// Remove this ranlib invocation and there is no problem.
/*assert!(
std::process::Command::new("ranlib")
.arg("test.a")
.status()
.expect("Couldn't run ranlib")
.success()
);*/
let mut archive = ar::Archive::new(std::fs::File::open("test.a").expect("open"));
while let Some(entry) = archive.next_entry() {
entry.unwrap();
}
}

View File

@ -5,7 +5,7 @@ rm -r target/out || true
mkdir -p target/out/clif
echo "[BUILD] mini_core"
$RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib -Csave-temps
$RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib
echo "[BUILD] example"
$RUSTC example/example.rs --crate-type lib