kumquat-buildroot/package/zeromq/0002-acinclude.m4-check-if-latomic-is-needed.patch
Fabrice Fontaine 14f5cb7daa zeromq: fix static build with libatomic
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>
2018-09-13 20:58:14 +02:00

72 lines
2.4 KiB
Diff

From 9f4ca582555b208d065f730b5ce3b1901136b275 Mon Sep 17 00:00:00 2001
From: Asaf Kahlon <asafka7@gmail.com>
Date: Mon, 7 May 2018 23:19:09 +0300
Subject: [PATCH] acinclude.m4: check if -latomic is needed
On some cases, -latomic is needed for linking, and since the current
acinclude.m4 checks only compilation we can sometimes miss the need for -latomic
and the linking process will fail.
Therefore, the AC_CHECK_IFELSE was replaced with AC_LINK_IFELSE. If the first
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 | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index f648ed0f..aa35195f 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -668,7 +668,7 @@ dnl # Check if compiler supoorts __atomic_Xxx intrinsics
dnl ################################################################################
AC_DEFUN([LIBZMQ_CHECK_ATOMIC_INTRINSICS], [{
AC_MSG_CHECKING(whether compiler supports __atomic_Xxx intrinsics)
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+ AC_LINK_IFELSE([AC_LANG_SOURCE([
/* atomic intrinsics test */
int v = 0;
int main (int, char **)
@@ -677,9 +677,32 @@ int main (int, char **)
return t;
}
])],
- [AC_MSG_RESULT(yes) ; libzmq_cv_has_atomic_instrisics="yes" ; $1],
- [AC_MSG_RESULT(no) ; libzmq_cv_has_atomic_instrisics="no" ; $2]
- )
+ [libzmq_cv_has_atomic_instrisics="yes"],
+ [libzmq_cv_has_atomic_instrisics="no"])
+
+ if test "x$libzmq_cv_has_atomic_instrisics" = "xno"; then
+ save_LIBS=$LIBS
+ LIBS="$LIBS -latomic"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([
+ /* atomic intrinsics test */
+ int v = 0;
+ int main (int, char **)
+ {
+ int t = __atomic_add_fetch (&v, 1, __ATOMIC_ACQ_REL);
+ return t;
+ }
+ ])],
+ [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
+ AC_MSG_RESULT(yes)
+ $1
+ else
+ AC_MSG_RESULT(no)
+ $2
+ fi
}])
dnl ################################################################################
--
2.17.0