aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_proc_macro_srv/src/dylib.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/crates/ra_proc_macro_srv/src/dylib.rs b/crates/ra_proc_macro_srv/src/dylib.rs
index 738b10d56..eca9c8576 100644
--- a/crates/ra_proc_macro_srv/src/dylib.rs
+++ b/crates/ra_proc_macro_srv/src/dylib.rs
@@ -57,10 +57,28 @@ fn is_derive_registrar_symbol(symbol: &str) -> bool {
57 symbol.contains(NEW_REGISTRAR_SYMBOL) 57 symbol.contains(NEW_REGISTRAR_SYMBOL)
58} 58}
59 59
60#[cfg(not(target_os = "macos"))]
61fn adjust_symbol_name(name: &str) -> String {
62 name.to_string()
63}
64
65#[cfg(target_os = "macos")]
66fn 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
60fn find_registrar_symbol(file: &Path) -> Option<String> { 78fn find_registrar_symbol(file: &Path) -> Option<String> {
61 let symbols = get_symbols_from_lib(file)?; 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/// Loads dynamic library in platform dependent manner. 84/// Loads dynamic library in platform dependent manner.