Skip to content

Commit 8742bf3

Browse files
Migrate run-make/cdylib to rmake.rs
1 parent b0d0cc6 commit 8742bf3

File tree

3 files changed

+36
-24
lines changed

3 files changed

+36
-24
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ run-make/c-unwind-abi-catch-panic/Makefile
1414
run-make/cat-and-grep-sanity-check/Makefile
1515
run-make/cdylib-dylib-linkage/Makefile
1616
run-make/cdylib-fewer-symbols/Makefile
17-
run-make/cdylib/Makefile
1817
run-make/codegen-options-parsing/Makefile
1918
run-make/comment-section/Makefile
2019
run-make/compiler-lookup-paths-2/Makefile

tests/run-make/cdylib/Makefile

-23
This file was deleted.

tests/run-make/cdylib/rmake.rs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// This test tries to check that basic cdylib libraries can be compiled and linked successfully
2+
// with C code, that the cdylib itself can depend on another rlib, and that the library can be built
3+
// with LTO.
4+
//
5+
// - `bar.rs` is a rlib
6+
// - `foo.rs` is a cdylib that relies on an extern crate `bar` and defines two `extern "C"`
7+
// functions:
8+
// - `foo()` which calls `bar::bar()`.
9+
// - `bar()` which implements basic addition.
10+
11+
//@ ignore-cross-compile
12+
13+
use std::fs::remove_file;
14+
15+
use run_make_support::{cc, dynamic_lib, is_msvc, run, rustc, tmp_dir};
16+
17+
fn main() {
18+
rustc().input("bar.rs").run();
19+
rustc().input("foo.rs").run();
20+
21+
if is_msvc() {
22+
cc().input("foo.c").arg(tmp_dir().join("foo.dll.lib")).out_exe("foo").run();
23+
} else {
24+
cc().input("foo.c")
25+
.arg("-lfoo")
26+
.output(tmp_dir().join("foo"))
27+
.library_search_path(tmp_dir())
28+
.run();
29+
}
30+
31+
run("foo");
32+
remove_file(dynamic_lib("foo")).unwrap();
33+
34+
rustc().input("foo.rs").arg("-Clto").run();
35+
run("foo");
36+
}

0 commit comments

Comments
 (0)