Skip to content

Commit 9020a44

Browse files
committed
Auto merge of rust-lang#128107 - Oneirical:tomato-hartester, r=<try>
Migrate `raw-dylib-alt-calling-convention`, `raw-dylib-c` and `redundant-libs` `run-make` tests to rmake Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try: try-job: x86_64-msvc try-job: x86_64-mingw
2 parents 355efac + 5d72321 commit 9020a44

File tree

8 files changed

+87
-80
lines changed

8 files changed

+87
-80
lines changed

Diff for: src/tools/run-make-support/src/external_deps/c_build.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
3535
pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf {
3636
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
3737
let src = format!("{lib_name}.c");
38-
let lib_path = dynamic_lib_name(lib_name);
38+
let lib_path =
39+
if is_msvc() { format!("{lib_name}.dll.lib") } else { dynamic_lib_name(lib_name) };
3940
if is_msvc() {
4041
cc().arg("-c").out_exe(&obj_file).input(src).run();
4142
} else {

Diff for: src/tools/tidy/src/allowed_run_make_makefiles.txt

-3
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,9 @@ run-make/pgo-gen-lto/Makefile
4242
run-make/pgo-indirect-call-promotion/Makefile
4343
run-make/print-calling-conventions/Makefile
4444
run-make/print-target-list/Makefile
45-
run-make/raw-dylib-alt-calling-convention/Makefile
46-
run-make/raw-dylib-c/Makefile
4745
run-make/raw-dylib-import-name-type/Makefile
4846
run-make/raw-dylib-link-ordinal/Makefile
4947
run-make/raw-dylib-stdcall-ordinal/Makefile
50-
run-make/redundant-libs/Makefile
5148
run-make/remap-path-prefix-dwarf/Makefile
5249
run-make/reproducible-build-2/Makefile
5350
run-make/reproducible-build/Makefile

Diff for: tests/run-make/raw-dylib-alt-calling-convention/Makefile

-24
This file was deleted.
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// `raw-dylib` is a Windows-specific attribute which emits idata sections for the items in the
2+
// attached extern block,
3+
// so they may be linked against without linking against an import library.
4+
// To learn more, read https://github.com/rust-lang/rfcs/blob/master/text/2627-raw-dylib-kind.md
5+
// This test uses this feature alongside alternative calling conventions, checking that both
6+
// features are compatible and result in the expected output upon execution of the binary.
7+
// See https://github.com/rust-lang/rust/pull/84171
8+
9+
//@ only-x86
10+
//@ only-windows
11+
12+
use run_make_support::{build_native_dynamic_lib, diff, is_msvc, run, run_with_args, rustc};
13+
14+
fn main() {
15+
rustc()
16+
.crate_type("lib")
17+
.crate_name("raw_dylib_alt_calling_convention_test")
18+
.input("lib.rs")
19+
.run();
20+
rustc().crate_type("bin").input("driver.rs").run();
21+
build_native_dynamic_lib("extern");
22+
let out = run("driver").stdout_utf8();
23+
diff().expected_file("output.txt").actual_text("actual", out).run();
24+
if is_msvc() {
25+
let out_msvc = run_with_args("driver", &["true"]).stdout_utf8();
26+
diff().expected_file("output.msvc.txt").actual_text("actual", out_msvc).run();
27+
}
28+
}

Diff for: tests/run-make/raw-dylib-c/Makefile

-28
This file was deleted.

Diff for: tests/run-make/raw-dylib-c/rmake.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// `raw-dylib` is a Windows-specific attribute which emits idata sections for the items in the
2+
// attached extern block,
3+
// so they may be linked against without linking against an import library.
4+
// To learn more, read https://github.com/rust-lang/rfcs/blob/master/text/2627-raw-dylib-kind.md
5+
// This test is the simplest of the raw-dylib tests, simply smoke-testing that the feature
6+
// can be used to build an executable binary with an expected output with native C files
7+
// compiling into dynamic libraries.
8+
// See https://github.com/rust-lang/rust/pull/86419
9+
10+
//@ only-windows
11+
12+
use run_make_support::{build_native_dynamic_lib, diff, run, rustc};
13+
14+
fn main() {
15+
rustc().crate_type("lib").crate_name("raw_dylib_test").input("lib.rs").run();
16+
rustc().crate_type("bin").input("driver.rs").run();
17+
rustc().crate_type("bin").crate_name("raw_dylib_test_bin").input("lib.rs").run();
18+
build_native_dynamic_lib("extern_1");
19+
build_native_dynamic_lib("extern_2");
20+
let out_driver = run("driver").stdout_utf8();
21+
let out_raw = run("raw_dylib_test_bin").stdout_utf8();
22+
23+
diff()
24+
.expected_file("output.txt")
25+
.actual_text("actual", out_driver)
26+
.normalize(r#"\r"#, "")
27+
.run();
28+
diff().expected_file("output.txt").actual_text("actual", out_raw).run();
29+
}

Diff for: tests/run-make/redundant-libs/Makefile

-24
This file was deleted.

Diff for: tests/run-make/redundant-libs/rmake.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// rustc will remove one of the two redundant references to foo below. Depending
2+
// on which one gets removed, we'll get a linker error on SOME platforms (like
3+
// Linux). On these platforms, when a library is referenced, the linker will
4+
// only pull in the symbols needed _at that point in time_. If a later library
5+
// depends on additional symbols from the library, they will not have been pulled
6+
// in, and you'll get undefined symbols errors.
7+
//
8+
// So in this example, we need to ensure that rustc keeps the _later_ reference
9+
// to foo, and not the former one.
10+
11+
//@ ignore-cross-compile
12+
// Reason: the compiled binary is executed
13+
14+
//FIXME(Oneirical): msvc
15+
16+
use run_make_support::{build_native_dynamic_lib, build_native_static_lib, run, rustc};
17+
18+
fn main() {
19+
build_native_dynamic_lib("foo");
20+
build_native_static_lib("bar");
21+
build_native_static_lib("baz");
22+
rustc()
23+
.input("main.rs")
24+
.args(&["-lstatic=bar", "-lfoo", "-lstatic=baz", "-lfoo"])
25+
.print("link-args")
26+
.run();
27+
run("main");
28+
}

0 commit comments

Comments
 (0)