Add test for thin archive reading support

This commit is contained in:
bjorn3 2024-08-10 17:43:22 +00:00
parent 4f8042e22e
commit a57f73d320
5 changed files with 37 additions and 0 deletions

View File

@ -271,6 +271,12 @@ impl LlvmAr {
self
}
/// Like `obj_to_ar` except creating a thin archive.
pub fn obj_to_thin_ar(&mut self) -> &mut Self {
self.cmd.arg("rcus").arg("--thin");
self
}
/// Extract archive members back to files.
pub fn extract(&mut self) -> &mut Self {
self.cmd.arg("x");

View File

@ -0,0 +1,10 @@
#[link(name = "rust_archive", kind = "static")]
extern "C" {
fn simple_fn();
}
fn main() {
unsafe {
simple_fn();
}
}

View File

@ -0,0 +1,13 @@
// Regression test for https://github.com/rust-lang/rust/issues/107407
use run_make_support::{llvm_ar, rustc, static_lib_name};
fn main() {
rustc().input("simple_obj.rs").emit("obj").run();
llvm_ar().obj_to_thin_ar().output_input(static_lib_name("thin_archive"), "simple_obj.o").run();
rustc().input("rust_archive.rs").run();
// Disable lld as it ignores the symbol table in the archive file.
rustc()
.input("bin.rs") /*.arg("-Zlinker-features=-lld")*/
.run();
}

View File

@ -0,0 +1,4 @@
#![crate_type = "staticlib"]
#[link(name = "thin_archive", kind = "static")]
extern "C" {}

View File

@ -0,0 +1,4 @@
#![crate_type = "staticlib"]
#[no_mangle]
extern "C" fn simple_fn() {}