From: Fabian Grünbichler Date: Thu, 16 Jan 2025 15:34:12 +0000 (+0100) Subject: proc-macro-srv: make usage of RTLD_DEEPBIND portable X-Git-Tag: archive/raspbian/1.84.0+dfsg1-2+rpi1^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1560b4e799e50132caf7e0b19703549df156ca66;p=rustc.git proc-macro-srv: make usage of RTLD_DEEPBIND portable 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), the libc crate takes care of those differences for us. fallback to old hard-coded value for non-glibc environments (which might or might not of DEEPBIND support). Forwarded: https://github.com/rust-lang/rust/pull/135591 Signed-off-by: Fabian Grünbichler Gbp-Pq: Topic behaviour Gbp-Pq: Name proc-macro-srv-make-usage-of-RTLD_DEEPBIND-portable.patch --- diff --git a/src/tools/rust-analyzer/Cargo.lock b/src/tools/rust-analyzer/Cargo.lock index 019609e6a5..bf08430d49 100644 --- a/src/tools/rust-analyzer/Cargo.lock +++ b/src/tools/rust-analyzer/Cargo.lock @@ -1357,6 +1357,7 @@ dependencies = [ "base-db", "expect-test", "intern", + "libc", "libloading", "memmap2", "object 0.33.0", diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/Cargo.toml b/src/tools/rust-analyzer/crates/proc-macro-srv/Cargo.toml index 4fabcc9006..28ca44b682 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/Cargo.toml +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/Cargo.toml @@ -14,6 +14,7 @@ doctest = false [dependencies] object.workspace = true +libc.workspace = true libloading.workspace = true memmap2.workspace = true diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs index 78ae4574c4..745bfc3f43 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs @@ -65,11 +65,16 @@ fn load_library(file: &Utf8Path) -> Result { #[cfg(unix)] fn load_library(file: &Utf8Path) -> Result { + // not defined by POSIX, different values on mips vs other targets + #[cfg(target_env = "gnu")] + use libc::RTLD_DEEPBIND; use libloading::os::unix::Library as UnixLibrary; - use std::os::raw::c_int; + // defined by POSIX + use libloading::os::unix::RTLD_NOW; - const RTLD_NOW: c_int = 0x00002; - const RTLD_DEEPBIND: c_int = 0x00008; + // MUSL and bionic don't have it.. + #[cfg(not(target_env = "gnu"))] + const RTLD_DEEPBIND: std::os::raw::c_int = 0x0; unsafe { UnixLibrary::open(Some(file), RTLD_NOW | RTLD_DEEPBIND).map(|lib| lib.into()) } }