Skip to contentSkip to conversation

package/libfastjson: fix build without threads

PATCH New Yann E. MORIN 2 participants 3 messages Jul 10, 2016 – Jul 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/libfastjson: fix build without threads

libfastjsn is supposed to use the __sync_*4 atomic intrinsics, but alas it is not using them because their ./configure decides they are not
available: it uses AC_TRY_RUN to check for them, and the default is to decide they are not available, because of cross-compilation.

Besides, one of the source files was not including the generated config.h, so even after fixing ./configure there was still a build error.

The first patch is a backport from upstream to fix the missing inclusion.

The second patch is switching AC_TRY_RUN over to AC_LINK_IFELSE, as the only thing we're interested in is to check for the presence of the atomic intrisics, and linking is enough for that.

Fixes:

    http://autobuild.buildroot.org/results/192/1923d0b570adba494f83747a9610ea6ec35f5223/
    http://autobuild.buildroot.org/results/23a/23ac0e742ed3a70ae4d038f8c9eadc23e708f671/
    and many others...
---
 .../libfastjson/0001-fix-missing-config.h.patch    | 29 ++++++++
 .../0002-m4-fix-detection-of-atomics.patch         | 87 ++++++++++++++++++++++
 2 files changed, 116 insertions(+)
 create mode 100644 package/libfastjson/0001-fix-missing-config.h.patch
 create mode 100644 package/libfastjson/0002-m4-fix-detection-of-atomics.patch
package/libfastjson/0001-fix-missing-config.h.patch new file +29 -0
new file mode 100644
index 0000000..8663e23
@@ -0,0 +1,29 @@
+From 3e017fe8da1e821d4fcd801c75467c8ec2a81eb4 Mon Sep 17 00:00:00 2001
+From: Rainer Gerhards <[email protected]>
+Date: Tue, 19 Apr 2016 08:21:50 +0200
+Subject: [PATCH] fix missing config.h
+
+[yann.morin.1998 at free.fr: backport from upstream]
+Signed-off-by: "Yann E. MORIN" <[email protected]>
+
+---
+ json_object_iterator.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/json_object_iterator.c b/json_object_iterator.c
+index 6ab3a85..fb51f6e 100644
+--- a/json_object_iterator.c
++++ b/json_object_iterator.c
+@@ -17,8 +17,8 @@
+ *******************************************************************************
+ */
+ 
++#include "config.h"
+ #include <stddef.h>
+-
+ #include "json.h"
+ #include "json_object_private.h"
+ #include "json_object_iterator.h"
+-- 
+2.7.4
+
package/libfastjson/0002-m4-fix-detection-of-atomics.patch new file +87 -0

87 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 package/libfastjson: can use threads instead of atomics

When atomic intrisics are missing, libfastjson falls back to using pthread mutexes to manage atomicity. Of course, this is much less efficient than atomics, but it does the job.

Propagate the new dependency to rsyslog, the sole user of libfastjson.

Note: rsyslog already depends on threads for itself, but we believe it is better to have the exact same dependency propagated.

---
 package/libfastjson/Config.in | 4 ++--
 package/rsyslog/Config.in     | 6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)
package/libfastjson/Config.in +2 -2
index 5a94113..fbc9b1d 100644
@@ -1,7 +1,7 @@
 config BR2_PACKAGE_LIBFASTJSON
 	bool "libfastjson"
-	# uses __sync_val_compare_and_swap_4
-	depends on BR2_TOOLCHAIN_HAS_SYNC_4
+	# uses the __sync_*_4 intrisics, or pthreads to emulate atomicity
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4 || BR2_TOOLCHAIN_HAS_THREADS
 	help
 	  Libfastjson - A fast json library for C
 
package/rsyslog/Config.in +4 -2
index 65291de..b3c146d 100644
@@ -7,7 +7,9 @@ config BR2_PACKAGE_RSYSLOG
 	depends on BR2_TOOLCHAIN_HAS_THREADS
 	depends on BR2_USE_MMU # fork()
 	depends on !BR2_STATIC_LIBS # modules
-	depends on BR2_TOOLCHAIN_HAS_SYNC_4 # libfastjson
+	# Propagate the exact same dependency from libfastjson,
+	# even though rsyslog already depends on threads for itself:
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4 || BR2_TOOLCHAIN_HAS_THREADS
 	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 	help
 	  Rsyslog is a powerful and flexible syslog implementation
@@ -18,4 +20,4 @@ comment "rsyslog needs a toolchain w/ threads, dynamic library"
 	depends on BR2_USE_MMU
 	depends on BR2_TOOLCHAIN_HAS_SYNC_4
 	depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS
-	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
\ No newline at end of file
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/2 package/libfastjson: fix build without threads

In reply to Yann E. MORIN

Hello,

Quoted 21 lines · Yann E. MORIN

libfastjsn is supposed to use the __sync_*4 atomic intrinsics, but alas it is not using them because their ./configure decides they are not
available: it uses AC_TRY_RUN to check for them, and the default is to decide they are not available, because of cross-compilation.

Besides, one of the source files was not including the generated config.h, so even after fixing ./configure there was still a build error.

The first patch is a backport from upstream to fix the missing inclusion.

The second patch is switching AC_TRY_RUN over to AC_LINK_IFELSE, as the only thing we're interested in is to check for the presence of the atomic intrisics, and linking is enough for that.

Fixes:

    http://autobuild.buildroot.org/results/192/1923d0b570adba494f83747a9610ea6ec35f5223/
    http://autobuild.buildroot.org/results/23a/23ac0e742ed3a70ae4d038f8c9eadc23e708f671/
    and many others...
Quoted 8 lines
---
 .../libfastjson/0001-fix-missing-config.h.patch    | 29 ++++++++
 .../0002-m4-fix-detection-of-atomics.patch         | 87 ++++++++++++++++++++++
 2 files changed, 116 insertions(+)
 create mode 100644 package/libfastjson/0001-fix-missing-config.h.patch
 create mode 100644 package/libfastjson/0002-m4-fix-detection-of-atomics.patch

Both applied, thanks! I fixed some minor typos here and here along the way.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com