Skip to content

Commit 46e2d6e

Browse files
authored
Merge pull request #18981 from Fabian-Gruenbichler/proc-macro-srv-portability
proc-macro-srv: make usage of RTLD_DEEPBIND portable
2 parents 7b65774 + 73fc468 commit 46e2d6e

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/proc-macro-srv/Cargo.toml

+1
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

crates/proc-macro-srv/src/dylib.rs

+8-3
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)