Skip to content

Commit c248778

Browse files
authored
Unrolled build for rust-lang#128696
Rollup merge of rust-lang#128696 - Oneirical:second-linkage-rampage, r=jieyouxu Migrate `staticlib-dylib-linkage` `run-make` test to rmake Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). I'm quite sure this has the same issue as the one brought up in [this discussion](rust-lang#128407 (comment)), so I elected to keep the ignore MSVC. try-job: aarch64-apple try-job: x86_64-gnu-llvm-17 try-job: armhf-gnu
2 parents 8b38707 + 608b322 commit c248778

File tree

3 files changed

+37
-22
lines changed

3 files changed

+37
-22
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ run-make/remap-path-prefix-dwarf/Makefile
2222
run-make/reproducible-build/Makefile
2323
run-make/rlib-format-packed-bundled-libs/Makefile
2424
run-make/split-debuginfo/Makefile
25-
run-make/staticlib-dylib-linkage/Makefile
2625
run-make/symbol-mangling-hashed/Makefile
2726
run-make/sysroot-crates-are-unstable/Makefile
2827
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,37 @@
1+
// A basic smoke test to check that rustc supports linking to a rust dylib with
2+
// --crate-type staticlib. bar is a dylib, on which foo is dependent - the native
3+
// static lib search paths are collected and used to compile foo.c, the final executable
4+
// which depends on both foo and bar.
5+
// See https://github.com/rust-lang/rust/pull/106560
6+
7+
//@ ignore-cross-compile
8+
// Reason: the compiled binary is executed.
9+
//@ ignore-wasm
10+
// Reason: WASM does not support dynamic libraries
11+
//@ ignore-msvc
12+
//FIXME(Oneirical): Getting this to work on MSVC requires passing libcmt.lib to CC,
13+
// which is not trivial to do.
14+
// Tracking issue: https://github.com/rust-lang/rust/issues/128602
15+
// Discussion: https://github.com/rust-lang/rust/pull/128407#discussion_r1702439172
16+
17+
use run_make_support::{cc, regex, run, rustc};
18+
19+
fn main() {
20+
rustc().arg("-Cprefer-dynamic").input("bar.rs").run();
21+
let libs = rustc()
22+
.input("foo.rs")
23+
.crate_type("staticlib")
24+
.print("native-static-libs")
25+
.arg("-Zstaticlib-allow-rdylib-deps")
26+
.run()
27+
.assert_stderr_contains("note: native-static-libs: ")
28+
.stderr_utf8();
29+
let re = regex::Regex::new(r#"note: native-static-libs:\s*(.+)"#).unwrap();
30+
let libs = re.find(&libs).unwrap().as_str().trim();
31+
// remove the note
32+
let (_, library_search_paths) = libs.split_once("note: native-static-libs: ").unwrap();
33+
// divide the command-line arguments in a vec
34+
let library_search_paths = library_search_paths.split(' ').collect::<Vec<&str>>();
35+
cc().input("foo.c").arg("-lfoo").args(library_search_paths).out_exe("foo").run();
36+
run("foo");
37+
}

0 commit comments

Comments
 (0)