Skip to content

Commit

Permalink
proc-macro-srv: drop unnecessary usage of RTLD_DEEPBIND
Browse files Browse the repository at this point in the history
the constant is wrong on some platforms (e.g., on mips64el it's 0x10, and 0x8
is RTLD_NOLOAD which makes all this functionality broken), and it is no longer
needed because rust-lang#60593 got fixed by
rust-lang#99944 in the meantime.

Signed-off-by: Fabian Grünbichler <[email protected]>
  • Loading branch information
Fabian-Gruenbichler committed Jan 16, 2025
1 parent d8a6409 commit c838673
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ use paths::{Utf8Path, Utf8PathBuf};
use crate::{proc_macros::ProcMacros, server_impl::TopSubtree, ProcMacroKind, ProcMacroSrvSpan};

/// Loads dynamic library in platform dependent manner.
///
/// For unix, you have to use RTLD_DEEPBIND flag to escape problems described
/// [here](https://github.com/fedochet/rust-proc-macro-panic-inside-panic-expample)
/// and [here](https://github.com/rust-lang/rust/issues/60593).
///
/// Usage of RTLD_DEEPBIND
/// [here](https://github.com/fedochet/rust-proc-macro-panic-inside-panic-expample/issues/1)
///
/// It seems that on Windows that behaviour is default, so we do nothing in that case.
#[cfg(windows)]
fn load_library(file: &Utf8Path) -> Result<Library, libloading::Error> {
unsafe { Library::new(file) }
Expand All @@ -29,12 +20,7 @@ fn load_library(file: &Utf8Path) -> Result<Library, libloading::Error> {
#[cfg(unix)]
fn load_library(file: &Utf8Path) -> Result<Library, libloading::Error> {
use libloading::os::unix::Library as UnixLibrary;
use std::os::raw::c_int;

const RTLD_NOW: c_int = 0x00002;
const RTLD_DEEPBIND: c_int = 0x00008;

unsafe { UnixLibrary::open(Some(file), RTLD_NOW | RTLD_DEEPBIND).map(|lib| lib.into()) }
unsafe { UnixLibrary::open(Some(file), libloading::os::unix::RTLD_NOW).map(|lib| lib.into()) }
}

#[derive(Debug)]
Expand Down

0 comments on commit c838673

Please sign in to comment.