bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: "Tim Rühsen" <tim.ruehsen@gmx.de>
Subject: Re: FreeBSD 11.2: glthread build failure
Date: Mon, 20 Jan 2020 04:01:05 +0100	[thread overview]
Message-ID: <1770813.AsgGKQxQiM@omega> (raw)
In-Reply-To: <efa75c19-081c-222f-316e-ebd411211848@gmx.de>

Hi Tim,

> > FreeBSD 11.2-RELEASE-p4 (with clang 6.0):
> > 
> >   CCLD     wget2

Please make it a habit to use "make V=1" when submitting a report.
I don't want to see "CCLD wget2"; I want to see the actual link
command line.

> > /usr/bin/ld: undefined reference to symbol
> > `pthread_mutexattr_gettype@@FBSD_1.0' (try adding -lthr)
> > //lib/libthr.so.3: could not read symbols: Bad value
> > clang: error: linker command failed with exit code 1 (use -v to see
> > invocation)
> > gmake[2]: *** [Makefile:1697: wget2] Error 1

I reproduce the issue
  - with a wget2-1.99.2.tar.gz tarball downloaded from
    https://gitlab.com/gnuwget/wget2/pipelines
  - when configuring with --disable-shared
  - on FreeBSD 11, NOT on FreeBSD 12,
  - NOT when configuring with --disable-shared --without-lzma

The problem is that, somehow, weak symbols don't work well when linking
with a library that has a dependency to libpthread.so (-> libthr.so)
- liblzma.so in this case.

Since gnulib cannot forbid any package from linking with liblzma, gnulib
has to avoid using weak symbols in this case.

This patch should fix the problem.


2020-01-19  Bruno Haible  <bruno@clisp.org>

	threadlib: Disable use of weak symbols on FreeBSD 11.
	Reported by Tim Rühsen <tim.ruehsen@gmx.de> in
	<https://lists.gnu.org/archive/html/bug-gnulib/2020-01/msg00061.html>.
	* m4/threadlib.m4 (gl_WEAK_SYMBOLS): Require AC_CANONICAL_HOST. Test
	against a bug in FreeBSD 11.

diff --git a/m4/threadlib.m4 b/m4/threadlib.m4
index e64ad62..94441f6 100644
--- a/m4/threadlib.m4
+++ b/m4/threadlib.m4
@@ -1,4 +1,4 @@
-# threadlib.m4 serial 26
+# threadlib.m4 serial 27
 dnl Copyright (C) 2005-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -81,6 +81,7 @@ dnl Checks whether the compiler and linker support weak declarations of symbols.
 
 AC_DEFUN([gl_WEAK_SYMBOLS],
 [
+  AC_REQUIRE([AC_CANONICAL_HOST])
   AC_CACHE_CHECK([whether imported symbols can be declared weak],
     [gl_cv_have_weak],
     [gl_cv_have_weak=no
@@ -119,6 +120,30 @@ int main ()
      case " $LDFLAGS " in
        *" -static "*) gl_cv_have_weak=no ;;
      esac
+     dnl Test for a bug in FreeBSD 11: A link error occurs when using a weak
+     dnl symbol and linking against a shared library that has a dependency on
+     dnl the shared library that defines the symbol.
+     case "$gl_cv_have_weak" in
+       *yes)
+         case "$host_os" in
+           freebsd* | dragonfly*)
+             : > conftest1.c
+             $CC $CPPFLAGS $CFLAGS $LDFLAGS -fPIC -shared -o libempty.so conftest1.c -lpthread >&AS_MESSAGE_LOG_FD 2>&1
+             cat <<EOF > conftest2.c
+#include <pthread.h>
+#pragma weak pthread_mutexattr_gettype
+int main ()
+{
+  return (pthread_mutexattr_gettype != NULL);
+}
+EOF
+             $CC $CPPFLAGS $CFLAGS $LDFLAGS -o conftest conftest2.c libempty.so >&AS_MESSAGE_LOG_FD 2>&1 \
+               || gl_cv_have_weak=no
+             rm -f conftest1.c libempty.so conftest2.c conftest
+             ;;
+         esac
+         ;;
+     esac
     ])
   case "$gl_cv_have_weak" in
     *yes)



  reply	other threads:[~2020-01-20  3:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 15:03 FreeBSD 11.2: glthread build failure Tim Rühsen
2020-01-09 10:04 ` Tim Rühsen
2020-01-20  3:01   ` Bruno Haible [this message]
2020-01-20  9:33     ` Tim Rühsen
2020-01-20 17:31       ` Bruno Haible
2020-01-20 18:04       ` Bruno Haible
2020-01-30 15:25         ` Tim Rühsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1770813.AsgGKQxQiM@omega \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=tim.ruehsen@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).