@@ -11,6 +11,11 @@ def _rust_stdlib_filegroup_impl(ctx):
11
11
between_core_and_std_files = []
12
12
std_files = []
13
13
alloc_files = []
14
+ self_contained_files = [
15
+ file
16
+ for file in rust_lib
17
+ if file .basename .endswith (".o" ) and "self-contained" in file .path
18
+ ]
14
19
15
20
std_rlibs = [f for f in rust_lib if f .basename .endswith (".rlib" )]
16
21
if std_rlibs :
@@ -53,6 +58,7 @@ def _rust_stdlib_filegroup_impl(ctx):
53
58
between_core_and_std_files = between_core_and_std_files ,
54
59
std_files = std_files ,
55
60
alloc_files = alloc_files ,
61
+ self_contained_files = self_contained_files ,
56
62
),
57
63
]
58
64
@@ -101,7 +107,7 @@ def _make_libstd_and_allocator_ccinfo(ctx, rust_lib, allocator_library):
101
107
A CcInfo object for the required libraries, or None if no such libraries are available.
102
108
"""
103
109
cc_toolchain , feature_configuration = find_cc_toolchain (ctx )
104
- link_inputs = []
110
+ cc_infos = []
105
111
106
112
if not rust_common .stdlib_info in ctx .attr .rust_lib :
107
113
fail (dedent ("""\
@@ -112,6 +118,23 @@ def _make_libstd_and_allocator_ccinfo(ctx, rust_lib, allocator_library):
112
118
""" ).format (ctx .label , ctx .attr .rust_lib ))
113
119
rust_stdlib_info = ctx .attr .rust_lib [rust_common .stdlib_info ]
114
120
121
+ if rust_stdlib_info .self_contained_files :
122
+ compilation_outputs = cc_common .create_compilation_outputs (
123
+ objects = depset (rust_stdlib_info .self_contained_files ),
124
+ )
125
+
126
+ linking_context , _linking_outputs = cc_common .create_linking_context_from_compilation_outputs (
127
+ name = ctx .label .name ,
128
+ actions = ctx .actions ,
129
+ feature_configuration = feature_configuration ,
130
+ cc_toolchain = cc_toolchain ,
131
+ compilation_outputs = compilation_outputs ,
132
+ )
133
+
134
+ cc_infos .append (CcInfo (
135
+ linking_context = linking_context ,
136
+ ))
137
+
115
138
if rust_stdlib_info .std_rlibs :
116
139
alloc_inputs = depset (
117
140
[_ltl (f , ctx , cc_toolchain , feature_configuration ) for f in rust_stdlib_info .alloc_files ],
@@ -160,22 +183,29 @@ def _make_libstd_and_allocator_ccinfo(ctx, rust_lib, allocator_library):
160
183
order = "topological" ,
161
184
)
162
185
163
- link_inputs . append ( cc_common .create_linker_input (
186
+ link_inputs = cc_common .create_linker_input (
164
187
owner = rust_lib .label ,
165
188
libraries = std_inputs ,
166
- ))
189
+ )
167
190
168
- allocator_inputs = None
169
- if allocator_library :
170
- allocator_inputs = [allocator_library [CcInfo ].linking_context .linker_inputs ]
191
+ allocator_inputs = None
192
+ if allocator_library :
193
+ allocator_inputs = [allocator_library [CcInfo ].linking_context .linker_inputs ]
194
+
195
+ cc_infos .append (CcInfo (
196
+ linking_context = cc_common .create_linking_context (
197
+ linker_inputs = depset (
198
+ [link_inputs ],
199
+ transitive = allocator_inputs ,
200
+ order = "topological" ,
201
+ ),
202
+ ),
203
+ ))
171
204
172
- libstd_and_allocator_ccinfo = None
173
- if link_inputs :
174
- return CcInfo (linking_context = cc_common .create_linking_context (linker_inputs = depset (
175
- link_inputs ,
176
- transitive = allocator_inputs ,
177
- order = "topological" ,
178
- )))
205
+ if cc_infos :
206
+ return cc_common .merge_cc_infos (
207
+ direct_cc_infos = cc_infos ,
208
+ )
179
209
return None
180
210
181
211
def _rust_toolchain_impl (ctx ):
0 commit comments