@@ -44,89 +44,93 @@ use crate::spec::{LinkOutputKind, MaybeLazy};
4444use std:: borrow:: Cow ;
4545use std:: collections:: BTreeMap ;
4646
47- pub type CrtObjects = BTreeMap < LinkOutputKind , Vec < Cow < ' static , str > > > ;
48- pub type LazyCrtObjects = MaybeLazy < CrtObjects > ;
47+ type Tralala = & ' static [ ( LinkOutputKind , & ' static [ & ' static str ] ) ] ;
48+ pub struct Trulala ( Tralala ) ;
4949
50- pub ( super ) fn new ( obj_table : & [ ( LinkOutputKind , & [ & ' static str ] ) ] ) -> CrtObjects {
51- obj_table. iter ( ) . map ( |( z, k) | ( * z, k. iter ( ) . map ( |b| ( * b) . into ( ) ) . collect ( ) ) ) . collect ( )
50+ impl FnOnce < ( ) > for Trulala {
51+ type Output = CrtObjects ;
52+ extern "rust-call" fn call_once ( self , _args : ( ) ) -> Self :: Output {
53+ self . 0 . iter ( ) . map ( |( z, k) | ( * z, k. iter ( ) . map ( |b| ( * b) . into ( ) ) . collect ( ) ) ) . collect ( )
54+ }
5255}
5356
54- pub ( super ) fn all ( obj : & ' static str ) -> CrtObjects {
55- new ( & [
56- ( LinkOutputKind :: DynamicNoPicExe , & [ obj] ) ,
57- ( LinkOutputKind :: DynamicPicExe , & [ obj] ) ,
58- ( LinkOutputKind :: StaticNoPicExe , & [ obj] ) ,
59- ( LinkOutputKind :: StaticPicExe , & [ obj] ) ,
60- ( LinkOutputKind :: DynamicDylib , & [ obj] ) ,
61- ( LinkOutputKind :: StaticDylib , & [ obj] ) ,
62- ] )
57+ pub type CrtObjects = BTreeMap < LinkOutputKind , Vec < Cow < ' static , str > > > ;
58+ pub type LazyCrtObjects = MaybeLazy < CrtObjects , Trulala > ;
59+
60+ pub ( super ) fn new ( obj_table : Tralala ) -> LazyCrtObjects {
61+ MaybeLazy :: lazied ( Trulala ( obj_table) )
6362}
6463
65- pub ( super ) fn pre_musl_self_contained ( ) -> LazyCrtObjects {
66- MaybeLazy :: lazy ( || {
64+ macro_rules! all {
65+ ( $obj : literal ) => {
6766 new( & [
68- ( LinkOutputKind :: DynamicNoPicExe , & [ "crt1.o" , "crti.o" , "crtbegin.o" ] ) ,
69- ( LinkOutputKind :: DynamicPicExe , & [ "Scrt1.o" , "crti.o" , "crtbeginS.o" ] ) ,
70- ( LinkOutputKind :: StaticNoPicExe , & [ "crt1.o" , "crti.o" , "crtbegin.o" ] ) ,
71- ( LinkOutputKind :: StaticPicExe , & [ "rcrt1.o" , "crti.o" , "crtbeginS.o" ] ) ,
72- ( LinkOutputKind :: DynamicDylib , & [ "crti.o" , "crtbeginS.o" ] ) ,
73- ( LinkOutputKind :: StaticDylib , & [ "crti.o" , "crtbeginS.o" ] ) ,
67+ ( LinkOutputKind :: DynamicNoPicExe , & [ $obj ] ) ,
68+ ( LinkOutputKind :: DynamicPicExe , & [ $obj ] ) ,
69+ ( LinkOutputKind :: StaticNoPicExe , & [ $obj ] ) ,
70+ ( LinkOutputKind :: StaticPicExe , & [ $obj ] ) ,
71+ ( LinkOutputKind :: DynamicDylib , & [ $obj ] ) ,
72+ ( LinkOutputKind :: StaticDylib , & [ $obj ] ) ,
7473 ] )
75- } )
74+ } ;
75+ }
76+
77+ pub ( super ) fn pre_musl_self_contained ( ) -> LazyCrtObjects {
78+ new ( & [
79+ ( LinkOutputKind :: DynamicNoPicExe , & [ "crt1.o" , "crti.o" , "crtbegin.o" ] ) ,
80+ ( LinkOutputKind :: DynamicPicExe , & [ "Scrt1.o" , "crti.o" , "crtbeginS.o" ] ) ,
81+ ( LinkOutputKind :: StaticNoPicExe , & [ "crt1.o" , "crti.o" , "crtbegin.o" ] ) ,
82+ ( LinkOutputKind :: StaticPicExe , & [ "rcrt1.o" , "crti.o" , "crtbeginS.o" ] ) ,
83+ ( LinkOutputKind :: DynamicDylib , & [ "crti.o" , "crtbeginS.o" ] ) ,
84+ ( LinkOutputKind :: StaticDylib , & [ "crti.o" , "crtbeginS.o" ] ) ,
85+ ] )
7686}
7787
7888pub ( super ) fn post_musl_self_contained ( ) -> LazyCrtObjects {
79- MaybeLazy :: lazy ( || {
80- new ( & [
81- ( LinkOutputKind :: DynamicNoPicExe , & [ "crtend.o" , "crtn.o" ] ) ,
82- ( LinkOutputKind :: DynamicPicExe , & [ "crtendS.o" , "crtn.o" ] ) ,
83- ( LinkOutputKind :: StaticNoPicExe , & [ "crtend.o" , "crtn.o" ] ) ,
84- ( LinkOutputKind :: StaticPicExe , & [ "crtendS.o" , "crtn.o" ] ) ,
85- ( LinkOutputKind :: DynamicDylib , & [ "crtendS.o" , "crtn.o" ] ) ,
86- ( LinkOutputKind :: StaticDylib , & [ "crtendS.o" , "crtn.o" ] ) ,
87- ] )
88- } )
89+ new ( & [
90+ ( LinkOutputKind :: DynamicNoPicExe , & [ "crtend.o" , "crtn.o" ] ) ,
91+ ( LinkOutputKind :: DynamicPicExe , & [ "crtendS.o" , "crtn.o" ] ) ,
92+ ( LinkOutputKind :: StaticNoPicExe , & [ "crtend.o" , "crtn.o" ] ) ,
93+ ( LinkOutputKind :: StaticPicExe , & [ "crtendS.o" , "crtn.o" ] ) ,
94+ ( LinkOutputKind :: DynamicDylib , & [ "crtendS.o" , "crtn.o" ] ) ,
95+ ( LinkOutputKind :: StaticDylib , & [ "crtendS.o" , "crtn.o" ] ) ,
96+ ] )
8997}
9098
9199pub ( super ) fn pre_mingw_self_contained ( ) -> LazyCrtObjects {
92- MaybeLazy :: lazy ( || {
93- new ( & [
94- ( LinkOutputKind :: DynamicNoPicExe , & [ "crt2.o" , "rsbegin.o" ] ) ,
95- ( LinkOutputKind :: DynamicPicExe , & [ "crt2.o" , "rsbegin.o" ] ) ,
96- ( LinkOutputKind :: StaticNoPicExe , & [ "crt2.o" , "rsbegin.o" ] ) ,
97- ( LinkOutputKind :: StaticPicExe , & [ "crt2.o" , "rsbegin.o" ] ) ,
98- ( LinkOutputKind :: DynamicDylib , & [ "dllcrt2.o" , "rsbegin.o" ] ) ,
99- ( LinkOutputKind :: StaticDylib , & [ "dllcrt2.o" , "rsbegin.o" ] ) ,
100- ] )
101- } )
100+ new ( & [
101+ ( LinkOutputKind :: DynamicNoPicExe , & [ "crt2.o" , "rsbegin.o" ] ) ,
102+ ( LinkOutputKind :: DynamicPicExe , & [ "crt2.o" , "rsbegin.o" ] ) ,
103+ ( LinkOutputKind :: StaticNoPicExe , & [ "crt2.o" , "rsbegin.o" ] ) ,
104+ ( LinkOutputKind :: StaticPicExe , & [ "crt2.o" , "rsbegin.o" ] ) ,
105+ ( LinkOutputKind :: DynamicDylib , & [ "dllcrt2.o" , "rsbegin.o" ] ) ,
106+ ( LinkOutputKind :: StaticDylib , & [ "dllcrt2.o" , "rsbegin.o" ] ) ,
107+ ] )
102108}
103109
104110pub ( super ) fn post_mingw_self_contained ( ) -> LazyCrtObjects {
105- MaybeLazy :: lazy ( || all ( "rsend.o" ) )
111+ all ! ( "rsend.o" )
106112}
107113
108114pub ( super ) fn pre_mingw ( ) -> LazyCrtObjects {
109- MaybeLazy :: lazy ( || all ( "rsbegin.o" ) )
115+ all ! ( "rsbegin.o" )
110116}
111117
112118pub ( super ) fn post_mingw ( ) -> LazyCrtObjects {
113- MaybeLazy :: lazy ( || all ( "rsend.o" ) )
119+ all ! ( "rsend.o" )
114120}
115121
116122pub ( super ) fn pre_wasi_self_contained ( ) -> LazyCrtObjects {
117123 // Use crt1-command.o instead of crt1.o to enable support for new-style
118124 // commands. See https://reviews.llvm.org/D81689 for more info.
119- MaybeLazy :: lazy ( || {
120- new ( & [
121- ( LinkOutputKind :: DynamicNoPicExe , & [ "crt1-command.o" ] ) ,
122- ( LinkOutputKind :: DynamicPicExe , & [ "crt1-command.o" ] ) ,
123- ( LinkOutputKind :: StaticNoPicExe , & [ "crt1-command.o" ] ) ,
124- ( LinkOutputKind :: StaticPicExe , & [ "crt1-command.o" ] ) ,
125- ( LinkOutputKind :: WasiReactorExe , & [ "crt1-reactor.o" ] ) ,
126- ] )
127- } )
125+ new ( & [
126+ ( LinkOutputKind :: DynamicNoPicExe , & [ "crt1-command.o" ] ) ,
127+ ( LinkOutputKind :: DynamicPicExe , & [ "crt1-command.o" ] ) ,
128+ ( LinkOutputKind :: StaticNoPicExe , & [ "crt1-command.o" ] ) ,
129+ ( LinkOutputKind :: StaticPicExe , & [ "crt1-command.o" ] ) ,
130+ ( LinkOutputKind :: WasiReactorExe , & [ "crt1-reactor.o" ] ) ,
131+ ] )
128132}
129133
130134pub ( super ) fn post_wasi_self_contained ( ) -> LazyCrtObjects {
131- MaybeLazy :: lazy ( || new ( & [ ] ) )
135+ new ( & [ ] )
132136}
0 commit comments