|
| 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 `import_name_type`, which allows for customization |
| 6 | +// of how Windows symbols will be named. The correctness of this feature is checked by comparison |
| 7 | +// with expected output. |
| 8 | +// See https://github.com/rust-lang/rust/pull/100732 |
| 9 | + |
| 10 | +//@ only-x86 |
| 11 | +//@ only-windows |
| 12 | + |
| 13 | +use run_make_support::{cc, diff, is_msvc, run, rustc}; |
| 14 | + |
| 15 | +// NOTE: build_native_dynamic lib is not used, as the special `def` files |
| 16 | +// must be passed to the CC compiler. |
| 17 | + |
| 18 | +fn main() { |
| 19 | + rustc().crate_type("bin").input("driver.rs").run(); |
| 20 | + if is_msvc() { |
| 21 | + cc().arg("-c").out_exe("extern").input("extern.c").run(); |
| 22 | + cc().input("extern.obj") |
| 23 | + .arg("extern.msvc.def") |
| 24 | + .args(&["-link", "-dll", "-noimplib", "-out:extern.dll"]) |
| 25 | + .run(); |
| 26 | + } else { |
| 27 | + cc().arg("-v").arg("-c").out_exe("extern.obj").input("extern.c").run(); |
| 28 | + cc().input("extern.obj") |
| 29 | + .arg("extern.gnu.def") |
| 30 | + .args(&["--no-leading-underscore", "-shared"]) |
| 31 | + .output("extern.dll") |
| 32 | + .run(); |
| 33 | + }; |
| 34 | + let out = run("driver").stdout_utf8(); |
| 35 | + diff().expected_file("output.txt").actual_text("actual", out).run(); |
| 36 | +} |
0 commit comments