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 8f14111

Browse files
committedMay 31, 2024
Migrate run-make/c-link-to-rust-dylib to rmake.rs
1 parent c6022b4 commit 8f14111

File tree

3 files changed

+47
-22
lines changed

3 files changed

+47
-22
lines changed
 

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ run-make/bare-outfile/Makefile
77
run-make/branch-protection-check-IBT/Makefile
88
run-make/c-dynamic-dylib/Makefile
99
run-make/c-dynamic-rlib/Makefile
10-
run-make/c-link-to-rust-dylib/Makefile
1110
run-make/c-static-dylib/Makefile
1211
run-make/c-static-rlib/Makefile
1312
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,47 @@
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()
17+
.input("bar.c")
18+
.arg(tmp_dir().join("foo.dll.lib"))
19+
.out_exe("bar")
20+
.run();
21+
} else {
22+
Cc::new()
23+
.input("bar.c")
24+
.arg("-lfoo")
25+
.output(tmp_dir().join("bar"))
26+
.library_search_path(tmp_dir())
27+
.run();
28+
}
29+
30+
run("bar");
31+
32+
let expected_extension = dynamic_lib_extension();
33+
read_dir(tmp_dir(), |path| {
34+
if path.is_file()
35+
&& path
36+
.extension()
37+
.is_some_and(|ext| ext == expected_extension)
38+
&& path
39+
.file_name()
40+
.and_then(|name| name.to_str())
41+
.is_some_and(|name| name.starts_with("lib"))
42+
{
43+
remove_file(path).unwrap();
44+
}
45+
});
46+
run_fail("bar");
47+
}

0 commit comments

Comments
 (0)
Failed to load comments.