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 {
5757 symbol. contains ( NEW_REGISTRAR_SYMBOL )
5858}
5959
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+
6078fn find_registrar_symbol ( file : & Path ) -> Option < String > {
6179 let symbols = get_symbols_from_lib ( file) ?;
6280
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 ) )
6482}
6583
6684/// Loads dynamic library in platform dependent manner.
You can’t perform that action at this time.
0 commit comments