Skip to content

wasm: make ls pass and prepare more work#11563

Open
sylvestre wants to merge 3 commits intouutils:mainfrom
sylvestre:wasm-pr1
Open

wasm: make ls pass and prepare more work#11563
sylvestre wants to merge 3 commits intouutils:mainfrom
sylvestre:wasm-pr1

Conversation

@sylvestre
Copy link
Copy Markdown
Contributor

No description provided.

Add #[cfg(target_os = "wasi")] branches to support building uucore
for the wasm32-wasip1 target:

- FileInformation: use std::fs::Metadata instead of nix::sys::stat
- is_stdin_directory: return false (stdin is never a directory on WASI)
- sane_blksize: use default block size (no MetadataExt on WASI)
- read_fs_list: return empty list (no mount info on WASI)
- into_stdio: convert via File since Stdio::from(OwnedFd) is unavailable
The hostname crate does not support WASI (no OS-level hostname API).
Make it an optional dependency and stub it to an empty string on WASI,
since hyperlink URLs don't need a hostname in a browser environment.
Now that hostname is optional and uucore has WASI stubs, ls can be
built for the wasm32-wasip1 target.
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/rm/isatty (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/csplit/csplit-heap is now passing!
Congrats! The gnu test tests/tail/tail-n0f is now passing!
Note: The gnu test tests/env/env-signal-handler was skipped on 'main' but is now failing.

@sylvestre sylvestre marked this pull request as ready for review March 31, 2026 17:09
@sylvestre sylvestre requested a review from cakebaker March 31, 2026 17:09
Comment on lines +1151 to +1153
#[cfg(feature = "feat_hostname")]
static HOSTNAME: LazyLock<OsString> = LazyLock::new(|| hostname::get().unwrap_or_default());
#[cfg(not(feature = "feat_hostname"))]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for introducing a new feature instead of using #[cfg(target_os = "wasi")] like in the other files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants