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

Drop Foundation dependency #92

Merged
merged 1 commit into from
May 1, 2024
Merged

Conversation

kateinoigakukun
Copy link
Member

No description provided.

Co-authored-by: Kabir Oberai <[email protected]>
@kateinoigakukun kateinoigakukun merged commit 63aa2e5 into main May 1, 2024
7 checks passed
@kateinoigakukun kateinoigakukun deleted the katei/drop-foundation branch May 1, 2024 04:16
import ucrt
#else
#error("Unsupported Platform")
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

How come we need to use libc here? Seems like the only use site is open(..., O_DIRECTORY) — can we not use SystemPackage.FileDescriptor.OpenOptions.directory instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to keep using memchr because llvm recognizes the lib call and optimizes it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, what do you think about making a memchr shim in SystemExtras? Might be nice to isolate the C library stuff to that one spot. We can do the same for O_DIRECTORY, which seems like it might need to be re-declared by us on Windows (other platforms define .directory in SystemPackage).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, importing it through a C shim could be an option. Actually memchr is not a syscall and SystemExtras will be upstreamed to swift-system later, so SystemExtras might not be an appropriate place.
Once we upgrade the minimum supported Swift version to 6.0, we can import it via @_extern(c) without C module, but it's not feasible right now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah interesting, I would've assumed that UnsafeRawBufferPointer.firstIndex(of:) could be optimized to memchr under the hood but it looks like that isn't being done yet. It's being tracked via swiftlang/swift#63200.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it's unfortunate situation now 🥲

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