Skip to content

Commit c1a8abb

Browse files
authored
Rollup merge of rust-lang#124383 - Urgau:port-print-native-static-libs, r=jieyouxu
Port run-make `--print=native-static-libs` to rmake.rs This PR port the run-make `--print=native-static-libs` test to rmake.rs The dedup was really awful in the `Makefile`, I'm glad to finally have a proper dedup detection for this. Related to rust-lang#121876 r? `@jieyouxu`
2 parents f74e7ab + 74cbc09 commit c1a8abb

File tree

3 files changed

+63
-20
lines changed

3 files changed

+63
-20
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ run-make/pretty-print-to-file/Makefile
220220
run-make/pretty-print-with-dep-file/Makefile
221221
run-make/print-calling-conventions/Makefile
222222
run-make/print-cfg/Makefile
223-
run-make/print-native-static-libs/Makefile
224223
run-make/print-target-list/Makefile
225224
run-make/profile/Makefile
226225
run-make/prune-link-args/Makefile

tests/run-make/print-native-static-libs/Makefile

-19
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//! This checks the output of `--print=native-static-libs`
2+
//!
3+
//! Specifically, this test makes sure that one and only one
4+
//! note is emitted with the text "native-static-libs:" as prefix
5+
//! that the note contains the link args given in the source code
6+
//! and cli of the current crate and downstream crates.
7+
//!
8+
//! It also checks that there aren't any duplicated consecutive
9+
//! args, as they are useless and suboptimal for debugability.
10+
//! See https://github.com/rust-lang/rust/issues/113209.
11+
12+
//@ ignore-cross-compile
13+
//@ ignore-wasm
14+
15+
extern crate run_make_support;
16+
17+
use std::io::BufRead;
18+
19+
use run_make_support::rustc;
20+
21+
fn main() {
22+
// build supporting crate
23+
rustc()
24+
.input("bar.rs")
25+
.crate_type("rlib")
26+
.arg("-lbar_cli")
27+
.run();
28+
29+
// build main crate as staticlib
30+
let output = rustc()
31+
.input("foo.rs")
32+
.crate_type("staticlib")
33+
.arg("-lfoo_cli")
34+
.arg("-lfoo_cli") // 2nd time
35+
.print("native-static-libs")
36+
.run();
37+
38+
let mut found_note = false;
39+
for l in output.stderr.lines() {
40+
let l = l.expect("utf-8 string");
41+
42+
let Some(args) = l.strip_prefix("note: native-static-libs:") else { continue; };
43+
assert!(!found_note);
44+
found_note = true;
45+
46+
let args: Vec<&str> = args.trim().split_ascii_whitespace().collect();
47+
48+
assert!(args.contains(&"-lglib-2.0")); // in bar.rs
49+
assert!(args.contains(&"-lsystemd")); // in foo.rs
50+
assert!(args.contains(&"-lbar_cli"));
51+
assert!(args.contains(&"-lfoo_cli"));
52+
53+
// make sure that no args are consecutively present
54+
let dedup_args: Vec<&str> = {
55+
let mut args = args.clone();
56+
args.dedup();
57+
args
58+
};
59+
assert_eq!(args, dedup_args);
60+
}
61+
62+
assert!(found_note);
63+
}

0 commit comments

Comments
 (0)