about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorJubilee Young <workingjubilee@gmail.com>2024-04-27 11:29:24 -0700
committerJubilee Young <workingjubilee@gmail.com>2024-04-27 11:33:15 -0700
commitfa73ebb303d3c6416c6e67d3184506b6a7883335 (patch)
tree9f2692deffc6eaaa3ac80ef66f1e8d078e6b304d /library/std/src/sys
parent61a1dbd751ab7f3c973be17d7ff3948ffda07c6e (diff)
downloadrust-fa73ebb303d3c6416c6e67d3184506b6a7883335.tar.gz
rust-fa73ebb303d3c6416c6e67d3184506b6a7883335.zip
Unconditionally call really_init
This makes miri not diverge in behavior, it fixes running Rust linux-gnu
binaries on musl with gcompat, it fixes dlopen edge-cases that cranelift
somehow hits, etc.
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/pal/unix/args.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/library/std/src/sys/pal/unix/args.rs b/library/std/src/sys/pal/unix/args.rs
index acf8100d47f..afe703bcb2f 100644
--- a/library/std/src/sys/pal/unix/args.rs
+++ b/library/std/src/sys/pal/unix/args.rs
@@ -98,12 +98,10 @@ mod imp {
     }
 
     #[inline(always)]
-    pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
-        // On Linux-GNU, we rely on `ARGV_INIT_ARRAY` below to initialize
-        // `ARGC` and `ARGV`. But in Miri that does not actually happen so we
-        // still initialize here.
-        #[cfg(any(miri, not(all(target_os = "linux", target_env = "gnu"))))]
-        really_init(_argc, _argv);
+    pub unsafe fn init(argc: isize, argv: *const *const u8) {
+        // on GNU/Linux if we are main then we will init argv and argc twice, it "duplicates work"
+        // BUT edge-cases are real: only using .init_array can break most emulators, dlopen, etc.
+        really_init(argc, argv);
     }
 
     /// glibc passes argc, argv, and envp to functions in .init_array, as a non-standard extension.