Fix review comments and other improvements
This commit is contained in:
parent
d63a067bfd
commit
db68a19b61
6 changed files with 34 additions and 24 deletions
|
@ -108,8 +108,8 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
|
||||||
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder + 'a> {
|
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder + 'a> {
|
||||||
// Keeping LlvmArchiveBuilder around in case of a regression caused by using
|
// Keeping LlvmArchiveBuilder around in case of a regression caused by using
|
||||||
// ArArchiveBuilder.
|
// ArArchiveBuilder.
|
||||||
// FIXME remove a couple of months after #128936 gets merged in case no
|
// FIXME(#128955) remove a couple of months after #128936 gets merged in case
|
||||||
// regression is found.
|
// no regression is found.
|
||||||
if false {
|
if false {
|
||||||
Box::new(LlvmArchiveBuilder { sess, additions: Vec::new() })
|
Box::new(LlvmArchiveBuilder { sess, additions: Vec::new() })
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -308,10 +308,8 @@ impl<'a> ArchiveBuilder for ArArchiveBuilder<'a> {
|
||||||
.map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err))?;
|
.map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err))?;
|
||||||
if !skip(&file_name) {
|
if !skip(&file_name) {
|
||||||
if entry.is_thin() {
|
if entry.is_thin() {
|
||||||
self.entries.push((
|
let member_path = archive_path.parent().unwrap().join(Path::new(&file_name));
|
||||||
file_name.clone().into_bytes(),
|
self.entries.push((file_name.into_bytes(), ArchiveEntry::File(member_path)));
|
||||||
ArchiveEntry::File(PathBuf::from(file_name)),
|
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
self.entries.push((
|
self.entries.push((
|
||||||
file_name.into_bytes(),
|
file_name.into_bytes(),
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
#[link(name = "rust_archive", kind = "static")]
|
|
||||||
extern "C" {
|
|
||||||
fn simple_fn();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
simple_fn();
|
rust_lib::simple_fn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,28 @@
|
||||||
// Regression test for https://github.com/rust-lang/rust/issues/107407
|
// Regression test for https://github.com/rust-lang/rust/issues/107407 which
|
||||||
|
// checks that rustc can read thin archive. Before the object crate added thin
|
||||||
|
// archive support rustc would add emit object files to the staticlib and after
|
||||||
|
// the object crate added thin archive support it would previously crash the
|
||||||
|
// compiler due to a missing special case for thin archive members.
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
use run_make_support::{llvm_ar, rustc, static_lib_name};
|
use run_make_support::{llvm_ar, rust_lib_name, rustc, static_lib_name};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
rustc().input("simple_obj.rs").emit("obj").run();
|
std::fs::create_dir("archive").unwrap();
|
||||||
llvm_ar().obj_to_thin_ar().output_input(static_lib_name("thin_archive"), "simple_obj.o").run();
|
|
||||||
rustc().input("rust_archive.rs").run();
|
// Build a thin archive
|
||||||
// Disable lld as it ignores the symbol table in the archive file.
|
rustc().input("simple_obj.rs").emit("obj").output("archive/simple_obj.o").run();
|
||||||
rustc()
|
llvm_ar()
|
||||||
.input("bin.rs") /*.arg("-Zlinker-features=-lld")*/
|
.obj_to_thin_ar()
|
||||||
|
.output_input(
|
||||||
|
Path::new("archive").join(static_lib_name("thin_archive")),
|
||||||
|
"archive/simple_obj.o",
|
||||||
|
)
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
|
// Build an rlib which includes the members of this thin archive
|
||||||
|
rustc().input("rust_lib.rs").library_search_path("archive").run();
|
||||||
|
|
||||||
|
// Build a binary which requires a symbol from the thin archive
|
||||||
|
rustc().input("bin.rs").extern_("rust_lib", rust_lib_name("rust_lib")).run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
#![crate_type = "staticlib"]
|
|
||||||
|
|
||||||
#[link(name = "thin_archive", kind = "static")]
|
|
||||||
extern "C" {}
|
|
6
tests/run-make/staticlib-thin-archive/rust_lib.rs
Normal file
6
tests/run-make/staticlib-thin-archive/rust_lib.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#![crate_type = "rlib"]
|
||||||
|
|
||||||
|
#[link(name = "thin_archive", kind = "static")]
|
||||||
|
extern "C" {
|
||||||
|
pub fn simple_fn();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue