Skip to content

Commit 74cfbfd

Browse files
committed
Consolidate handling of libdl, and handle crt-static
Move the link line for `libdl` up to `src/unix/mod.rs`, making it easier to see all the libraries `libc` links to. This also makes `libdl` respect `target-feature=+crt-static`.
1 parent e929f27 commit 74cfbfd

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,6 @@ extern "C" {
14351435
) -> ::c_int;
14361436
}
14371437

1438-
#[link(name = "dl")]
14391438
extern "C" {
14401439
pub fn dlmopen(
14411440
lmid: Lmid_t,

src/unix/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ cfg_if! {
303303
feature = "rustc-dep-of-std"))] {
304304
#[link(name = "c", kind = "static-nobundle",
305305
cfg(target_feature = "crt-static"))]
306+
#[link(name = "dl", kind = "static-nobundle",
307+
cfg(target_feature = "crt-static"))]
306308
#[link(name = "m", kind = "static-nobundle",
307309
cfg(target_feature = "crt-static"))]
308310
#[link(name = "pthread", kind = "static-nobundle",
@@ -312,6 +314,7 @@ cfg_if! {
312314
#[link(name = "util", kind = "static-nobundle",
313315
cfg(target_feature = "crt-static"))]
314316
#[link(name = "c", cfg(not(target_feature = "crt-static")))]
317+
#[link(name = "dl", cfg(not(target_feature = "crt-static")))]
315318
#[link(name = "m", cfg(not(target_feature = "crt-static")))]
316319
#[link(name = "pthread", cfg(not(target_feature = "crt-static")))]
317320
#[link(name = "rt", cfg(not(target_feature = "crt-static")))]

0 commit comments

Comments
 (0)