Skip to contentSkip to conversation

package/yajl: Update patch to link with libm

PATCH New Bernd Kuhls 2 participants 2 messages Apr 19, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/yajl: Update patch to link with libm

Currently yajl does not compile using gcc6 from
http://patchwork.ozlabs.org/patch/611249/

Patch 0003 needed a rebase after patch 0001 was replaced by a version which also works with gcc6.

This patch also fixes current build failures:
http://autobuild.buildroot.net/results/05b/05b1847bc838a328e7398d03a4bb0efb95ef3938/

---
v2: updated patch description, patch is needed not only for gcc6

 ...1-cmake-uClibc-Fix-missing-libm-for-tests.patch | 30 -------------------
 .../yajl/0001-cmake-uClibc-Fix-missing-libm.patch  | 34 ++++++++++++++++++++++
 ...ink-with-shared-libyajl-in-a-shared-build.patch |  6 ++--
 3 files changed, 37 insertions(+), 33 deletions(-)
 delete mode 100644 package/yajl/0001-cmake-uClibc-Fix-missing-libm-for-tests.patch
 create mode 100644 package/yajl/0001-cmake-uClibc-Fix-missing-libm.patch
package/yajl/0001-cmake-uClibc-Fix-missing-libm-for-tests.patch deleted +0 -30
deleted file mode 100644
index 08553f9..0000000
@@ -1,30 +0,0 @@
-From a36814a6f9fbb62f49897f9fb1e68d204602e199 Mon Sep 17 00:00:00 2001
-From: Maxime Hadjinlian <[email protected]>
-Date: Tue, 2 Feb 2016 17:28:31 +0100
-Subject: [PATCH] cmake: uClibc: Fix missing libm for tests
-
-At the link time, the tests are not linked against libm which cause an
-error with uClibc based toolchain:
-
-../../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'
-
-Signed-off-by: Maxime Hadjinlian <[email protected]>
----
- test/api/CMakeLists.txt | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/api/CMakeLists.txt b/test/api/CMakeLists.txt
-index cd65a54..e0ce2f6 100644
---- a/test/api/CMakeLists.txt
-+++ b/test/api/CMakeLists.txt
-@@ -21,5 +21,5 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/lib)
- FOREACH (test ${TESTS})
-   GET_FILENAME_COMPONENT(testProg ${test} NAME_WE)
-   ADD_EXECUTABLE(${testProg} ${test})
--  TARGET_LINK_LIBRARIES(${testProg} yajl)
-+  TARGET_LINK_LIBRARIES(${testProg} yajl m)
- ENDFOREACH()
--- 
-2.7.0
-
package/yajl/0001-cmake-uClibc-Fix-missing-libm.patch new file +34 -0
new file mode 100644
index 0000000..3564cb2
@@ -0,0 +1,34 @@
+From 76f6ead65b46e4a9cceca4e21efa940cc8a77a6e Mon Sep 17 00:00:00 2001
+From: Bernd Kuhls <[email protected]>
+Date: Sat, 16 Apr 2016 19:28:41 +0200
+Subject: [PATCH 1/1] cmake: uClibc: Fix missing libm
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Patch created by Ren? Rh?aume, downloaded from
+https://bugs.gentoo.org/show_bug.cgi?id=512738#c9
+
+Patch is discussed upstream:
+https://github.com/lloyd/yajl/pull/184#issuecomment-201549734
+
+Signed-off-by: Bernd Kuhls <[email protected]>
+---
+ CMakeLists.txt | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 471eee1..08d69ec 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -60,6 +60,7 @@ ELSE (WIN32)
+ 
+   SET(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g")
+   SET(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -Wuninitialized")
++  SET(CMAKE_SHARED_LINKER_FLAGS "-lm ${CMAKE_SHARED_LINKER_FLAGS}")
+ ENDIF (WIN32)
+ 
+ 
+-- 
+2.8.0.rc3
+
package/yajl/0003-Link-with-shared-libyajl-in-a-shared-build.patch +3 -3
index 6a6e5e3..46e652d 100644
@@ -82,11 +82,11 @@ index e0ce2f6..9adebdc 100644
  FOREACH (test ${TESTS})
    GET_FILENAME_COMPONENT(testProg ${test} NAME_WE)
    ADD_EXECUTABLE(${testProg} ${test})
--  TARGET_LINK_LIBRARIES(${testProg} yajl m)
+-  TARGET_LINK_LIBRARIES(${testProg} yajl)
 +  IF(BUILD_SHARED_LIBS)
-+    TARGET_LINK_LIBRARIES(${testProg} yajl m)
++    TARGET_LINK_LIBRARIES(${testProg} yajl)
 +  ELSE()
-+    TARGET_LINK_LIBRARIES(${testProg} yajl_s m)
++    TARGET_LINK_LIBRARIES(${testProg} yajl_s)
 +  ENDIF()
  ENDFOREACH()
 diff --git a/test/parsing/CMakeLists.txt b/test/parsing/CMakeLists.txt
Signature · 1 line
2.8.0.rc3
#1 lore raw

PATCH v2 1/1 package/yajl: Update patch to link with libm

Dear Bernd Kuhls,

Quoted 133 lines · Bernd Kuhls

Currently yajl does not compile using gcc6 from
http://patchwork.ozlabs.org/patch/611249/

Patch 0003 needed a rebase after patch 0001 was replaced by a version which also works with gcc6.

This patch also fixes current build failures:
http://autobuild.buildroot.net/results/05b/05b1847bc838a328e7398d03a4
bb0efb95ef3938/

---
v2: updated patch description, patch is needed not only for gcc6

?...1-cmake-uClibc-Fix-missing-libm-for-tests.patch | 30 ------------
-------
?.../yajl/0001-cmake-uClibc-Fix-missing-libm.patch??| 34
++++++++++++++++++++++
?...ink-with-shared-libyajl-in-a-shared-build.patch |??6 ++-- ?3 files changed, 37 insertions(+), 33 deletions(-) ?delete mode 100644 package/yajl/0001-cmake-uClibc-Fix-missing-libm- for-tests.patch
?create mode 100644 package/yajl/0001-cmake-uClibc-Fix-missing- libm.patch

(quoted diff) +0 -0

tests.patch b/package/yajl/0001-cmake-uClibc-Fix-missing-libm-for- tests.patch
deleted file mode 100644
index 08553f9..0000000

package/yajl/0001-cmake-uClibc-Fix-missing-libm-for-tests.patch deleted +0 -1
@@ -1,30 +0,0 @@
-From a36814a6f9fbb62f49897f9fb1e68d204602e199 Mon Sep 17 00:00:00

2001

package/yajl/0001-cmake-uClibc-Fix-missing-libm-for-tests.patch deleted +0 -5
-From: Maxime Hadjinlian <[email protected]>
-Date: Tue, 2 Feb 2016 17:28:31 +0100
-Subject: [PATCH] cmake: uClibc: Fix missing libm for tests
-
-At the link time, the tests are not linked against libm which cause

an

package/yajl/0001-cmake-uClibc-Fix-missing-libm-for-tests.patch deleted +0 -3
-error with uClibc based toolchain:
-
-../../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'

package/yajl/0001-cmake-uClibc-Fix-missing-libm-for-tests.patch deleted +0 -11
-
-Signed-off-by: Maxime Hadjinlian <[email protected]>
----
- test/api/CMakeLists.txt | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/api/CMakeLists.txt b/test/api/CMakeLists.txt
-index cd65a54..e0ce2f6 100644
---- a/test/api/CMakeLists.txt
-+++ b/test/api/CMakeLists.txt
-@@ -21,5 +21,5 @@

LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/ lib)
- FOREACH (test ${TESTS}) -???GET_FILENAME_COMPONENT(testProg ${test} NAME_WE) -???ADD_EXECUTABLE(${testProg} ${test}) --??TARGET_LINK_LIBRARIES(${testProg} yajl) -+??TARGET_LINK_LIBRARIES(${testProg} yajl m)
- ENDFOREACH()
---?
-2.7.0

package/yajl/0001-cmake-uClibc-Fix-missing-libm-for-tests.patch deleted +0 -1
-
package/yajl/0001-cmake-uClibc-Fix-missing-libm.patch new file +1 -0
new file mode 100644
index 0000000..3564cb2
@@ -0,0 +1,34 @@
+From 76f6ead65b46e4a9cceca4e21efa940cc8a77a6e Mon Sep 17 00:00:00

2001

package/yajl/0001-cmake-uClibc-Fix-missing-libm.patch new file +33 -0
+From: Bernd Kuhls <[email protected]>
+Date: Sat, 16 Apr 2016 19:28:41 +0200
+Subject: [PATCH 1/1] cmake: uClibc: Fix missing libm
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Patch created by Ren? Rh?aume, downloaded from
+https://bugs.gentoo.org/show_bug.cgi?id=512738#c9
+
+Patch is discussed upstream:
+https://github.com/lloyd/yajl/pull/184#issuecomment-201549734
+
+Signed-off-by: Bernd Kuhls <[email protected]>
+---
+ CMakeLists.txt | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 471eee1..08d69ec 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -60,6 +60,7 @@ ELSE (WIN32)
+?
+???SET(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g")
+???SET(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -Wuninitialized")
++??SET(CMAKE_SHARED_LINKER_FLAGS "-lm ${CMAKE_SHARED_LINKER_FLAGS}")
+ ENDIF (WIN32)
+?
+?
+--?
+2.8.0.rc3
+
(quoted diff) +0 -0

build.patch b/package/yajl/0003-Link-with-shared-libyajl-in-a-shared- build.patch
index 6a6e5e3..46e652d 100644
--- a/package/yajl/0003-Link-with-shared-libyajl-in-a-shared- build.patch
+++ b/package/yajl/0003-Link-with-shared-libyajl-in-a-shared- build.patch

(quoted diff) +3 -3
@@ -82,11 +82,11 @@ index e0ce2f6..9adebdc 100644
 ? FOREACH (test ${TESTS})
 ????GET_FILENAME_COMPONENT(testProg ${test} NAME_WE)
 ????ADD_EXECUTABLE(${testProg} ${test})
--??TARGET_LINK_LIBRARIES(${testProg} yajl m)
+-??TARGET_LINK_LIBRARIES(${testProg} yajl)
 ?+??IF(BUILD_SHARED_LIBS)
-+????TARGET_LINK_LIBRARIES(${testProg} yajl m)
++????TARGET_LINK_LIBRARIES(${testProg} yajl)
 ?+??ELSE()
-+????TARGET_LINK_LIBRARIES(${testProg} yajl_s m)
++????TARGET_LINK_LIBRARIES(${testProg} yajl_s)
 ?+??ENDIF()
 ? ENDFOREACH()
Quoted 2 lines

?diff --git a/test/parsing/CMakeLists.txt
b/test/parsing/CMakeLists.txt

While this patch indeed fixes the build issue for shared builds, it does not for static builds.

In my opinion the macro?CMAKE_SHARED_LINKER_FLAGS is not the right place to add the library. I would prefer to use TARGET_LINK_LIBRARIES. Of course, it's tedious to add '-lm' to each CMakeLists.txt, so a macro YAJL_LIBS should be defined and used instead.

Furthermore, linking with libmath is not required with every C library, so the need for '-lm' could (should?) be detected and added to YAJL_LIBS conditionally.

Best regards
J?rg Krause