-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix env::ArgsOs
for zkVM
#139849
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
Fix env::ArgsOs
for zkVM
#139849
Conversation
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
This PR fixes the iterator, but leaves the arg retrieval and copying the same. There are some interesting alternatives to be considered there. rust/library/std/src/sys/args/zkvm.rs Lines 21 to 38 in 2da29db
It looks like the memory allocated by As for the comment about reimplementing |
I've now implemented the caching approach. The two commits are complete fixes with different approaches, so they should be considered separately until we decide. |
☔ The latest upstream changes (presumably #140581) made this pull request unmergeable. Please resolve the merge conflicts. |
The zkVM implementation of `env::ArgsOs` incorrectly reports the full length even after having iterated. Instead, use a range approach which works out to be simpler. Also, implement more iterator methods like the other platforms in rust-lang#139847.
Retrieve argc/argv from the host once, on demand when the first `env::ArgsOs` is constructed, and globally cache it. Copy each argument to an `OsString` while iterating.
I think we'd like to test this out somehow before accepting this. It doesn't look like it will cause a problem, but I'm not entirely sure. |
The zkVM implementation of
env::ArgsOs
incorrectly reports the full length even after having iterated. Instead, use a range approach which works out to be simpler. Also, implement more iterator methods like the other platforms in #139847.cc @flaub @jbruestle @SchmErik