zeromq: fix static build with libatomic
authorFabrice Fontaine <fontaine.fabrice@gmail.com>
Thu, 13 Sep 2018 18:24:19 +0000 (20:24 +0200)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Thu, 13 Sep 2018 18:58:14 +0000 (20:58 +0200)
Second patch added support to link with -latomic if needed however using
LDFLAGS doesn't work when statically linking because LDFLAGS is added
before LIBS

Detection of atomic fails with:

configure:23230: /accts/mlweber1/instance-2/output/host/bin/sparc-linux-g++ -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os   -static -static -pedantic -Werror -Wall -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE -Wno-long-long -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -static -latomic conftest.cpp -lrt -lpthread -lstdc++ >&5
/tmp/ccgrvVTg.o: In function `main':
conftest.cpp:(.text.startup+0x10): undefined reference to `__atomic_fetch_add_4'
collect2: error: ld returned 1 exit status

So use LIBS instead of LDFLAGS

As second patch was already merged upstream, a new PR was sent:
https://github.com/zeromq/libzmq/pull/3250

Fixes:
 - http://autobuild.buildroot.net/results/c471d6b1061a8516f7772735e471db68a32965aa

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/zeromq/0002-acinclude.m4-check-if-latomic-is-needed.patch

index a0c188a5c3fa1774fd427233d33040a4a6d84ece..233b364662e39cd91532c738862ea0e630451a13 100644 (file)
@@ -11,9 +11,11 @@ try fails, we try to link again with -latomic and add LIBS="-latomic" in case we
 succeeded.
 
 Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+[Update to use LIBS: https://github.com/zeromq/libzmq/pull/3250]
 ---
- acinclude.m4 | 32 ++++++++++++++++++++++++++++----
- 1 file changed, 28 insertions(+), 4 deletions(-)
+ acinclude.m4 | 3+++++++++++++++++++++++++++----
+ 1 file changed, 27 insertions(+), 4 deletions(-)
 
 diff --git a/acinclude.m4 b/acinclude.m4
 index f648ed0f..aa35195f 100644
@@ -28,7 +30,7 @@ index f648ed0f..aa35195f 100644
  /* atomic intrinsics test */
  int v = 0;
  int main (int, char **)
-@@ -677,9 +677,33 @@ int main (int, char **)
+@@ -677,9 +677,32 @@ int main (int, char **)
      return t;
  }
      ])],
@@ -39,8 +41,8 @@ index f648ed0f..aa35195f 100644
 +    [libzmq_cv_has_atomic_instrisics="no"])
 +
 +    if test "x$libzmq_cv_has_atomic_instrisics" = "xno"; then
-+        save_LDFLAGS=$LDFLAGS
-+        LDFLAGS="$LDFLAGS -latomic"
++        save_LIBS=$LIBS
++        LIBS="$LIBS -latomic"
 +        AC_LINK_IFELSE([AC_LANG_SOURCE([
 +        /* atomic intrinsics test */
 +        int v = 0;
@@ -50,9 +52,8 @@ index f648ed0f..aa35195f 100644
 +            return t;
 +        }
 +        ])],
-+        [libzmq_cv_has_atomic_instrisics="yes" LIBS="-latomic"],
-+        [libzmq_cv_has_atomic_instrisics="no"])
-+        LDFLAGS=$save_LDFLAGS
++        [libzmq_cv_has_atomic_instrisics="yes"],
++        [libzmq_cv_has_atomic_instrisics="no" LIBS=$save_LIBS])
 +    fi
 +
 +    if test "x$libzmq_cv_has_atomic_instrisics" = "xyes"; then