Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c8d7b07

Browse files
authoredApr 28, 2024··
Unrolled build for rust-lang#124447
Rollup merge of rust-lang#124447 - workingjubilee:set-argv-twice-on-gnu, r=ChrisDenton Unconditionally call `really_init` on GNU/Linux 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. Fixes rust-lang#124126 thou hast gazed into this abyss with me: r? ``@ChrisDenton``
2 parents aed2187 + fa73ebb commit c8d7b07

File tree

1 file changed

+4
-6
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+4
-6
lines changed
 

‎library/std/src/sys/pal/unix/args.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,10 @@ mod imp {
9898
}
9999

100100
#[inline(always)]
101-
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
102-
// On Linux-GNU, we rely on `ARGV_INIT_ARRAY` below to initialize
103-
// `ARGC` and `ARGV`. But in Miri that does not actually happen so we
104-
// still initialize here.
105-
#[cfg(any(miri, not(all(target_os = "linux", target_env = "gnu"))))]
106-
really_init(_argc, _argv);
101+
pub unsafe fn init(argc: isize, argv: *const *const u8) {
102+
// on GNU/Linux if we are main then we will init argv and argc twice, it "duplicates work"
103+
// BUT edge-cases are real: only using .init_array can break most emulators, dlopen, etc.
104+
really_init(argc, argv);
107105
}
108106

109107
/// glibc passes argc, argv, and envp to functions in .init_array, as a non-standard extension.

0 commit comments

Comments
 (0)
Please sign in to comment.