Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/libloading.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ jobs:
- name: Compile without the standard library
run: cargo clean && cargo +nightly build -Zbuild-std=core,alloc --no-default-features

musl-rust-lld-link-test:
runs-on: ubuntu-latest
# This test checks if binaries using libloading can be linked using rust-lld linker for target environments that
# provide a unified libc (e.g. musl) without needing to provide additional library paths to the linker.
steps:
- uses: actions/checkout@v4
- run: rustup install stable --profile=minimal
- run: rustup target add x86_64-unknown-linux-musl
- run: RUSTFLAGS="-Clinker=rust-lld" cargo build --target=x86_64-unknown-linux-musl --example e1

windows-test:
runs-on: windows-latest
strategy:
Expand Down
5 changes: 5 additions & 0 deletions examples/e1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
unsafe {
libloading::Library::new("libc.so").unwrap();
}
}
9 changes: 8 additions & 1 deletion src/os/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,14 @@ impl<T> fmt::Debug for Symbol<T> {
}

// Platform specific things
#[cfg_attr(any(target_os = "linux", target_os = "android"), link(name = "dl"))]
#[cfg_attr(
any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "android"
),
link(name = "dl")
)]
#[cfg_attr(all(target_os = "linux", target_env = "musl"), link(name = "c"))]
#[cfg_attr(any(target_os = "freebsd", target_os = "dragonfly"), link(name = "c"))]
extern "C" {
fn dlopen(
Expand Down