1- use crate :: core:: compiler:: { CompileMode , Context , CrateType , Unit } ;
1+ use crate :: core:: compiler:: { BuildContext , CompileMode , CrateType , Unit } ;
22use crate :: core:: profiles;
33use crate :: util:: interning:: InternedString ;
44
@@ -40,9 +40,9 @@ pub enum Lto {
4040 OnlyObject ,
4141}
4242
43- pub fn generate ( cx : & mut Context < ' _ , ' _ > ) -> CargoResult < ( ) > {
43+ pub fn generate ( bcx : & BuildContext < ' _ , ' _ > ) -> CargoResult < HashMap < Unit , Lto > > {
4444 let mut map = HashMap :: new ( ) ;
45- for unit in cx . bcx . roots . iter ( ) {
45+ for unit in bcx. roots . iter ( ) {
4646 let root_lto = match unit. profile . lto {
4747 // LTO not requested, no need for bitcode.
4848 profiles:: Lto :: Bool ( false ) | profiles:: Lto :: Off => Lto :: OnlyObject ,
@@ -60,10 +60,9 @@ pub fn generate(cx: &mut Context<'_, '_>) -> CargoResult<()> {
6060 }
6161 }
6262 } ;
63- calculate ( cx , & mut map, unit, root_lto) ?;
63+ calculate ( bcx , & mut map, unit, root_lto) ?;
6464 }
65- cx. lto = map;
66- Ok ( ( ) )
65+ Ok ( map)
6766}
6867
6968/// Whether or not any of these crate types need object code.
@@ -87,7 +86,7 @@ fn lto_when_needs_object(crate_types: &[CrateType]) -> Lto {
8786}
8887
8988fn calculate (
90- cx : & Context < ' _ , ' _ > ,
89+ bcx : & BuildContext < ' _ , ' _ > ,
9190 map : & mut HashMap < Unit , Lto > ,
9291 unit : & Unit ,
9392 parent_lto : Lto ,
@@ -185,8 +184,8 @@ fn calculate(
185184 }
186185 } ;
187186
188- for dep in cx . unit_deps ( unit) {
189- calculate ( cx , map, & dep. unit , merged_lto) ?;
187+ for dep in & bcx . unit_graph [ unit] {
188+ calculate ( bcx , map, & dep. unit , merged_lto) ?;
190189 }
191190 Ok ( ( ) )
192191}
0 commit comments