2024-05-31 03:47:57 -05:00
|
|
|
// This test checks that C linking with Rust does not encounter any errors, with dynamic libraries.
|
|
|
|
// See <https://github.com/rust-lang/rust/issues/10434>.
|
|
|
|
|
|
|
|
//@ ignore-cross-compile
|
|
|
|
|
2024-07-17 08:31:38 -05:00
|
|
|
use run_make_support::{cc, cwd, dynamic_lib_extension, is_msvc, rfs, run, run_fail, rustc};
|
2024-05-31 03:47:57 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
rustc().input("foo.rs").run();
|
|
|
|
|
|
|
|
if is_msvc() {
|
2024-06-06 14:34:34 -05:00
|
|
|
let lib = "foo.dll.lib";
|
2024-05-31 03:47:57 -05:00
|
|
|
|
|
|
|
cc().input("bar.c").arg(lib).out_exe("bar").run();
|
|
|
|
} else {
|
2024-06-06 14:34:34 -05:00
|
|
|
cc().input("bar.c").arg("-lfoo").output("bar").library_search_path(cwd()).run();
|
2024-05-31 03:47:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
run("bar");
|
|
|
|
|
|
|
|
let expected_extension = dynamic_lib_extension();
|
2024-07-17 07:42:06 -05:00
|
|
|
rfs::read_dir_entries(cwd(), |path| {
|
2024-05-31 03:47:57 -05:00
|
|
|
if path.is_file()
|
|
|
|
&& path.extension().is_some_and(|ext| ext == expected_extension)
|
|
|
|
&& path.file_name().and_then(|name| name.to_str()).is_some_and(|name| {
|
|
|
|
name.ends_with(".so") || name.ends_with(".dll") || name.ends_with(".dylib")
|
|
|
|
})
|
|
|
|
{
|
2024-07-17 07:42:06 -05:00
|
|
|
rfs::remove_file(path);
|
2024-05-31 03:47:57 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
run_fail("bar");
|
|
|
|
}
|