Skip to content

Improve CSystem import handling - #391

Open
jrflat wants to merge 1 commit into
apple:mainfrom
jrflat:improve-csystem-import-handling-v2
Open

jrflat wants to merge 1 commit into
apple:mainfrom
jrflat:improve-csystem-import-handling-v2

Conversation

@jrflat

@jrflat jrflat commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

System previously imported CSystem with a bare (public) import. As a result, building with library evolution (e.g. as an OS framework) added import CSystem to System's .swiftinterface, which then failed to verify with "no such module 'CSystem'". On Darwin, _O_CLOFORK's inlinable body also referenced a macro defined in CSystem.

Switching to internal imports alone doesn't work: CSystemLinux.h re-included glibc headers, which made CSystem a second owner of declarations like EPERM and mode_t. These declarations would then be treated as internal and couldn't be used inside inlinable code. Now:

  • CSystemLinux.h no longer re-includes libc headers that Glibc exports. Those declarations are now attributed to the libc module.
  • Every CSystem import is internal, except Constants.swift on WASI and FreeBSD, whose inlinable constants still come from CSystem.
  • IORing's io_uring types move to a new CSystemIOUring module, which the IORing files import publicly. The syscall wrappers move into shims.c.
  • Darwin's _O_CLOFORK is now the literal 0x0800_0000, since older SDKs lack O_CLOFORK, and CSystemDarwin.h is removed. A new test checks the literal against the SDK's O_CLOFORK.
  • Windows files import WinSDK directly, and CSystemWindows.h is removed.
  • CInterop.swift imports Android instead of Bionic, like the other files.

@jrflat

jrflat commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author
2 breaking changes detected in SystemPackage:
  💔 API breakage: accessor IORing.RegisteredResource.unsafeBuffer.Get() has generic signature change from <T where T == CSystem.iovec> to <T where T == SwiftGlibc.iovec>
  💔 API breakage: accessor IORing.RegisteredResource.bytes.Get() has generic signature change from <T where T == CSystem.iovec> to <T where T == SwiftGlibc.iovec>

This is expected since CSystem.iovec is now attributed as SwiftGlibc.iovec. The actual symbol should still be compiled as __C.iovec. A client who calls import CSystem (even though it's not a product) to name iovec without import Glibc would now need import Glibc. I highly doubt this case exists.

Once we merge, the CI failure will go away.

@jrflat
jrflat marked this pull request as ready for review September 30, 2026 18:17
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.

1 participant