33
44use rustc:: session:: { Session , filesearch} ;
55use rustc:: session:: config:: {
6- self , RUST_CGU_EXT , DebugInfo , OutputFilenames , OutputType , PrintRequest , Sanitizer
6+ self , DebugInfo , OutputFilenames , OutputType , PrintRequest , Sanitizer
77} ;
88use rustc:: session:: search_paths:: PathKind ;
99use rustc:: middle:: dependency_format:: Linkage ;
@@ -15,7 +15,8 @@ use rustc_fs_util::fix_windows_verbatim_for_gcc;
1515use rustc_target:: spec:: { PanicStrategy , RelroLevel , LinkerFlavor } ;
1616use syntax:: symbol:: Symbol ;
1717
18- use crate :: { METADATA_FILENAME , RLIB_BYTECODE_EXTENSION , CrateInfo , CodegenResults } ;
18+ use crate :: { METADATA_FILENAME , RLIB_BYTECODE_EXTENSION , CrateInfo ,
19+ looks_like_rust_object_file, CodegenResults } ;
1920use super :: archive:: ArchiveBuilder ;
2021use super :: command:: Command ;
2122use super :: linker:: Linker ;
@@ -1549,23 +1550,9 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
15491550 let canonical = f. replace ( "-" , "_" ) ;
15501551 let canonical_name = name. replace ( "-" , "_" ) ;
15511552
1552- // Look for `.rcgu.o` at the end of the filename to conclude
1553- // that this is a Rust-related object file.
1554- fn looks_like_rust ( s : & str ) -> bool {
1555- let path = Path :: new ( s) ;
1556- let ext = path. extension ( ) . and_then ( |s| s. to_str ( ) ) ;
1557- if ext != Some ( OutputType :: Object . extension ( ) ) {
1558- return false
1559- }
1560- let ext2 = path. file_stem ( )
1561- . and_then ( |s| Path :: new ( s) . extension ( ) )
1562- . and_then ( |s| s. to_str ( ) ) ;
1563- ext2 == Some ( RUST_CGU_EXT )
1564- }
1565-
15661553 let is_rust_object =
15671554 canonical. starts_with ( & canonical_name) &&
1568- looks_like_rust ( & f) ;
1555+ looks_like_rust_object_file ( & f) ;
15691556
15701557 // If we've been requested to skip all native object files
15711558 // (those not generated by the rust compiler) then we can skip
0 commit comments