Skip to content

Commit a57f73d

Browse files
committed
Add test for thin archive reading support
1 parent 4f8042e commit a57f73d

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

src/tools/run-make-support/src/external_deps/llvm.rs

+6
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ impl LlvmAr {
271271
self
272272
}
273273

274+
/// Like `obj_to_ar` except creating a thin archive.
275+
pub fn obj_to_thin_ar(&mut self) -> &mut Self {
276+
self.cmd.arg("rcus").arg("--thin");
277+
self
278+
}
279+
274280
/// Extract archive members back to files.
275281
pub fn extract(&mut self) -> &mut Self {
276282
self.cmd.arg("x");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[link(name = "rust_archive", kind = "static")]
2+
extern "C" {
3+
fn simple_fn();
4+
}
5+
6+
fn main() {
7+
unsafe {
8+
simple_fn();
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Regression test for https://github.com/rust-lang/rust/issues/107407
2+
3+
use run_make_support::{llvm_ar, rustc, static_lib_name};
4+
5+
fn main() {
6+
rustc().input("simple_obj.rs").emit("obj").run();
7+
llvm_ar().obj_to_thin_ar().output_input(static_lib_name("thin_archive"), "simple_obj.o").run();
8+
rustc().input("rust_archive.rs").run();
9+
// Disable lld as it ignores the symbol table in the archive file.
10+
rustc()
11+
.input("bin.rs") /*.arg("-Zlinker-features=-lld")*/
12+
.run();
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![crate_type = "staticlib"]
2+
3+
#[link(name = "thin_archive", kind = "static")]
4+
extern "C" {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![crate_type = "staticlib"]
2+
3+
#[no_mangle]
4+
extern "C" fn simple_fn() {}

0 commit comments

Comments
 (0)