From 7d71a30f149c6a140975a474047c758d80a1fcd4 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 16 Jul 2017 14:49:21 +0200
Subject: [PATCH] threadlib: Support static linking.

* m4/threadlib.m4 (gl_THREADLIB_BODY): When static linking is in use,
set gl_cv_have_weak to 'no'.
---
 ChangeLog       | 6 ++++++
 m4/threadlib.m4 | 6 +++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index fdc2993922..7865c05f4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-07-16  Bruno Haible  <bruno@clisp.org>
+
+	threadlib: Support static linking.
+	* m4/threadlib.m4 (gl_THREADLIB_BODY): When static linking is in use,
+	set gl_cv_have_weak to 'no'.
+
 2017-07-16  Bruno Haible  <bruno@clisp.org>
 
 	unicase/locale-language: Fix link dependencies.
diff --git a/m4/threadlib.m4 b/m4/threadlib.m4
index f79fde20f5..6fd1b9e87a 100644
--- a/m4/threadlib.m4
+++ b/m4/threadlib.m4
@@ -1,4 +1,4 @@
-# threadlib.m4 serial 12
+# threadlib.m4 serial 13
 dnl Copyright (C) 2005-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -148,6 +148,10 @@ int main ()
               [gl_cv_have_weak="guessing no"])
            ])
        fi
+       dnl But when linking statically, weak symbols don't work.
+       case " $LDFLAGS " in
+         *" -static "*) gl_cv_have_weak=no ;;
+       esac
       ])
     if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
       # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
-- 
2.39.5