Openembedded Core Discussions
 help / color / mirror / Atom feed
From: "André Draszik" <git@andred.net>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 2/4] json-c: backport patch to fix uClibc link issues
Date: Fri, 24 Jun 2016 11:54:29 +0100	[thread overview]
Message-ID: <1466765671-22371-2-git-send-email-git@andred.net> (raw)
In-Reply-To: <1466765671-22371-1-git-send-email-git@andred.net>

From: André Draszik <adraszik@tycoint.com>

We need to link against libm as we get linker errors otherwise:

<sysroot>/usr/lib/libjson-c.so.2: undefined reference to `__isnan'
<sysroot>/usr/lib/libjson-c.so.2: undefined reference to `__isinf'
collect2: error: ld returned 1 exit status

Backport the upstream patch.

Signed-off-by: André Draszik <adraszik@tycoint.com>
---
 .../0001-Link-against-libm-when-needed.patch       | 53 ++++++++++++++++++++++
 meta/recipes-devtools/json-c/json-c_0.12.bb        |  1 +
 2 files changed, 54 insertions(+)
 create mode 100644 meta/recipes-devtools/json-c/json-c/0001-Link-against-libm-when-needed.patch

diff --git a/meta/recipes-devtools/json-c/json-c/0001-Link-against-libm-when-needed.patch b/meta/recipes-devtools/json-c/json-c/0001-Link-against-libm-when-needed.patch
new file mode 100644
index 0000000..bfe9d72
--- /dev/null
+++ b/meta/recipes-devtools/json-c/json-c/0001-Link-against-libm-when-needed.patch
@@ -0,0 +1,53 @@
+From 93582ad85ef48c18ac12f00a9a9e124989b1fcab Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Date: Fri, 1 May 2015 12:52:18 +0200
+Subject: [PATCH] Link against libm when needed
+
+In certain C libraries (e.g uClibc), isnan() and related functions are
+implemented in libm, so json-c needs to link against it. This commit
+therefore adds an AC_TRY_LINK() test to check whether a program
+calling isnan() can be properly linked with no special flags. If not,
+we assume linking against libm is needed.
+
+The json-c.pc.in file is also adjusted so that in the case of static
+linking against json-c, -lm is also used.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+---
+Upstream-Status: Backport
+
+ configure.ac | 4 ++++
+ json-c.pc.in | 3 ++-
+ 2 files changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index c50f81b..30e7174 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -50,6 +50,10 @@ AC_CHECK_DECLS([isinf], [], [], [[#include <math.h>]])
+ AC_CHECK_DECLS([_isnan], [], [], [[#include <float.h>]])
+ AC_CHECK_DECLS([_finite], [], [], [[#include <float.h>]])
+ 
++if test "$ac_cv_have_decl_isnan" = "yes" ; then
++   AC_TRY_LINK([#include <math.h>], [float f = 0.0; return isnan(f)], [], [LIBS="$LIBS -lm"])
++fi
++
+ #check if .section.gnu.warning accepts long strings (for __warn_references)
+ AC_LANG_PUSH([C])
+ 
+diff --git a/json-c.pc.in b/json-c.pc.in
+index 037739d..05bfbc8 100644
+--- a/json-c.pc.in
++++ b/json-c.pc.in
+@@ -6,6 +6,7 @@ includedir=@includedir@
+ Name: json-c
+ Description: JSON implementation in C
+ Version: @VERSION@
+-Requires: 
++Requires:
++Libs.private: @LIBS@
+ Libs:  -L${libdir} -ljson-c
+ Cflags: -I${includedir}/json-c
+-- 
+2.8.1
+
diff --git a/meta/recipes-devtools/json-c/json-c_0.12.bb b/meta/recipes-devtools/json-c/json-c_0.12.bb
index 1a5c394..d8c76db 100644
--- a/meta/recipes-devtools/json-c/json-c_0.12.bb
+++ b/meta/recipes-devtools/json-c/json-c_0.12.bb
@@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=de54b60fbbc35123ba193fea8ee216f2"
 
 SRC_URI = "https://s3.amazonaws.com/json-c_releases/releases/${BP}.tar.gz \
            file://0001-json_tokener-requires-INF-and-NAN.patch \
+           file://0001-Link-against-libm-when-needed.patch \
           "
 
 SRC_URI[md5sum] = "3ca4bbb881dfc4017e8021b5e0a8c491"
-- 
2.8.1



  reply	other threads:[~2016-06-24 10:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-24 10:54 [PATCH 1/4] libidn: fix QA warning (uClibc) André Draszik
2016-06-24 10:54 ` André Draszik [this message]
2016-06-24 10:54 ` [PATCH 3/4] uclibc: backport patch to fix gdb 7.11 compilation André Draszik
2016-06-24 13:52   ` Khem Raj
2016-06-24 14:39   ` [PATCH 3/4 v2] " André Draszik
2016-06-24 10:54 ` [PATCH 4/4] uclibc: really enable verbose compilation André Draszik
2016-06-24 13:46   ` Khem Raj
2016-06-24 13:51     ` Burton, Ross
2016-06-24 13:57       ` Khem Raj
2016-06-24 14:19         ` André Draszik
2016-06-24 14:32           ` André Draszik
2016-06-24 14:59           ` Khem Raj
2016-06-24 15:30   ` [PATCH 4/4 v2] uclibc: re-enable " André Draszik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466765671-22371-2-git-send-email-git@andred.net \
    --to=git@andred.net \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox