Skip to content

Commit 618b913

Browse files
authored
Merge pull request rust-lang#18981 from Fabian-Gruenbichler/proc-macro-srv-portability
proc-macro-srv: make usage of RTLD_DEEPBIND portable
2 parents 141e53b + 5f4f6fb commit 618b913

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/tools/rust-analyzer/Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,7 @@ version = "0.0.0"
13771377
dependencies = [
13781378
"expect-test",
13791379
"intern",
1380+
"libc",
13801381
"libloading",
13811382
"memmap2",
13821383
"object 0.33.0",

src/tools/rust-analyzer/crates/proc-macro-srv/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ doctest = false
1414

1515
[dependencies]
1616
object.workspace = true
17+
libc.workspace = true
1718
libloading.workspace = true
1819
memmap2.workspace = true
1920

src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ fn load_library(file: &Utf8Path) -> Result<Library, libloading::Error> {
2828

2929
#[cfg(unix)]
3030
fn load_library(file: &Utf8Path) -> Result<Library, libloading::Error> {
31+
// not defined by POSIX, different values on mips vs other targets
32+
#[cfg(target_env = "gnu")]
33+
use libc::RTLD_DEEPBIND;
3134
use libloading::os::unix::Library as UnixLibrary;
32-
use std::os::raw::c_int;
35+
// defined by POSIX
36+
use libloading::os::unix::RTLD_NOW;
3337

34-
const RTLD_NOW: c_int = 0x00002;
35-
const RTLD_DEEPBIND: c_int = 0x00008;
38+
// MUSL and bionic don't have it..
39+
#[cfg(not(target_env = "gnu"))]
40+
const RTLD_DEEPBIND: std::os::raw::c_int = 0x0;
3641

3742
unsafe { UnixLibrary::open(Some(file), RTLD_NOW | RTLD_DEEPBIND).map(|lib| lib.into()) }
3843
}

0 commit comments

Comments
 (0)