mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-30 03:27:44 +00:00
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 not setting the flag in non-glibc environments - some of them might have support for it using a different value that we don't know about, and some of them lack it entirely. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
248bd511ae
commit
73fc468a8f
3 changed files with 10 additions and 3 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1377,6 +1377,7 @@ version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"expect-test",
|
"expect-test",
|
||||||
"intern",
|
"intern",
|
||||||
|
"libc",
|
||||||
"libloading",
|
"libloading",
|
||||||
"memmap2",
|
"memmap2",
|
||||||
"object 0.33.0",
|
"object 0.33.0",
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
object.workspace = true
|
object.workspace = true
|
||||||
|
libc.workspace = true
|
||||||
libloading.workspace = true
|
libloading.workspace = true
|
||||||
memmap2.workspace = true
|
memmap2.workspace = true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,16 @@ fn load_library(file: &Utf8Path) -> Result<Library, libloading::Error> {
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn load_library(file: &Utf8Path) -> Result<Library, libloading::Error> {
|
fn load_library(file: &Utf8Path) -> Result<Library, libloading::Error> {
|
||||||
|
// 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 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;
|
// MUSL and bionic don't have it..
|
||||||
const RTLD_DEEPBIND: c_int = 0x00008;
|
#[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()) }
|
unsafe { UnixLibrary::open(Some(file), RTLD_NOW | RTLD_DEEPBIND).map(|lib| lib.into()) }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue