Skip to content
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

[wasm] Define _WASI_EMULATED_MMAN to replace imports #4913

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Mar 8, 2024

The wasi_emulated_mman module must be imported with @_implementationOnly to avoid requiring Foundation users to enable _WASI_EMULATED_MMAN by themselves. "private import" does not work here because it still imports private dependencies while building a module that import Foundation.

@kateinoigakukun
Copy link
Member Author

@swift-ci test

@MaxDesiatov MaxDesiatov requested a review from xymus March 8, 2024 15:05
@MaxDesiatov
Copy link
Member

IIUC @_implementationOnly should not be used for non-resilient libraries, so maybe we can find some other workaround for this? I hope @xymus can clarify what options we have here.

Importing `wasi_emulated_mman` in Swift code requires the client to
define `_WASI_EMULATED_MMAN`. `@_implementationOnly import` was the only
way to work around this, but it's now declared as unsafe if it's used in
non-resilient moules (even though it's actually safe as long as the
module does not use type layout of the imported module).
The new scoped import feature always requires the transitive clients to
load privately imported modules, so it's not a good fit for this tricky
case where a special macro must be defined before importing the module.

This patch imports `sys/mman.h` through CoreFoundation while defining
`_WASI_EMULATED_MMAN` in the header exposed by modulemap. This way, the
clients don't need to define it.
@kateinoigakukun kateinoigakukun force-pushed the pr-f6022e0721b057fdae9a44e9299afba97392ce2d branch from 2a8ed98 to 90c1832 Compare March 8, 2024 15:57
@kateinoigakukun
Copy link
Member Author

kateinoigakukun commented Mar 8, 2024

@MaxDesiatov Updated not to use @_implementationOnly here. See commit message for the rationale 90c1832

@kateinoigakukun
Copy link
Member Author

@swift-ci test

@MaxDesiatov
Copy link
Member

@swift-ci test windows

@MaxDesiatov MaxDesiatov changed the title [wasm] Import wasi_emulated_mman with @_implementationOnly [wasm] Define _WASI_EMULATED_MMAN in headers instead of using imports Mar 8, 2024
@MaxDesiatov MaxDesiatov changed the title [wasm] Define _WASI_EMULATED_MMAN in headers instead of using imports [wasm] Define _WASI_EMULATED_MMAN to replace imports Mar 8, 2024
@kateinoigakukun kateinoigakukun merged commit f997707 into apple:main Mar 9, 2024
2 of 3 checks passed
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.

None yet

2 participants