@@ -142,6 +142,14 @@ fn copy_and_stamp(
142
142
target_deps. push ( ( target, dependency_type) ) ;
143
143
}
144
144
145
+ fn copy_llvm_libunwind ( builder : & Builder < ' _ > , target : TargetSelection , libdir : & Path ) -> PathBuf {
146
+ let libunwind_path = builder. ensure ( native:: Libunwind { target } ) ;
147
+ let libunwind_source = libunwind_path. join ( "libunwind.a" ) ;
148
+ let libunwind_target = libdir. join ( "libunwind.a" ) ;
149
+ builder. copy ( & libunwind_source, & libunwind_target) ;
150
+ libunwind_target
151
+ }
152
+
145
153
/// Copies third party objects needed by various targets.
146
154
fn copy_third_party_objects (
147
155
builder : & Builder < ' _ > ,
@@ -167,6 +175,15 @@ fn copy_third_party_objects(
167
175
) ;
168
176
}
169
177
178
+ if target == "x86_64-fortanix-unknown-sgx"
179
+ || builder. config . llvm_libunwind == LlvmLibunwind :: InTree
180
+ && ( target. contains ( "linux" ) || target. contains ( "fuchsia" ) )
181
+ {
182
+ let libunwind_path =
183
+ copy_llvm_libunwind ( builder, target, & builder. sysroot_libdir ( * compiler, target) ) ;
184
+ target_deps. push ( ( libunwind_path, DependencyType :: Target ) ) ;
185
+ }
186
+
170
187
target_deps
171
188
}
172
189
@@ -208,6 +225,9 @@ fn copy_self_contained_objects(
208
225
builder. copy ( & src, & target) ;
209
226
target_deps. push ( ( target, DependencyType :: TargetSelfContained ) ) ;
210
227
}
228
+
229
+ let libunwind_path = copy_llvm_libunwind ( builder, target, & libdir_self_contained) ;
230
+ target_deps. push ( ( libunwind_path, DependencyType :: TargetSelfContained ) ) ;
211
231
} else if target. ends_with ( "-wasi" ) {
212
232
let srcdir = builder
213
233
. wasi_root ( target)
@@ -234,18 +254,6 @@ fn copy_self_contained_objects(
234
254
}
235
255
}
236
256
237
- if target. contains ( "musl" )
238
- || target. contains ( "x86_64-fortanix-unknown-sgx" )
239
- || builder. config . llvm_libunwind == LlvmLibunwind :: InTree
240
- && ( target. contains ( "linux" ) || target. contains ( "fuchsia" ) )
241
- {
242
- let libunwind_path = builder. ensure ( native:: Libunwind { target } ) ;
243
- let libunwind_source = libunwind_path. join ( "libunwind.a" ) ;
244
- let libunwind_target = libdir_self_contained. join ( "libunwind.a" ) ;
245
- builder. copy ( & libunwind_source, & libunwind_target) ;
246
- target_deps. push ( ( libunwind_target, DependencyType :: TargetSelfContained ) ) ;
247
- }
248
-
249
257
target_deps
250
258
}
251
259
0 commit comments