Skip to content

WASI: Access to EEXIST through a stub getter function #800

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

@kateinoigakukun kateinoigakukun commented Nov 3, 2024

Build fix for WASI

Motivation:

Use of errno values in Swift without libc overlay is not supported with wasi-libc.

https://ci.swift.org/job/oss-swift-pr-test-crosscompile-wasm-ubuntu-20_04/1784/console

/home/build-user/swift-testing/Sources/Testing/Attachments/Test.Attachment.swift:249:61: error: cannot find 'EEXIST' in scope
247 |           result = preferredPath
248 |           break
249 |         } catch let error as CError where error.rawValue == EEXIST {
    |                                                             `- error: cannot find 'EEXIST' in scope
250 |           // Try again with a new suffix.
251 |           continue

Modifications:

This change introduces a new function swt_EEXIST to get the value of EEXIST because it is a complex macro in wasi-libc and cannot be imported directly into Swift.

Result:

WASI build will be repaired.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This change introduces a new function `swt_EEXIST` to get the value of
`EEXIST` because it is a complex macro in wasi-libc and cannot be
imported directly into Swift.
@kateinoigakukun
Copy link
Member Author

@swift-ci test

@kateinoigakukun kateinoigakukun changed the title Access to EEXIST through a stub getter function WASI: Access to EEXIST through a stub getter function Nov 3, 2024
@grynspan grynspan added bug 🪲 Something isn't working wasi/wasm 🧭 WebAssembly support labels Nov 3, 2024
@grynspan grynspan added this to the Swift 6.1 milestone Nov 3, 2024
@kateinoigakukun kateinoigakukun merged commit 12727e2 into swiftlang:main Nov 3, 2024
3 checks passed
@grynspan
Copy link
Contributor

grynspan commented Nov 3, 2024

Fixes issue introduced in #796.

@grynspan
Copy link
Contributor

grynspan commented Nov 3, 2024

@kateinoigakukun Seems like the Musl Swift overlay should (re)define these error codes so they're visible to Swift?

@kateinoigakukun
Copy link
Member Author

@grynspan The complex errno code definitions exist only in wasi-libc, not in musl. And we already define these error codes in WASILibc overlay module but not used them here to follow the porting policy

@grynspan
Copy link
Contributor

grynspan commented Nov 3, 2024

Fair enough. Just mentioning it in case it wasn't already handled and other projects could run into trouble. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working wasi/wasm 🧭 WebAssembly support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants