[commit: ghc] master: Enforce linkage with pthread library on OpenBSD (c8e866a)

git at git.haskell.org git at git.haskell.org
Sun Nov 1 09:47:03 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/c8e866a190d4d5866bf364ee794db28b227a2e0e/ghc

>---------------------------------------------------------------

commit c8e866a190d4d5866bf364ee794db28b227a2e0e
Author: Karel Gardas <karel.gardas at centrum.cz>
Date:   Sun Nov 1 10:18:55 2015 +0100

    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


>---------------------------------------------------------------

c8e866a190d4d5866bf364ee794db28b227a2e0e
 configure.ac        | 9 +++++++++
 rts/package.conf.in | 8 ++++++++
 2 files changed, 17 insertions(+)

diff --git a/configure.ac b/configure.ac
index bc18c12..6bd2103 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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.])],
diff --git a/rts/package.conf.in b/rts/package.conf.in
index 97cc4f9..fff645d 100644
--- a/rts/package.conf.in
+++ b/rts/package.conf.in
@@ -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



More information about the ghc-commits mailing list