From 74cfbfd734a6e12a6394010d8da8242141088056 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sat, 19 Sep 2020 20:46:25 -0700 Subject: [PATCH] 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`. --- src/unix/linux_like/linux/gnu/mod.rs | 1 - src/unix/mod.rs | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 9ea34dec38ed4..6ead42fee675b 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1435,7 +1435,6 @@ extern "C" { ) -> ::c_int; } -#[link(name = "dl")] extern "C" { pub fn dlmopen( lmid: Lmid_t, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 3ab6d334ec380..fb78e4d617c7a 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -303,6 +303,8 @@ cfg_if! { feature = "rustc-dep-of-std"))] { #[link(name = "c", kind = "static-nobundle", cfg(target_feature = "crt-static"))] + #[link(name = "dl", kind = "static-nobundle", + cfg(target_feature = "crt-static"))] #[link(name = "m", kind = "static-nobundle", cfg(target_feature = "crt-static"))] #[link(name = "pthread", kind = "static-nobundle", @@ -312,6 +314,7 @@ cfg_if! { #[link(name = "util", kind = "static-nobundle", cfg(target_feature = "crt-static"))] #[link(name = "c", cfg(not(target_feature = "crt-static")))] + #[link(name = "dl", cfg(not(target_feature = "crt-static")))] #[link(name = "m", cfg(not(target_feature = "crt-static")))] #[link(name = "pthread", cfg(not(target_feature = "crt-static")))] #[link(name = "rt", cfg(not(target_feature = "crt-static")))]