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

Support Big Sur #200

Merged
merged 2 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/block_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static struct blockif_sig_elem *blockif_bse_head;
#pragma clang diagnostic pop

static ssize_t
preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When building with Xcode 12.2 Beta 4 it fails with the following error:

/Users/shane/Code/xhyve/src/block_if.c:248:15: error: 'preadv' is only available on macOS 11.0 or newer [-Werror,-Wunguarded-availability-new]
                        if ((len = preadv(bc->bc_fd, br->br_iov, br->br_iovcnt,
                                   ^~~~~~
In module 'Darwin' imported from /Users/shane/Code/xhyve/src/block_if.c:30:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/include/sys/uio.h:103:9: note: 'preadv' has been marked as being introduced in macOS 11.0 here, but the deployment target is macOS 10.10.0
ssize_t preadv(int, const struct iovec *, int, off_t) __DARWIN_NOCANCEL(preadv) __API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0));
        ^
/Users/shane/Code/xhyve/src/block_if.c:248:15: note: enclose 'preadv' in a __builtin_available check to silence this warning
                        if ((len = preadv(bc->bc_fd, br->br_iov, br->br_iovcnt,
                                   ^~~~~~

It seems that preadv has been added in Big Sur. I couldn't find an easy way of using the builtin function in Big Sur and this shim for earlier versions so I just avoided the name collision. Suggestions for improvement welcome!

Similarly for pwritev below.

Copy link
Contributor

Choose a reason for hiding this comment

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

This will be fine for now, as it does not regress any existing behavior. However, it would be nice to make use of preadv. I think we can fix this later by checking __MAC_OS_X_VERSION_MAX_ALLOWED, like @jeremyhu suggested in #192.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have tried to wrap this function as suggested but I get the same error, it seems like it would want the target SDK to be 11.0+ 🤷🏻‍♂️

{
off_t res;

Expand All @@ -132,7 +132,7 @@ preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
}

static ssize_t
pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
{
off_t res;

Expand Down Expand Up @@ -239,7 +239,7 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf)
switch (be->be_op) {
case BOP_READ:
if (buf == NULL) {
if ((len = preadv(bc->bc_fd, br->br_iov, br->br_iovcnt,
if ((len = _preadv(bc->bc_fd, br->br_iov, br->br_iovcnt,
br->br_offset)) < 0)
err = errno;
else
Expand Down Expand Up @@ -279,7 +279,7 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf)
break;
}
if (buf == NULL) {
if ((len = pwritev(bc->bc_fd, br->br_iov, br->br_iovcnt,
if ((len = _pwritev(bc->bc_fd, br->br_iov, br->br_iovcnt,
br->br_offset)) < 0)
err = errno;
else
Expand Down
3 changes: 3 additions & 0 deletions src/pci_e82545.c
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,10 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head, uint16_t tail,

/* Allocate, fill and prepend writable header vector. */
if (hdrlen != 0) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Walloca"
hdr = __builtin_alloca((size_t)(hdrlen + vlen));
#pragma clang diagnostic push
hdr += vlen;
for (left = hdrlen, hdrp = hdr; left > 0;
left -= now, hdrp += now) {
Expand Down
2 changes: 2 additions & 0 deletions xcconfigs/xhyve.xcconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ARCHS = x86_64;

CODE_SIGN_ENTITLEMENTS = src/xhyve-entitlements.plist
OTHER_CODE_SIGN_FLAGS = -o library

Expand Down
3 changes: 2 additions & 1 deletion xhyve.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@
attributes = {
DefaultBuildSystemTypeForWorkspace = Latest;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = "xhyve";
ORGANIZATIONNAME = xhyve;
TargetAttributes = {
3F1934911BF7C0D40099CC46 = {
CreatedOnToolsVersion = 7.3;
Expand All @@ -597,6 +597,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 3F1934891BF7C0D40099CC46;
Expand Down