File tree 3 files changed +14
-0
lines changed
compiler/rustc_codegen_ssa
3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -3624,6 +3624,7 @@ dependencies = [
3624
3624
" itertools" ,
3625
3625
" jobserver" ,
3626
3626
" libc" ,
3627
+ " libloading" ,
3627
3628
" object 0.28.4" ,
3628
3629
" pathdiff" ,
3629
3630
" regex" ,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ pathdiff = "0.2.0"
19
19
snap = " 1"
20
20
smallvec = { version = " 1.6.1" , features = [" union" , " may_dangle" ] }
21
21
regex = " 1.4"
22
+ libloading = " 0.7.1"
22
23
23
24
rustc_serialize = { path = " ../rustc_serialize" }
24
25
rustc_arena = { path = " ../rustc_arena" }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use rustc_session::Session;
4
4
use rustc_span:: symbol:: Symbol ;
5
5
6
6
use std:: io;
7
+ use std:: ffi:: OsStr ;
7
8
use std:: path:: { Path , PathBuf } ;
8
9
9
10
pub ( super ) fn find_library (
@@ -32,6 +33,17 @@ pub(super) fn find_library(
32
33
if test. exists ( ) {
33
34
return test;
34
35
}
36
+ if cfg ! ( target_os = "macos" ) {
37
+ // This is a bit unintuitive: On macOS, a shared library may not be present on the file
38
+ // system yet still be loadable. This is due to the fact that there's a global cache of shared libraries being
39
+ // maintained by the system on BigSur and newer [1]. Therefore, as a last resort, try loading the library
40
+ // instead of just checking for its existence as a file.
41
+ // [1]: https://web.archive.org/web/20220317152936/https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes
42
+ let path: & OsStr = test. as_ref ( ) ;
43
+ if let Ok ( _) = unsafe { libloading:: Library :: new ( path) } {
44
+ return test;
45
+ }
46
+ }
35
47
}
36
48
}
37
49
sess. fatal ( & format ! (
You can’t perform that action at this time.
0 commit comments