Auto merge of #128107 - Oneirical:tomato-hartester, r= · rust-lang/rust@91c0888 (original) (raw)
7 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -23,9 +23,6 @@ run-make/no-alloc-shim/Makefile | ||
23 | 23 | run-make/pdb-buildinfo-cl-cmd/Makefile |
24 | 24 | run-make/pgo-gen-lto/Makefile |
25 | 25 | run-make/pgo-indirect-call-promotion/Makefile |
26 | -run-make/raw-dylib-alt-calling-convention/Makefile | |
27 | -run-make/raw-dylib-c/Makefile | |
28 | -run-make/redundant-libs/Makefile | |
29 | 26 | run-make/remap-path-prefix-dwarf/Makefile |
30 | 27 | run-make/reproducible-build/Makefile |
31 | 28 | run-make/rlib-format-packed-bundled-libs/Makefile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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).normalize(r#"\r"#, "").run(); | |
24 | +if is_msvc() { | |
25 | +let out_msvc = run_with_args("driver", &["true"]).stdout_utf8(); | |
26 | +diff() | |
27 | +.expected_file("output.msvc.txt") | |
28 | +.actual_text("actual", out_msvc) | |
29 | +.normalize(r#"\r"#, "") | |
30 | +.run(); | |
31 | +} | |
32 | +} |
Original file line number | Diff line number | Diff 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).normalize(r#"\r"#, "").run(); | |
29 | +} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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 | +//@ ignore-windows-msvc | |
14 | +// Reason: this test links libraries via link.exe, which only accepts the import library | |
15 | +// for the dynamic library, i.e. `foo.dll.lib`. However, build_native_dynamic_lib only | |
16 | +// produces `foo.dll` - the dynamic library itself. To make this test work on MSVC, one | |
17 | +// would need to derive the import library from the dynamic library. | |
18 | +// See https://stackoverflow.com/questions/9360280/ | |
19 | + | |
20 | +use run_make_support::{ | |
21 | + build_native_dynamic_lib, build_native_static_lib, cwd, is_msvc, rfs, run, rustc, | |
22 | +}; | |
23 | + | |
24 | +fn main() { | |
25 | +build_native_dynamic_lib("foo"); | |
26 | +build_native_static_lib("bar"); | |
27 | +build_native_static_lib("baz"); | |
28 | +rustc() | |
29 | +.args(&["-lstatic=bar", "-lfoo", "-lstatic=baz", "-lfoo"]) | |
30 | +.input("main.rs") | |
31 | +.print("link-args") | |
32 | +.run(); | |
33 | +run("main"); | |
34 | +} |