Skip to content

Commit

Permalink
build: add configure --with-external-libev
Browse files Browse the repository at this point in the history
Problem: libev asserts in ev_epoll.c on macos.

Assertion failed: (("libev: I/O watcher with invalid fd found in epoll_ctl", errno != EBADF && errno != ELOOP && errno != EINVAL)), function epoll_modify, file ev_epoll.c, line 134.

The fact that libev is using epoll, which is not native to macos,
indicates that its configure logic is getting confused by the presence
of the epoll-shim (required for the flux_t handle implementation).

Get around this by adding a configure option --with-external-libev so
we can use the homebrew libev, which is properly configured to use kqueue
instead of epoll.

Fixes flux-framework#6485
  • Loading branch information
garlick committed Dec 14, 2024
1 parent 9ff2e53 commit 1ae37d2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
13 changes: 11 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,18 @@ RRA_WITH_SYSTEMD_UNITDIR


##
# Embedded libev
# libev
##
m4_include([src/common/libev/libev.m4])
AC_ARG_WITH([external-libev],
AS_HELP_STRING([--with-external-libev], [Use external libev]))
AS_IF([test "x$with_external_libev" = "xyes"], [
AC_SEARCH_LIBS([ev_run], [ev], [], [
AC_MSG_ERROR([--with-external-libev requested but external libev not found])
])
],[
m4_include([src/common/libev/libev.m4])
])
AM_CONDITIONAL([INTERNAL_LIBEV],[test "x$with_external_libev" != "xyes"])

AC_PKGCONFIG

Expand Down
8 changes: 6 additions & 2 deletions src/common/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
SUBDIRS = \
libtap \
libtestutil \
libev \
libyuarel \
libpmi \
liblsd \
Expand Down Expand Up @@ -30,6 +29,9 @@ SUBDIRS = \
libfilemap \
libsdexec \
libmissing
if INTERNAL_LIBEV
SUBDIRS += libev
endif

AM_CFLAGS = $(WARNING_CFLAGS) $(CODE_COVERAGE_CFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LIBS)
Expand All @@ -45,7 +47,6 @@ libflux_internal_la_LIBADD = \
$(builddir)/libccan/libccan.la \
$(builddir)/libutil/libutil.la \
$(builddir)/libidset/libidset.la \
$(builddir)/libev/libev.la \
$(builddir)/libyuarel/libyuarel.la \
$(builddir)/libtomlc99/libtomlc99.la \
$(builddir)/libeventlog/libeventlog.la \
Expand All @@ -62,6 +63,9 @@ libflux_internal_la_LIBADD = \
$(LIBDL) \
$(LIBRT) \
$(FLUX_SECURITY_LIBS)
if INTERNAL_LIBEV
libflux_internal_la_LIBADD += $(builddir)/libev/libev.la
endif
libflux_internal_la_LDFLAGS = $(san_ld_zdef_flag)

lib_LTLIBRARIES = libflux-core.la \
Expand Down
4 changes: 4 additions & 0 deletions src/common/libflux/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ AM_CPPFLAGS = \
$(JANSSON_CFLAGS) \
$(LIBUUID_CFLAGS)

if INTERNAL_LIBEV
AM_CPPFLAGS += -I$(top_srcdir)/src/common/libev
endif

fluxcoreinclude_HEADERS = \
flux.h \
types.h \
Expand Down
3 changes: 1 addition & 2 deletions src/common/libflux/reactor.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
#include <errno.h>
#include <stdbool.h>
#include <fcntl.h>
#include <ev.h>
#include <flux/core.h>

#include "src/common/libev/ev.h"

#include "reactor_private.h"

struct flux_reactor {
Expand Down
3 changes: 1 addition & 2 deletions src/common/libflux/watcher_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
#include "config.h"
#endif
#include <assert.h>
#include <ev.h>
#include <flux/core.h>

#include "src/common/libev/ev.h"

#include "reactor_private.h"
#include "watcher_private.h"

Expand Down

0 comments on commit 1ae37d2

Please sign in to comment.