Skip to content

Commit 9c17cad

Browse files
authored
Merge pull request #1899 from joshtriplett/support-static-glibc
2 parents b3f8975 + 5bf6ee5 commit 9c17cad

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// Attributes needed when building as part of the standard library
2020
#![cfg_attr(
2121
feature = "rustc-dep-of-std",
22-
feature(cfg_target_vendor, link_cfg, no_core)
22+
feature(cfg_target_vendor, link_cfg, no_core, static_nobundle)
2323
)]
2424
#![cfg_attr(libc_thread_local, feature(thread_local))]
2525
// Enable extra lints:

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 & 2 deletions
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;
@@ -1436,7 +1435,6 @@ extern "C" {
14361435
) -> ::c_int;
14371436
}
14381437

1439-
#[link(name = "dl")]
14401438
extern "C" {
14411439
pub fn dlmopen(
14421440
lmid: Lmid_t,

src/unix/mod.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,32 @@ cfg_if! {
298298
} else if #[cfg(feature = "std")] {
299299
// cargo build, don't pull in anything extra as the libstd dep
300300
// already pulls in all libs.
301+
} else if #[cfg(all(target_os = "linux",
302+
target_env = "gnu",
303+
feature = "rustc-dep-of-std"))] {
304+
#[link(name = "util", kind = "static-nobundle",
305+
cfg(target_feature = "crt-static"))]
306+
#[link(name = "rt", kind = "static-nobundle",
307+
cfg(target_feature = "crt-static"))]
308+
#[link(name = "pthread", kind = "static-nobundle",
309+
cfg(target_feature = "crt-static"))]
310+
#[link(name = "m", kind = "static-nobundle",
311+
cfg(target_feature = "crt-static"))]
312+
#[link(name = "dl", kind = "static-nobundle",
313+
cfg(target_feature = "crt-static"))]
314+
#[link(name = "c", kind = "static-nobundle",
315+
cfg(target_feature = "crt-static"))]
316+
#[link(name = "gcc_eh", kind = "static-nobundle",
317+
cfg(target_feature = "crt-static"))]
318+
#[link(name = "gcc", kind = "static-nobundle",
319+
cfg(target_feature = "crt-static"))]
320+
#[link(name = "util", cfg(not(target_feature = "crt-static")))]
321+
#[link(name = "rt", cfg(not(target_feature = "crt-static")))]
322+
#[link(name = "pthread", cfg(not(target_feature = "crt-static")))]
323+
#[link(name = "m", cfg(not(target_feature = "crt-static")))]
324+
#[link(name = "dl", cfg(not(target_feature = "crt-static")))]
325+
#[link(name = "c", cfg(not(target_feature = "crt-static")))]
326+
extern {}
301327
} else if #[cfg(target_env = "musl")] {
302328
#[cfg_attr(feature = "rustc-dep-of-std",
303329
link(name = "c", kind = "static",

0 commit comments

Comments
 (0)