Skip to content

Commit

Permalink
rewrite staticlib-dylib-linkage to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Aug 5, 2024
1 parent 2b78d92 commit e3c1ad4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ run-make/reproducible-build/Makefile
run-make/rlib-format-packed-bundled-libs/Makefile
run-make/simd-ffi/Makefile
run-make/split-debuginfo/Makefile
run-make/staticlib-dylib-linkage/Makefile
run-make/symbol-mangling-hashed/Makefile
run-make/sysroot-crates-are-unstable/Makefile
run-make/thumb-none-cortex-m/Makefile
Expand Down
21 changes: 0 additions & 21 deletions tests/run-make/staticlib-dylib-linkage/Makefile

This file was deleted.

28 changes: 28 additions & 0 deletions tests/run-make/staticlib-dylib-linkage/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//@ ignore-cross-compile
// Reason: the compiled binary is executed.
//@ ignore-wasm
// Reason: WASM does not support dynamic libraries
//@ ignore-msvc
//FIXME(Oneirical): Getting this to work on MSVC requires passing libcmt.lib to CC,
// which is not trivial to do.
// Tracking issue: https://github.com/rust-lang/rust/issues/128602
// Discussion: https://github.com/rust-lang/rust/pull/128407#discussion_r1702439172

use run_make_support::{cc, regex, run, rustc};

fn main() {
rustc().arg("-Cprefer-dynamic").input("bar.rs").run();
let libs = rustc()
.input("foo.rs")
.crate_type("staticlib")
.print("native-static-libs")
.arg("-Zstaticlib-allow-rdylib-deps")
.run()
.assert_stderr_contains("note: native-static-libs: ")
.stderr_utf8();
let re = regex::Regex::new(r#"note: native-static-libs:\s*(.+)"#).unwrap();
let libs = re.find(&libs).unwrap().as_str().trim();
let libs: &Vec<&str> = &libs[libs.find("-L").unwrap()..libs.len()].split(' ').collect();
cc().input("foo.c").arg("-lfoo").args(libs).out_exe("foo").run();
run("foo");
}

0 comments on commit e3c1ad4

Please sign in to comment.