package/yajl: fix build when explicit link with libm is needed
PATCH 1/1 package/yajl: fix build when explicit link with libm is needed
This change adds another fix to the yajl build-system code. This patch checks for isnan function in libc, and if not, it makes sure libm is passed to the linker flags.
This change fixes build failure looking like:
make[3]: Entering directory /home/peko/autobuild/instance-2/output/build/yajl-2.1.0' [ 81%] Building C object example/CMakeFiles/parse_config.dir/parse_config.c.o ../yajl-2.1.0/lib/libyajl.so.2.1.0: undefined reference to __isnan' ../yajl-2.1.0/lib/libyajl.so.2.1.0: undefined reference to `__isinf'
collect2: error: ld returned 1 exit status
make[3]: *** [verify/json_verify] Error 1
Fixes:
http://autobuild.buildroot.org/results/312/31268e4d20aa34bb90c09aa771b1923f979578ab/
and many others
--- ...l-_s-with-libm-when-isnan-is-not-brought-.patch | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 package/yajl/0004-Link-libyajl-_s-with-libm-when-isnan-is-not-brought-.patch
package/yajl/0004-Link-libyajl-_s-with-libm-when-isnan-is-not-brought-.patch new file +64 -0
@@ -0,0 +1,64 @@ +From b47f6a50925efb8c8707b1faed5561a4b66ffdb1 Mon Sep 17 00:00:00 2001 +From: Samuel Martin <[email protected]> +Date: Sun, 24 Apr 2016 18:45:27 +0200 +Subject: [PATCH] Link libyajl{,_s} with libm when isnan is not brought by the + libc + +Check whether isnan is provided by the libc library, otherwise make sure +yajl libraries are link against libm. + +Note that setting libm as PUBLIC link libraries enable the transitivity +[1, 2]; therefore it will be automatically passed to target linking +against libyajl{,_s}. + +This patch also makes sure the link libraries will appear in the yajl.pc +file. + +[1] https://cmake.org/cmake/help/v3.5/command/target_link_libraries.html +[2] https://cmake.org/cmake/help/v3.5/manual/cmake-buildsystem.7.html#target-usage-requirements + +Signed-off-by: Samuel Martin <[email protected]> +--- + src/CMakeLists.txt | 10 ++++++++++ + src/yajl.pc.cmake | 2 +- + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index b487bfd..a88698f 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -35,11 +35,21 @@ SET (shareDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/share/pkgconfig) + # set the output path for libraries + SET(LIBRARY_OUTPUT_PATH ${libDir}) + ++SET(yajl_lib_link) ++INCLUDE(CheckLibraryExists) ++CHECK_LIBRARY_EXISTS(c isnan "" HAVE_LIBC_ISNAN) ++ ++IF(NOT HAVE_LIBC_ISNAN) ++ LIST(APPEND yajl_lib_link "-lm") ++ENDIF(NOT HAVE_LIBC_ISNAN) ++ + ADD_LIBRARY(yajl_s STATIC ${SRCS} ${HDRS} ${PUB_HDRS}) + SET_TARGET_PROPERTIES(yajl_s PROPERTIES OUTPUT_NAME yajl) ++TARGET_LINK_LIBRARIES(yajl_s PUBLIC ${yajl_lib_link}) + + IF(BUILD_SHARED_LIBS) + ADD_LIBRARY(yajl SHARED ${SRCS} ${HDRS} ${PUB_HDRS}) ++TARGET_LINK_LIBRARIES(yajl PUBLIC ${yajl_lib_link}) + + #### setup shared library version number + SET_TARGET_PROPERTIES(yajl PROPERTIES +diff --git a/src/yajl.pc.cmake b/src/yajl.pc.cmake +index 6eaca14..4681dd4 100644 +--- a/src/yajl.pc.cmake ++++ b/src/yajl.pc.cmake +@@ -6,4 +6,4 @@ Name: Yet Another JSON Library + Description: A Portable JSON parsing and serialization library in ANSI C + Version: ${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO} + Cflags: -I${dollar}{includedir} +-Libs: -L${dollar}{libdir} -lyajl ++Libs: -L${dollar}{libdir} -lyajl ${yajl_lib_link} +-- +2.8.0 +
Signature · 1 line
2.8.0
PATCH 1/1 package/yajl: fix build when explicit link with libm is needed
Am Sun, 24 Apr 2016 20:29:38 +0200 schrieb Samuel Martin:
Quoted 1 line
This change adds another fix to the yajl build-system code.
(compile-tested using gcc6/uclibc-ng)
Thomas Petazzoni
AppliedPATCH 1/1 package/yajl: fix build when explicit link with libm is needed
In reply to Samuel MartinHello,
Quoted 22 lines · Samuel Martin
This change adds another fix to the yajl build-system code. This patch checks for isnan function in libc, and if not, it makes sure libm is passed to the linker flags.
This change fixes build failure looking like:
make[3]: Entering directory
/home/peko/autobuild/instance-2/output/build/yajl-2.1.0' [ 81%] Building C object example/CMakeFiles/parse_config.dir/parse_config.c.o ../yajl-2.1.0/lib/libyajl.so.2.1.0: undefined reference to__isnan' ../yajl-2.1.0/lib/libyajl.so.2.1.0: undefined reference to `__isinf'
collect2: error: ld returned 1 exit status
make[3]: *** [verify/json_verify] Error 1Fixes:
http://autobuild.buildroot.org/results/312/31268e4d20aa34bb90c09aa771b1923f979578ab/
and many othersCc Beno?t Mauduit <[email protected]>Cc Bernd Kuhls <[email protected]>Cc J?rg Krause <[email protected]>Cc Vicente Olivert Riera <[email protected]>Signed-off-by Samuel Martin <[email protected]>
Quoted 4 lines
--- ...l-_s-with-libm-when-isnan-is-not-brought-.patch | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 package/yajl/0004-Link-libyajl-_s-with-libm-when-isnan-is-not-brought-.patch
Applied to master, thanks. Please submit upstream! Generally speaking, if some effort could be made to submit our 4 yajl patches upstream, it would be good.
Thanks a lot!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com