diff mbox series

[v2,1/1] zeromq: check if -latomic is needed

Message ID 20180507202623.29498-1-asafka7@gmail.com
State Accepted
Headers show
Series [v2,1/1] zeromq: check if -latomic is needed | expand

Commit Message

Asaf Kahlon May 7, 2018, 8:26 p.m. UTC
Fixes:
http://autobuild.buildroot.net/results/b149aa2ee00e4d6a53c884cf99ecb2dd8af58b65/
http://autobuild.buildroot.net/results/e4b3616ac2695d3b6898185a70da6509b1faa2b8/

Patch the package to check if -latomic is needed to be added, depending on the
result of AC_LINK_IFELSE.

The patch was sent to upstream, see:
https://github.com/zeromq/libzmq/pull/3083

Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
---

v2: fix typos and small refactoring.

 ...nclude.m4-check-if-latomic-is-needed.patch | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 package/zeromq/0002-acinclude.m4-check-if-latomic-is-needed.patch

Comments

Thomas Petazzoni May 7, 2018, 9:24 p.m. UTC | #1
Hello,

On Mon,  7 May 2018 23:26:23 +0300, Asaf Kahlon wrote:
> Fixes:
> http://autobuild.buildroot.net/results/b149aa2ee00e4d6a53c884cf99ecb2dd8af58b65/
> http://autobuild.buildroot.net/results/e4b3616ac2695d3b6898185a70da6509b1faa2b8/
> 
> Patch the package to check if -latomic is needed to be added, depending on the
> result of AC_LINK_IFELSE.

Thanks for this new iteration.

> The patch was sent to upstream, see:
> https://github.com/zeromq/libzmq/pull/3083

Sadly, this pull request corresponds to the previous iteration, and it
has been merged. Perhaps you can send a follow-up patch upstream to
improve the situation ?

Thanks!

Thomas
Asaf Kahlon May 8, 2018, 3:46 a.m. UTC | #2
Sure, I'll send an update on the upstream.
Would it be necessary to send a new patch here? It will probably be the
same code, just the pull request link on the commit message will change
(and we won't be able to have a link with all the patch anyway since half
of it was already merged).

Thanks,
Asaf.

On Tue, May 8, 2018, 00:24 Thomas Petazzoni <thomas.petazzoni@bootlin.com>
wrote:

> Hello,
>
> On Mon,  7 May 2018 23:26:23 +0300, Asaf Kahlon wrote:
> > Fixes:
> >
> http://autobuild.buildroot.net/results/b149aa2ee00e4d6a53c884cf99ecb2dd8af58b65/
> >
> http://autobuild.buildroot.net/results/e4b3616ac2695d3b6898185a70da6509b1faa2b8/
> >
> > Patch the package to check if -latomic is needed to be added, depending
> on the
> > result of AC_LINK_IFELSE.
>
> Thanks for this new iteration.
>
> > The patch was sent to upstream, see:
> > https://github.com/zeromq/libzmq/pull/3083
>
> Sadly, this pull request corresponds to the previous iteration, and it
> has been merged. Perhaps you can send a follow-up patch upstream to
> improve the situation ?
>
> Thanks!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
<div dir="auto">Sure, I&#39;ll send an update on the upstream.<div dir="auto">Would it be necessary to send a new patch here? It will probably be the same code, just the pull request link on the commit message will change (and we won&#39;t be able to have a link with all the patch anyway since half of it was already merged).<div dir="auto"><br></div><div dir="auto">Thanks,</div><div dir="auto">Asaf.</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, May 8, 2018, 00:24 Thomas Petazzoni &lt;<a href="mailto:thomas.petazzoni@bootlin.com" target="_blank" rel="noreferrer">thomas.petazzoni@bootlin.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
On Mon,  7 May 2018 23:26:23 +0300, Asaf Kahlon wrote:<br>
&gt; Fixes:<br>
&gt; <a href="http://autobuild.buildroot.net/results/b149aa2ee00e4d6a53c884cf99ecb2dd8af58b65/" rel="noreferrer noreferrer noreferrer" target="_blank">http://autobuild.buildroot.net/results/b149aa2ee00e4d6a53c884cf99ecb2dd8af58b65/</a><br>
&gt; <a href="http://autobuild.buildroot.net/results/e4b3616ac2695d3b6898185a70da6509b1faa2b8/" rel="noreferrer noreferrer noreferrer" target="_blank">http://autobuild.buildroot.net/results/e4b3616ac2695d3b6898185a70da6509b1faa2b8/</a><br>
&gt; <br>
&gt; Patch the package to check if -latomic is needed to be added, depending on the<br>
&gt; result of AC_LINK_IFELSE.<br>
<br>
Thanks for this new iteration.<br>
<br>
&gt; The patch was sent to upstream, see:<br>
&gt; <a href="https://github.com/zeromq/libzmq/pull/3083" rel="noreferrer noreferrer noreferrer" target="_blank">https://github.com/zeromq/libzmq/pull/3083</a><br>
<br>
Sadly, this pull request corresponds to the previous iteration, and it<br>
has been merged. Perhaps you can send a follow-up patch upstream to<br>
improve the situation ?<br>
<br>
Thanks!<br>
<br>
Thomas<br>
-- <br>
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)<br>
Embedded Linux and Kernel engineering<br>
<a href="https://bootlin.com" rel="noreferrer noreferrer noreferrer" target="_blank">https://bootlin.com</a><br>
</blockquote></div>
Thomas Petazzoni May 8, 2018, 1 p.m. UTC | #3
Hello,

On Mon,  7 May 2018 23:26:23 +0300, Asaf Kahlon wrote:
> Fixes:
> http://autobuild.buildroot.net/results/b149aa2ee00e4d6a53c884cf99ecb2dd8af58b65/
> http://autobuild.buildroot.net/results/e4b3616ac2695d3b6898185a70da6509b1faa2b8/
> 
> Patch the package to check if -latomic is needed to be added, depending on the
> result of AC_LINK_IFELSE.
> 
> The patch was sent to upstream, see:
> https://github.com/zeromq/libzmq/pull/3083
> 
> Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
> ---

Applied to master, thanks.

Thomas
diff mbox series

Patch

diff --git a/package/zeromq/0002-acinclude.m4-check-if-latomic-is-needed.patch b/package/zeromq/0002-acinclude.m4-check-if-latomic-is-needed.patch
new file mode 100644
index 0000000000..6f3671c4a0
--- /dev/null
+++ b/package/zeromq/0002-acinclude.m4-check-if-latomic-is-needed.patch
@@ -0,0 +1,70 @@ 
+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 1/1] 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>
+---
+ acinclude.m4 | 32 ++++++++++++++++++++++++++++----
+ 1 file changed, 28 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,33 @@ 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_LDFLAGS=$LDFLAGS
++        LDFLAGS="$LDFLAGS -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" LIBS="-latomic"],
++        [libzmq_cv_has_atomic_instrisics="no"])
++        LDFLAGS=$save_LDFLAGS
++    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
+