Commit c8e866a1 authored by kgardas's avatar kgardas Committed by Ben Gamari

Enforce linkage with pthread library on OpenBSD

This patch enforces linkage with pthread library on OpenBSD. This is
done in order to avoid linker errors when linking with libffi which
requires POSIX threading but itself is not linked with libpthread
directly. So client binaries (of libffi) needs to link against
libpthread explicitly

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, erikd

Differential Revision: https://phabricator.haskell.org/D1410
parent 4ad2a8f9
......@@ -919,6 +919,15 @@ AS_IF([test "$UseSystemLibFFI" = "YES"], [
CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
LDFLAGS2="$LDFLAGS"
LDFLAGS="$LIBFFI_LDFLAGS $LDFLAGS"
if test "$HostOS" = "openbsd";
then
# OpenBSD's libffi is not directly linked to the libpthread but
# still requires pthread functionality. This means that any client
# binary which links with libffi also needs to link with
# libpthread. If it does not, then linking fails with unresolved
# symbols.
LDFLAGS="$LDFLAGS -lpthread"
fi
AC_CHECK_LIB(ffi, ffi_call,
[AC_CHECK_HEADERS([ffi.h], [break], [])
AC_DEFINE([HAVE_LIBFFI], [1], [Define to 1 if you have libffi.])],
......
......@@ -45,6 +45,14 @@ extra-libraries:
#ifdef freebsd_HOST_OS
, "pthread" /* for pthread_getthreadid_np() */
#endif
#ifdef openbsd_HOST_OS
/* OpenBSD's libffi is not directly linked to the libpthread but still requires
pthread functionality. This means that any client binary which links with libffi
also need to link with libpthread. If it does not, then linking fails with
unresolved symbols. */
, "pthread"
#endif
#if defined(DEBUG) && defined(HAVE_LIBBFD)
,"bfd", "iberty" /* for debugging */
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment