mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
36 lines
1.0 KiB
Rust
36 lines
1.0 KiB
Rust
// 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
|
|
|
|
use run_make_support::{
|
|
cc, cwd, dynamic_lib_extension, fs_wrapper, is_msvc, read_dir, run, run_fail, rustc,
|
|
};
|
|
|
|
fn main() {
|
|
rustc().input("foo.rs").run();
|
|
|
|
if is_msvc() {
|
|
let lib = "foo.dll.lib";
|
|
|
|
cc().input("bar.c").arg(lib).out_exe("bar").run();
|
|
} else {
|
|
cc().input("bar.c").arg("-lfoo").output("bar").library_search_path(cwd()).run();
|
|
}
|
|
|
|
run("bar");
|
|
|
|
let expected_extension = dynamic_lib_extension();
|
|
read_dir(cwd(), |path| {
|
|
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")
|
|
})
|
|
{
|
|
fs_wrapper::remove_file(path);
|
|
}
|
|
});
|
|
run_fail("bar");
|
|
}
|