Allow wasi-libc to initialize its environment variables lazily.#107866
Allow wasi-libc to initialize its environment variables lazily.#107866bors merged 1 commit intorust-lang:masterfrom
Conversation
Use `__wasilibc_get_environ()` to read the environment variable list from wasi-libc instead of using `environ`. `environ` is a global variable which effectively requires wasi-libc to initialize the environment variables eagerly, and `__wasilibc_get_environ()` is specifically designed to be an alternative that lets wasi-libc intiailize its environment variables lazily. This should have the side effect of fixing at least some of the cases of rust-lang#107635.
|
r? @m-ou-se (rustbot has picked a reviewer for you, use r? to override) |
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
| extern "C" { | ||
| pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; | ||
| pub fn chdir(dir: *const c_char) -> c_int; | ||
| pub fn __wasilibc_get_environ() -> *mut *mut c_char; |
There was a problem hiding this comment.
So the only cost of this change is that now we need to be sure that this wasilibc function is available via extern "C"? And it looks like we already rely on a wasilibc function in library/std/src/sys/wasi/fs.rs so that's nothing new.
|
This wasilibc function was added to wasi-libc in 2021 for this exact purpose so there shouldn't be any concerns about not having this function available. This change should only affect timing, not core function. @bors r+ rollup |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#107789 (Avoid exposing type parameters and implementation details sourced from macro expansions) - rust-lang#107836 (Handle properly when there is no crate attrs) - rust-lang#107839 (avoid duplicating the RUSTC_LOG env var name) - rust-lang#107866 (Allow wasi-libc to initialize its environment variables lazily.) - rust-lang#107876 (create symlink only for non-windows operating systems) - rust-lang#107882 (Cleanup typos in en_US/borrowck.ftl) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Use
__wasilibc_get_environ()to read the environment variable list from wasi-libc instead of usingenviron.environis a global variable which effectively requires wasi-libc to initialize the environment variables eagerly, and__wasilibc_get_environ()is specifically designed to be an alternative that lets wasi-libc intiailize its environment variables lazily.This should have the side effect of fixing at least some of the cases of #107635.