Skip to content

libkqueue as git submodule #76

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

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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "libpwq"]
path = libpwq
url = https://github.com/mheily/libpwq.git
[submodule "libkqueue"]
path = libkqueue
url = https://github.com/ianpartridge/libkqueue.git
2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Prepare your system
2. Install dtrace (to generate provider.h)
sudo apt-get install systemtap-sdt-dev
3. Install libdispatch pre-reqs
sudo apt-get install libblocksruntime-dev libkqueue-dev libbsd-dev
sudo apt-get install libblocksruntime-dev libbsd-dev
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't quite do that, as I think that it won't fly long term with distributions to not use the system's libkqueue. so I wouldn't touch this, but use pkg-config or some method in configure to check that the system libkqueue is recent enough to have the right fixes instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We did an identical change when we added libpwq as a git submodule.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know, but the situation with libpwq is different: libdispatch is its only client on the system ever so having dispatch "disptribute" it is fine.

libkqueue is different, it has other clients on the system and other OSS projects use it, so while I understand the motivation of this patch for swift development purposes, I don't think we can ship like that.

Copy link
Contributor

Choose a reason for hiding this comment

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

IOW I think it's completely fine to be able to use the submodule, but that should be for development purposes only, unlike libpwq

Copy link
Contributor

Choose a reason for hiding this comment

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

@MadCoder that makes sense. Once we have a final list of fixes needed and know which level of libkqueue those fixes make it in to, we can definitely take the approach of only using a submodule if the system installed levels are too old.


Initialize git submodules:
We are using git submodules to incorporate a specific revision of the
Expand Down
29 changes: 14 additions & 15 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,30 @@
ACLOCAL_AMFLAGS = -I m4

if BUILD_OWN_PTHREAD_WORKQUEUES
MAYBE_PTHREAD_WORKQUEUES = libpwq
endif

if BUILD_OWN_KQUEUES
MAYBE_KQUEUES = libkqueue
endif

SUBDIRS= \
dispatch \
libpwq \
man \
os \
private \
src \
tests
else
SUBDIRS= \
dispatch \
man \
os \
$(MAYBE_PTHREAD_WORKQUEUES) \
$(MAYBE_KQUEUES) \
man \
os \
private \
src \
src \
tests
endif

EXTRA_DIST= \
README.md \
LICENSE \
PATCHES \
autogen.sh \
config/config.h \
libdispatch.xcodeproj \
config/config.h \
libdispatch.xcodeproj \
resolver \
tools \
xcodeconfig \
Expand Down
18 changes: 13 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,20 @@ esac
AC_SEARCH_LIBS(clock_gettime, rt)
AC_SEARCH_LIBS(pthread_create, pthread)

#
# Prefer native kqueue(2); otherwise use libkqueue if present.
#
AC_CHECK_HEADER(sys/event.h, [],
[PKG_CHECK_MODULES(KQUEUE, libkqueue)]
AS_IF([test -f $srcdir/libkqueue/configure.ac],
[AC_DEFINE(BUILD_OWN_KQUEUES, 1, [Define if building libkqueue from source])
ac_configure_args="--disable-libkqueue-install $ac_configure_args"
AC_CONFIG_SUBDIRS([libkqueue])
build_own_kqueues=true],
[build_own_kqueues=false
AC_CHECK_HEADER(sys/event.h, [],
[AC_SEARCH_LIBS([kqueue], [kqueue], [],
[AC_MSG_ERROR([unable to find kqueue() function])]
)]
)
]
)
AM_CONDITIONAL(BUILD_OWN_KQUEUES, $build_own_kqueues)

AC_CHECK_FUNCS([strlcpy getprogname], [],
[PKG_CHECK_MODULES(BSD_OVERLAY, libbsd-overlay,[
Expand Down
1 change: 1 addition & 0 deletions libkqueue
Submodule libkqueue added at 549b82
13 changes: 10 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,19 @@ AM_CPPFLAGS=-I$(top_builddir) -I$(top_srcdir) \
-I$(top_srcdir)/private -I$(top_srcdir)/os

DISPATCH_CFLAGS=-Wall $(VISIBILITY_FLAGS) $(OMIT_LEAF_FP_FLAGS) \
$(MARCH_FLAGS) $(KQUEUE_CFLAGS) $(BSD_OVERLAY_CFLAGS)
AM_CFLAGS= $(PTHREAD_WORKQUEUE_CFLAGS) $(DISPATCH_CFLAGS) $(CBLOCKS_FLAGS)
$(MARCH_FLAGS) $(BSD_OVERLAY_CFLAGS)
AM_CFLAGS=$(KQUEUE_CFLAGS) $(PTHREAD_WORKQUEUE_CFLAGS) $(DISPATCH_CFLAGS) $(CBLOCKS_FLAGS)
AM_OBJCFLAGS=$(DISPATCH_CFLAGS) $(CBLOCKS_FLAGS)
AM_CXXFLAGS=$(PTHREAD_WORKQUEUE_CFLAGS) $(DISPATCH_CFLAGS) $(CXXBLOCKS_FLAGS)
AM_CXXFLAGS=$(KQUEUE_CFLAGS) $(PTHREAD_WORKQUEUE_CFLAGS) $(DISPATCH_CFLAGS) $(CXXBLOCKS_FLAGS)
AM_OBJCXXFLAGS=$(DISPATCH_CFLAGS) $(CXXBLOCKS_FLAGS)

if BUILD_OWN_KQUEUES
KQUEUE_LIBS=$(top_builddir)/libkqueue/libkqueue.la
KQUEUE_CFLAGS=-I$(top_srcdir)/libkqueue/include
else
KQUEUE_CFLAGS=-I/usr/local/include/kqueue
endif

if BUILD_OWN_PTHREAD_WORKQUEUES
PTHREAD_WORKQUEUE_LIBS=$(top_builddir)/libpwq/libpthread_workqueue.la
PTHREAD_WORKQUEUE_CFLAGS=-I$(top_srcdir)/libpwq/include
Expand Down
7 changes: 7 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ AM_OBJCFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CBLOCKS_FLAGS)
AM_CXXFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CXXBLOCKS_FLAGS) $(BSD_OVERLAY_CFLAGS)
AM_OBJCXXFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CXXBLOCKS_FLAGS)

if BUILD_OWN_KQUEUES
KQUEUE_LIBS=$(top_builddir)/libkqueue/libkqueue.la
KQUEUE_CFLAGS=-I$(top_srcdir)/libkqueue/include
else
KQUEUE_CFLAGS=-I/usr/local/include/kqueue
endif

if !BUILD_OWN_PTHREAD_WORKQUEUES
if HAVE_PTHREAD_WORKQUEUES
PTHREAD_WORKQUEUE_LIBS=-lpthread_workqueue
Expand Down