Skip to contentSkip to conversation

zeromq: fix static build with libatomic

PATCH New Fabrice Fontaine 3 participants 3 messages Sep 13, 2018 – Oct 1, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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

---
 ...cinclude.m4-check-if-latomic-is-needed.patch | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
package/zeromq/0002-acinclude.m4-check-if-latomic-is-needed.patch +9 -8
index a0c188a5c3..233b364662 100644
@@ -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 <[email protected]>
+Signed-off-by: Fabrice Fontaine <[email protected]>
+[Update to use LIBS: https://github.com/zeromq/libzmq/pull/3250]
 ---
- acinclude.m4 | 32 ++++++++++++++++++++++++++++----
- 1 file changed, 28 insertions(+), 4 deletions(-)
+ acinclude.m4 | 31 +++++++++++++++++++++++++++----
+ 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
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 zeromq: fix static build with libatomic

Hello,

Quoted 16 lines · Fabrice Fontaine

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

Quoted 7 lines

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

---
 ...cinclude.m4-check-if-latomic-is-needed.patch | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 zeromq: fix static build with libatomic

In reply to Fabrice Fontaine
Quoted 15 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Fabrice" == Fabrice Fontaine <[email protected]> writes:

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

Quoted 7 lines

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

Committed to 2018.05.x and 2018.08.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard