|
| 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 | +// Almost identical to `raw-dylib-link-ordinal`, but with the addition of calling conventions, |
| 6 | +// such as stdcall. |
| 7 | +// See https://github.com/rust-lang/rust/pull/90782 |
| 8 | + |
| 9 | +//@ only-x86 |
| 10 | +//@ only-windows |
| 11 | + |
| 12 | +use run_make_support::{cc, diff, is_msvc, run, rustc}; |
| 13 | + |
| 14 | +// NOTE: build_native_dynamic lib is not used, as the special `def` files |
| 15 | +// must be passed to the CC compiler. |
| 16 | + |
| 17 | +fn main() { |
| 18 | + rustc().crate_type("lib").crate_name("raw_dylib_test").input("lib.rs").run(); |
| 19 | + rustc().crate_type("bin").input("driver.rs").run(); |
| 20 | + if is_msvc() { |
| 21 | + cc().arg("-c").out_exe("exporter").input("exporter.c").run(); |
| 22 | + cc().input("exporter.obj") |
| 23 | + .arg("exporter-msvc.def") |
| 24 | + .args(&["-link", "-dll", "-noimplib", "-out:exporter.dll"]) |
| 25 | + .run(); |
| 26 | + } else { |
| 27 | + cc().arg("-v").arg("-c").out_exe("exporter.obj").input("exporter.c").run(); |
| 28 | + cc().input("exporter.obj") |
| 29 | + .arg("exporter-gnu.def") |
| 30 | + .arg("-shared") |
| 31 | + .output("exporter.dll") |
| 32 | + .run(); |
| 33 | + }; |
| 34 | + let out = run("driver").stdout_utf8(); |
| 35 | + diff().expected_file("output.txt").actual_text("actual", out).normalize(r#"\r"#, "").run(); |
| 36 | +} |
0 commit comments