Skip to content

Commit 33ac508

Browse files
committed
update
1 parent 12f421a commit 33ac508

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

ci/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ symcheck+=(-- build-and-check)
6464

6565
build_intrinsics_test() {
6666
# Mostly we want to check that `cargo build` works, but we also go via
67-
# symcheck here to look for duplicates.
67+
# symcheck here to see if any duplicates sneak in somehow.
6868
"${symcheck[@]}" \
6969
--target "$target" --verbose \
7070
--manifest-path builtins-test-intrinsics/Cargo.toml "$@"

crates/symbol-check/src/main.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use object::read::archive::{ArchiveFile, ArchiveMember};
1111
use object::{Object, ObjectSymbol, Symbol, SymbolKind, SymbolScope, SymbolSection};
1212
use serde_json::Value;
1313

14+
const CHECK_LIBRARIES: &[&str] = &["compiler_builtins", "builtins_test_intrinsics"];
15+
1416
const USAGE: &str = "Usage:
1517
1618
symbol-check build-and-check CARGO_ARGS ...
@@ -40,7 +42,8 @@ fn main() {
4042
}
4143
}
4244

43-
/// Run `cargo build` with the provided additional arguments.
45+
/// Run `cargo build` with the provided additional arguments, collecting the list of created
46+
/// libraries.
4447
fn exec_cargo_with_args(args: &[&str]) -> Vec<PathBuf> {
4548
let mut cmd = Command::new("cargo")
4649
.arg("build")
@@ -52,41 +55,39 @@ fn exec_cargo_with_args(args: &[&str]) -> Vec<PathBuf> {
5255

5356
let stdout = cmd.stdout.take().unwrap();
5457
let reader = BufReader::new(stdout);
58+
let mut rlibs = Vec::new();
5559

56-
let mut x = Vec::new();
57-
58-
for m in reader.lines() {
59-
let m = m.expect("failed to read line");
60-
println!("{m}");
60+
for line in reader.lines() {
61+
let line = line.expect("failed to read line");
62+
println!("{line}"); // tee to stdout
6163

62-
let j: Value = serde_json::from_str(&m).expect("failed to deserialize");
64+
// Select only steps that create files
65+
let j: Value = serde_json::from_str(&line).expect("failed to deserialize");
6366
if j["reason"] != "compiler-artifact" {
6467
continue;
6568
}
6669

67-
for fname in j["filenames"].as_array().expect("filenames not an array") {
68-
let path = fname.as_str().expect("file name not a string");
69-
let p = PathBuf::from(path);
70-
71-
if let Some(ex) = p.extension()
72-
&& ex == "rlib"
73-
&& p.file_name()
74-
.unwrap()
75-
.to_str()
76-
.unwrap()
77-
.contains("compiler_builtins")
78-
{
79-
x.push(p);
70+
// Find rlibs in the created file list that match our
71+
for fpath in j["filenames"].as_array().expect("filenames not an array") {
72+
let path = fpath.as_str().expect("file name not a string");
73+
let path = PathBuf::from(path);
74+
75+
if path.extension().is_some_and(|ex| ex == "rlib") {
76+
let fname = path.file_name().unwrap().to_str().unwrap();
77+
78+
if CHECK_LIBRARIES.iter().any(|lib| fname.contains(lib)) {
79+
rlibs.push(path);
80+
}
8081
}
8182
}
8283
}
8384

8485
cmd.wait().expect("failed to wait on Cargo");
8586

86-
assert!(!x.is_empty(), "no compiler_builtins rlibs found");
87-
println!("Collected the following rlibs to check: {x:#?}");
87+
assert!(!rlibs.is_empty(), "no compiler_builtins rlibs found");
88+
println!("Collected the following rlibs to check: {rlibs:#?}");
8889

89-
x
90+
rlibs
9091
}
9192

9293
#[expect(unused)] // only for printing

0 commit comments

Comments
 (0)