Skip to content

Commit ab0fc6e

Browse files
Migrate run-make/c-link-to-rust-dylib to rmake.rs
1 parent aa0f8f9 commit ab0fc6e

File tree

3 files changed

+44
-22
lines changed

3 files changed

+44
-22
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ run-make/bare-outfile/Makefile
66
run-make/branch-protection-check-IBT/Makefile
77
run-make/c-dynamic-dylib/Makefile
88
run-make/c-dynamic-rlib/Makefile
9-
run-make/c-link-to-rust-dylib/Makefile
109
run-make/c-static-dylib/Makefile
1110
run-make/c-static-rlib/Makefile
1211
run-make/c-unwind-abi-catch-lib-panic/Makefile

tests/run-make/c-link-to-rust-dylib/Makefile

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// This test checks that C linking with Rust does not encounter any errors, with dynamic libraries.
2+
// See <https://github.com/rust-lang/rust/issues/10434>.
3+
4+
//@ ignore-cross-compile
5+
6+
use std::fs::remove_file;
7+
8+
use run_make_support::{
9+
cc, dynamic_lib_extension, is_msvc, read_dir, run, run_fail, rustc, tmp_dir,
10+
};
11+
12+
fn main() {
13+
rustc().input("foo.rs").run();
14+
15+
if is_msvc() {
16+
let lib = tmp_dir().join("foo.dll.lib");
17+
18+
// We remove the file in case it exists.
19+
let _ = remove_file(&lib);
20+
cc().input("bar.c").arg(lib).out_exe("bar").run();
21+
} else {
22+
cc().input("bar.c")
23+
.arg("-lfoo")
24+
.output(tmp_dir().join("bar"))
25+
.library_search_path(tmp_dir())
26+
.run();
27+
}
28+
29+
run("bar");
30+
31+
let expected_extension = dynamic_lib_extension();
32+
read_dir(tmp_dir(), |path| {
33+
if path.is_file()
34+
&& path.extension().is_some_and(|ext| ext == expected_extension)
35+
&& path
36+
.file_name()
37+
.and_then(|name| name.to_str())
38+
.is_some_and(|name| name.starts_with("lib"))
39+
{
40+
remove_file(path).unwrap();
41+
}
42+
});
43+
run_fail("bar");
44+
}

0 commit comments

Comments
 (0)