Fix IORing build for older Linux kernels #247
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
System currently fails to build on Ubuntu 20.04 (Linux kernel v5.4) as shown in #243, but those same tests should now pass with this PR. I verified locally that System now builds on a Swift 6.2 Ubuntu 20.04 image.
The issue is that
struct io_uring_sqehas added new properties in later kernel versions, and the Swift implementation is expecting these properties to be available on the struct.Specifically,
struct io_uring_sqeadded:cancel_flagsin v5.5open_flagsin v5.6file_indexin v5.15In the future, we could do something tricky to guard the availability of these features, but for now, let's just define a fallback struct for kernel versions < 5.15 so that we can build, but otherwise not support
IORinginitialization at runtime (such as by throwingENOTSUP).This PR defines a
struct swift_io_uring_sqethat is just a typedef ofstruct io_uring_sqeon kernel versions thatIORingsupports. Otherwise, we use the same fallback struct that's defined when the<linux/io_uring.h>header isn't available.We also replace the use of
IORING_FEAT_NODROPwithIORing.Features.nonDroppingCompletions.rawValue, which hard-codes the value for now.