diff --git a/src/libstd/sys/unix/args.rs b/src/libstd/sys/unix/args.rs index 58fa305a8190a..15dafb1bcf964 100644 --- a/src/libstd/sys/unix/args.rs +++ b/src/libstd/sys/unix/args.rs @@ -72,12 +72,18 @@ mod imp { // acquire this mutex reentrantly! static LOCK: Mutex = Mutex::new(); - pub unsafe fn init(argc: isize, argv: *const *const u8) { + unsafe fn really_init(argc: isize, argv: *const *const u8) { let _guard = LOCK.lock(); ARGC = argc; ARGV = argv; } + #[inline(always)] + pub unsafe fn init(_argc: isize, _argv: *const *const u8) { + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] + really_init(_argc, _argv); + } + /// glibc passes argc, argv, and envp to functions in .init_array, as a non-standard extension. /// This allows `std::env::args` to work even in a `cdylib`, as it does on macOS and Windows. #[cfg(all(target_os = "linux", target_env = "gnu"))] @@ -94,7 +100,7 @@ mod imp { _envp: *const *const u8, ) { unsafe { - init(argc as isize, argv); + really_init(argc as isize, argv); } } init_wrapper