Skip to content

Follow-up fixes to make it work with wasi-libc #1095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kateinoigakukun
Copy link
Member

Fix remaining build issues with wasi-libc for missing functions, some constant shims, and replace a legacy libc function use (futimes) with futimens

@kateinoigakukun
Copy link
Member Author

@swift-ci test

try $0.withMemoryRebound(to: timeval.self, capacity: 2) {
if futimes(dstFD, $0) != 0 {
try $0.withMemoryRebound(to: timespec.self, capacity: 2) {
if futimens(dstFD, $0) != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, I just spent some time looking into and working around this issue for Android before I saw your pull, so I'm all for this futimens() change.

Copy link
Member

@finagolfin finagolfin left a comment

Choose a reason for hiding this comment

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

LGTM

@jmschonfeld jmschonfeld merged commit c0532f8 into swiftlang:main Dec 16, 2024
3 checks passed
kateinoigakukun added a commit to kateinoigakukun/swift-foundation that referenced this pull request Dec 17, 2024
* Gate `fchown` and `fchmod` calls behind `os(WASI)`

They are not available on WASI, so we gate them behind `os(WASI)`.

* Add missing constant shims for wasi-libc

* Use `futimens` instead of legacy `futimes`

wasi-libc does not provide `futimes` as it is a legacy function.
https://github.com/WebAssembly/wasi-libc/blob/574b88da481569b65a237cb80daf9a2d5aeaf82d/libc-top-half/musl/include/sys/time.h#L34
itingliu pushed a commit that referenced this pull request Jan 3, 2025
* Fix WASI build of `_copyDirectoryMetadata` (#1094)

Extended attributes don't exist in WASI, so we need to exclude the use
of xattr-related APIs including `flistxattr`.

* Follow-up fixes to make it work with wasi-libc (#1095)

* Gate `fchown` and `fchmod` calls behind `os(WASI)`

They are not available on WASI, so we gate them behind `os(WASI)`.

* Add missing constant shims for wasi-libc

* Use `futimens` instead of legacy `futimes`

wasi-libc does not provide `futimes` as it is a legacy function.
https://github.com/WebAssembly/wasi-libc/blob/574b88da481569b65a237cb80daf9a2d5aeaf82d/libc-top-half/musl/include/sys/time.h#L34

* Don't try to set extended attributes on Android (#1106)

Normal users don't have permission to change these, even for their own files.

---------

Co-authored-by: finagolfin <finagolfin@tuta.io>
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.

3 participants