@@ -11,6 +11,8 @@ use object::read::archive::{ArchiveFile, ArchiveMember};
1111use object:: { Object , ObjectSymbol , Symbol , SymbolKind , SymbolScope , SymbolSection } ;
1212use serde_json:: Value ;
1313
14+ const CHECK_LIBRARIES : & [ & str ] = & [ "compiler_builtins" , "builtins_test_intrinsics" ] ;
15+
1416const 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.
4447fn 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