-
Notifications
You must be signed in to change notification settings - Fork 51
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
fix macos portability issues (fifth batch) #6479
Conversation
static int * get_open_fds (int maxfd) | ||
{ | ||
/* Valgrind may show open fds > maxfd, so double the space | ||
* allocated so we don't overflow when run under valgrind. | ||
*/ | ||
int * fds = calloc (maxfd * 2, sizeof (int)); | ||
if (fds) | ||
ok (fdwalk (set_fd, fds) == 0, | ||
ok (fdwalk (set_fd_if_open, fds) == 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also do this in test_fdwalk_fallback()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing much motivation for doing that, are you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just wanted to make sure it wasn't missed by accident :-)
int valid_flags = O_CLOEXEC | O_NONBLOCK; | ||
|
||
if ((flags & ~valid_flags)) { | ||
errno = EINVAL; | ||
return -1; | ||
} | ||
if ((flags & O_CLOEXEC)) { | ||
if (fd_set_cloexec (fd) < 0) | ||
return -1; | ||
} | ||
if ((flags & O_NONBLOCK)) { | ||
if (fd_set_nonblocking (fd) < 0) | ||
return -1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what you did here doesn't match your commit message. Not sure if you changed mind on what to do and just need to update commit message? hopefully not a rebase mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are just helper functions that do what it says in the commit message but I guess that could be made more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed a tweak to the commit message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, you know what it is. Seeing the very generic prior implementation, the appearance is that more/other flags would have been supported.
But I now see that pipe2()
only supports three flags, one of which appears to be linux only. so the new setflags()
supports every flag for pipe2()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. If compilation is working then we should consider adding a macos build to CI to avoid future PRs breaking the build.
src/shell/oom.c
Outdated
@@ -20,7 +20,9 @@ | |||
#endif | |||
#include <sys/types.h> | |||
#include <sys/stat.h> | |||
#ifdef HAVE_SYS_INOTIFY_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this plugin should just be conditionally not compiled on macos, since we know cgroups are never supported there? However, perhaps this way is just easier since you don't have to modify the bulitin plugin list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that seems obvious now that you mention it. Let me try that way.
Problem: the shell oom plugin won't compile on macos because it doesn't have inotify. Make compilation conditional on inotify.
Problem: there is an extra "to" in an error message. Fix it.
Problem: macos doesn't have /proc/self/exe so flux(1) cannot determine if it is installed or not. Provide an executable_selfdir() implementation for macos that uses _NSGetExecutablePath(). See also: dyld(3).
Problem: the fdwalk unit test fails on macos The failing test assumes that fdwalk visits only the open file descriptors, which is the case for linux but not when the fallback implementation is used. Modify the test to check the file descriptors before tallying.
Problem: the intree unit test uses pthread barriers, an optional POSIX feature that is missing on macos. Provide a simple alternate implementation within the test if barriers are unavailable.
Problem: the pipe2(2) libmissing implementation sets O_CLOEXEC incorrectly. Use helpers that call fcntl (F_SETFD, FD_CLOEXEC) instead of calling fcntl (F_SETFL, O_CLOEXEC), which is wrong. Adjust linkage to ensure that helper gets linked in where needed.
Problem: compilation fails on macos in various places becuase SOCK_NONBLOCK is undefined. Set O_NONBLOCK with fcntl(2) after socket creation if SOCK_NONBLOCK is undefined.
Problem: compilation fails in various places on macos due to undefined kill(2). Include signal.h where needed.
Problem: compilation fails on macos with 'environ' undefined. Just define it locally where needed.
Problem: compilation fails in some places where get_current_dir_name() is used. Use the fallback in libmissing where needed.
Problem: compilation of test program fails due to missing jansson headers. Add $(JANSSON_CFLAGS) to AM_CPPFLAGS.
Problem: compilation fails on macos when %ju or %jd is used with non-matching integer types. Cast them to [u]intmax_t.
OK, I reworked the oom plugin it's just not built if inotify is unavailable. Perhaps we can add a macos builder another day? It would have to just do a |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6479 +/- ##
==========================================
- Coverage 83.60% 83.60% -0.01%
==========================================
Files 524 524
Lines 87617 87621 +4
==========================================
+ Hits 73256 73257 +1
- Misses 14361 14364 +3
|
Chicken mon dieu! This macos nightmare is finally over for now. |
Ok. If/when we do that we'll probably have to fix portability issues we introduce between now and then. Since we have no macos users and it doesn't work anyway, that's pretty low priority IMO. |
I'll open an issue on that one for now. |
Last batch of macos fixes.
I think this gets everything compiled, including tests but there are still unit test failures to deal with. Anyway, this is as far as I got for now.