@@ -44,89 +44,93 @@ use crate::spec::{LinkOutputKind, MaybeLazy};
44
44
use std:: borrow:: Cow ;
45
45
use std:: collections:: BTreeMap ;
46
46
47
- pub type CrtObjectsData = BTreeMap < LinkOutputKind , Vec < Cow < ' static , str > > > ;
48
- pub type CrtObjects = MaybeLazy < CrtObjectsData > ;
47
+ type Tralala = & ' static [ ( LinkOutputKind , & ' static [ & ' static str ] ) ] ;
48
+ pub struct Trulala ( Tralala ) ;
49
49
50
- pub ( super ) fn new ( obj_table : & [ ( LinkOutputKind , & [ & ' static str ] ) ] ) -> CrtObjectsData {
51
- obj_table. iter ( ) . map ( |( z, k) | ( * z, k. iter ( ) . map ( |b| ( * b) . into ( ) ) . collect ( ) ) ) . collect ( )
50
+ impl FnOnce < ( ) > for Trulala {
51
+ type Output = CrtObjectsData ;
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
+ }
52
55
}
53
56
54
- pub ( super ) fn all ( obj : & ' static str ) -> CrtObjectsData {
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 CrtObjectsData = BTreeMap < LinkOutputKind , Vec < Cow < ' static , str > > > ;
58
+ pub type CrtObjects = MaybeLazy < CrtObjectsData , Trulala > ;
59
+
60
+ pub ( super ) fn new ( obj_table : Tralala ) -> CrtObjects {
61
+ MaybeLazy :: lazy2 ( Trulala ( obj_table) )
63
62
}
64
63
65
- pub ( super ) fn pre_musl_self_contained ( ) -> CrtObjects {
66
- MaybeLazy :: lazy ( || {
64
+ macro_rules! all {
65
+ ( $obj : literal ) => {
67
66
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 ] ) ,
74
73
] )
75
- } )
74
+ } ;
75
+ }
76
+
77
+ pub ( super ) fn pre_musl_self_contained ( ) -> CrtObjects {
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
+ ] )
76
86
}
77
87
78
88
pub ( super ) fn post_musl_self_contained ( ) -> CrtObjects {
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
+ ] )
89
97
}
90
98
91
99
pub ( super ) fn pre_mingw_self_contained ( ) -> CrtObjects {
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
+ ] )
102
108
}
103
109
104
110
pub ( super ) fn post_mingw_self_contained ( ) -> CrtObjects {
105
- MaybeLazy :: lazy ( || all ( "rsend.o" ) )
111
+ all ! ( "rsend.o" )
106
112
}
107
113
108
114
pub ( super ) fn pre_mingw ( ) -> CrtObjects {
109
- MaybeLazy :: lazy ( || all ( "rsbegin.o" ) )
115
+ all ! ( "rsbegin.o" )
110
116
}
111
117
112
118
pub ( super ) fn post_mingw ( ) -> CrtObjects {
113
- MaybeLazy :: lazy ( || all ( "rsend.o" ) )
119
+ all ! ( "rsend.o" )
114
120
}
115
121
116
122
pub ( super ) fn pre_wasi_self_contained ( ) -> CrtObjects {
117
123
// Use crt1-command.o instead of crt1.o to enable support for new-style
118
124
// 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
+ ] )
128
132
}
129
133
130
134
pub ( super ) fn post_wasi_self_contained ( ) -> CrtObjects {
131
- MaybeLazy :: lazy ( || new ( & [ ] ) )
135
+ new ( & [ ] )
132
136
}
0 commit comments