forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#125808 - GuillaumeGomez:migrate-run-make-c-…
…link-to-rust-dylib, r=jieyouxu Migrate `run-make/c-link-to-rust-dylib` to `rmake.rs` Part of rust-lang#121876. First commit comes from rust-lang#125773. r? `@jieyouxu`
- Loading branch information
Showing
4 changed files
with
73 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// 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 std::fs::remove_file; | ||
|
||
use run_make_support::{ | ||
dynamic_lib_extension, is_msvc, read_dir, run, run_fail, rustc, tmp_dir, Cc, | ||
}; | ||
|
||
fn main() { | ||
rustc().input("foo.rs").run(); | ||
|
||
if is_msvc() { | ||
Cc::new() | ||
.input("bar.c") | ||
.arg(tmp_dir().join("foo.dll.lib")) | ||
.out_exe("bar") | ||
.run(); | ||
} else { | ||
Cc::new() | ||
.input("bar.c") | ||
.arg("-lfoo") | ||
.output(tmp_dir().join("bar")) | ||
.library_search_path(tmp_dir()) | ||
.run(); | ||
} | ||
|
||
run("bar"); | ||
|
||
let expected_extension = dynamic_lib_extension(); | ||
read_dir(tmp_dir(), |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.starts_with("lib")) | ||
{ | ||
remove_file(path).unwrap(); | ||
} | ||
}); | ||
run_fail("bar"); | ||
} |