Skip to content

Commit d448ab0

Browse files
committed
Make std::sys::unix::args::init a no-op on glibc Linux
1 parent 55fe6d8 commit d448ab0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/libstd/sys/unix/args.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,18 @@ mod imp {
7272
// acquire this mutex reentrantly!
7373
static LOCK: Mutex = Mutex::new();
7474

75-
pub unsafe fn init(argc: isize, argv: *const *const u8) {
75+
unsafe fn really_init(argc: isize, argv: *const *const u8) {
7676
let _guard = LOCK.lock();
7777
ARGC = argc;
7878
ARGV = argv;
7979
}
8080

81+
#[inline(always)]
82+
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
83+
#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
84+
really_init(_argc, _argv);
85+
}
86+
8187
/// glibc passes argc, argv, and envp to functions in .init_array, as a non-standard extension.
8288
/// This allows `std::env::args` to work even in a `cdylib`, as it does on macOS and Windows.
8389
#[cfg(all(target_os = "linux", target_env = "gnu"))]
@@ -94,7 +100,7 @@ mod imp {
94100
_envp: *const *const u8,
95101
) {
96102
unsafe {
97-
init(argc as isize, argv);
103+
really_init(argc as isize, argv);
98104
}
99105
}
100106
init_wrapper

0 commit comments

Comments
 (0)