rewrite archive-duplicate-names to rmake · rust-lang/rust@47c2101 (original) (raw)

File tree

3 files changed

lines changed

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
1 -run-make/archive-duplicate-names/Makefile
2 1 run-make/branch-protection-check-IBT/Makefile
3 2 run-make/c-dynamic-dylib/Makefile
4 3 run-make/c-dynamic-rlib/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
1 +// When two object archives with the same filename are present, an iterator is supposed to
2 +// inspect each object, recognize the duplication and extract each one to a different directory.
3 +// This test checks that this duplicate handling behaviour has not been broken.
4 +// See https://github.com/rust-lang/rust/pull/24439
5 +
6 +//@ ignore-cross-compile
7 +// Reason: the compiled binary is executed
8 +
9 +use run_make_support::{cc, is_msvc, llvm_ar, rfs, run, rustc};
10 +
11 +fn main() {
12 + rfs::create_dir("a");
13 + rfs::create_dir("b");
14 +compile_obj_force_foo("a", "foo");
15 +compile_obj_force_foo("b", "bar");
16 +let mut ar = llvm_ar();
17 + ar.obj_to_ar().arg("libfoo.a");
18 +if is_msvc() {
19 + ar.arg("a/foo.obj").arg("b/foo.obj").run();
20 +} else {
21 + ar.arg("a/foo.o").arg("b/foo.o").run();
22 +}
23 +rustc().input("foo.rs").run();
24 +rustc().input("bar.rs").run();
25 +run("bar");
26 +}
27 +
28 +#[track_caller]
29 +pub fn compile_obj_force_foo(dir: &str, lib_name: &str) {
30 +let obj_file = if is_msvc() { format!("{dir}/foo") } else { format!("{dir}/foo.o") };
31 +let src = format!("{lib_name}.c");
32 +if is_msvc() {
33 +cc().arg("-c").out_exe(&obj_file).input(src).run();
34 +} else {
35 +cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
36 +};
37 +}