Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e3c1ad4

Browse files
committedAug 5, 2024
rewrite staticlib-dylib-linkage to rmake
1 parent 2b78d92 commit e3c1ad4

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed
 

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ run-make/reproducible-build/Makefile
3131
run-make/rlib-format-packed-bundled-libs/Makefile
3232
run-make/simd-ffi/Makefile
3333
run-make/split-debuginfo/Makefile
34-
run-make/staticlib-dylib-linkage/Makefile
3534
run-make/symbol-mangling-hashed/Makefile
3635
run-make/sysroot-crates-are-unstable/Makefile
3736
run-make/thumb-none-cortex-m/Makefile

‎tests/run-make/staticlib-dylib-linkage/Makefile

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//@ ignore-cross-compile
2+
// Reason: the compiled binary is executed.
3+
//@ ignore-wasm
4+
// Reason: WASM does not support dynamic libraries
5+
//@ ignore-msvc
6+
//FIXME(Oneirical): Getting this to work on MSVC requires passing libcmt.lib to CC,
7+
// which is not trivial to do.
8+
// Tracking issue: https://github.com/rust-lang/rust/issues/128602
9+
// Discussion: https://github.com/rust-lang/rust/pull/128407#discussion_r1702439172
10+
11+
use run_make_support::{cc, regex, run, rustc};
12+
13+
fn main() {
14+
rustc().arg("-Cprefer-dynamic").input("bar.rs").run();
15+
let libs = rustc()
16+
.input("foo.rs")
17+
.crate_type("staticlib")
18+
.print("native-static-libs")
19+
.arg("-Zstaticlib-allow-rdylib-deps")
20+
.run()
21+
.assert_stderr_contains("note: native-static-libs: ")
22+
.stderr_utf8();
23+
let re = regex::Regex::new(r#"note: native-static-libs:\s*(.+)"#).unwrap();
24+
let libs = re.find(&libs).unwrap().as_str().trim();
25+
let libs: &Vec<&str> = &libs[libs.find("-L").unwrap()..libs.len()].split(' ').collect();
26+
cc().input("foo.c").arg("-lfoo").args(libs).out_exe("foo").run();
27+
run("foo");
28+
}

0 commit comments

Comments
 (0)
Failed to load comments.