Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ef4f8e6

Browse files
committedJun 1, 2024
Migrate run-make/c-link-to-rust-dylib to rmake.rs
1 parent aa0f8f9 commit ef4f8e6

File tree

3 files changed

+41
-22
lines changed

3 files changed

+41
-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,41 @@
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+
dynamic_lib_extension, is_msvc, read_dir, run, run_fail, rustc, tmp_dir, Cc,
10+
};
11+
12+
fn main() {
13+
rustc().input("foo.rs").run();
14+
15+
if is_msvc() {
16+
Cc::new().input("bar.c").arg(tmp_dir().join("foo.dll.lib")).out_exe("bar").run();
17+
} else {
18+
Cc::new()
19+
.input("bar.c")
20+
.arg("-lfoo")
21+
.output(tmp_dir().join("bar"))
22+
.library_search_path(tmp_dir())
23+
.run();
24+
}
25+
26+
run("bar");
27+
28+
let expected_extension = dynamic_lib_extension();
29+
read_dir(tmp_dir(), |path| {
30+
if path.is_file()
31+
&& path.extension().is_some_and(|ext| ext == expected_extension)
32+
&& path
33+
.file_name()
34+
.and_then(|name| name.to_str())
35+
.is_some_and(|name| name.starts_with("lib"))
36+
{
37+
remove_file(path).unwrap();
38+
}
39+
});
40+
run_fail("bar");
41+
}

0 commit comments

Comments
 (0)
Failed to load comments.