File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
crates/ra_proc_macro_srv/src Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -57,10 +57,28 @@ fn is_derive_registrar_symbol(symbol: &str) -> bool {
57
57
symbol. contains ( NEW_REGISTRAR_SYMBOL )
58
58
}
59
59
60
+ #[ cfg( not( target_os = "macos" ) ) ]
61
+ fn adjust_symbol_name ( name : & str ) -> String {
62
+ name. to_string ( )
63
+ }
64
+
65
+ #[ cfg( target_os = "macos" ) ]
66
+ fn adjust_symbol_name ( s : & str ) -> String {
67
+ // In macos doc:
68
+ // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dlsym.3.html
69
+ // Unlike other dyld API's, the symbol name passed to dlsym() must NOT be
70
+ // prepended with an underscore.
71
+ if s. starts_with ( "_" ) {
72
+ s[ 1 ..s. len ( ) ] . to_string ( )
73
+ } else {
74
+ s. to_string ( )
75
+ }
76
+ }
77
+
60
78
fn find_registrar_symbol ( file : & Path ) -> Option < String > {
61
79
let symbols = get_symbols_from_lib ( file) ?;
62
80
63
- symbols. iter ( ) . find ( |s| is_derive_registrar_symbol ( s) ) . map ( |s| s . to_string ( ) )
81
+ symbols. iter ( ) . find ( |s| is_derive_registrar_symbol ( s) ) . map ( |s| adjust_symbol_name ( & s ) )
64
82
}
65
83
66
84
/// Loads dynamic library in platform dependent manner.
You can’t perform that action at this time.
0 commit comments