Skip to content

Commit e005f4c

Browse files
committed
Consolidate handling of libutil, and handle crt-static
The two library blocks that specify `#[link(name = "util")]` do not actually reference any functions in `libutil`; the functions that do use `libutil` don't have any reference to it. And having two library blocks specify it results in two separate inclusions of `-lutil` on the linker command line. Move the link lines up to `src/unix/mod.rs`, making it easier to see all the libraries `libc` links to. This also makes `libutil` respect `target-feature=+crt-static`.
1 parent ac0a783 commit e005f4c

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ pub const SYS_pkey_alloc: ::c_long = 330;
410410
pub const SYS_pkey_free: ::c_long = 331;
411411
pub const SYS_statx: ::c_long = 332;
412412

413-
#[link(name = "util")]
414413
extern "C" {
415414
pub fn sysctl(
416415
name: *mut ::c_int,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,6 @@ extern "C" {
13621362
) -> ::c_int;
13631363
}
13641364

1365-
#[link(name = "util")]
13661365
extern "C" {
13671366
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
13681367
pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int;

src/unix/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ cfg_if! {
301301
} else if #[cfg(all(target_os = "linux",
302302
target_env = "gnu",
303303
feature = "rustc-dep-of-std"))] {
304+
#[link(name = "util", kind = "static-nobundle",
305+
cfg(target_feature = "crt-static"))]
304306
#[link(name = "rt", kind = "static-nobundle",
305307
cfg(target_feature = "crt-static"))]
306308
#[link(name = "pthread", kind = "static-nobundle",
@@ -313,6 +315,7 @@ cfg_if! {
313315
cfg(target_feature = "crt-static"))]
314316
#[link(name = "gcc", kind = "static-nobundle",
315317
cfg(target_feature = "crt-static"))]
318+
#[link(name = "util", cfg(not(target_feature = "crt-static")))]
316319
#[link(name = "rt", cfg(not(target_feature = "crt-static")))]
317320
#[link(name = "pthread", cfg(not(target_feature = "crt-static")))]
318321
#[link(name = "m", cfg(not(target_feature = "crt-static")))]

0 commit comments

Comments
 (0)