All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] libfastjson: indicate explicitly which gcc -std option to use
@ 2017-11-17 15:14 Thomas Petazzoni
  2017-11-18  8:04 ` Peter Korsgaard
  2017-11-27  9:35 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2017-11-17 15:14 UTC (permalink / raw)
  To: buildroot

This commit fixes the following build issue of libfastjson with old
enough compilers (4.8) and wchar disabled:

json_object.c: In function 'fjson_object_object_delete':
json_object.c:385:3: error: 'for' loop initial declarations are only allowed in C99 mode
   for (int i = 0 ; i < FJSON_OBJECT_CHLD_PG_SIZE ; ++i) {
   ^

The code of libfastjson requires C99. If your compiler is recent
enough (gcc 5.x), then no problem, it is C99 by default, no additional
flags are needed.

If your compiler is older (for example gcc 4.8), then -std=c99 or
-std=gnu99 is explicitly needed to tell the compiler to accept C99
constructs. Testing the compiler for the availability of such flags is
done by libfastjson configure script. However, the test program used
by the configure script uses some wchar_t types, and therefore the
test checking for C99 availability fails on toolchains with wchar
disabled. From config.log:

configure:3928: checking for /home/test/buildroot/output/host/usr/bin/i586-buildroot-linux-uclibc-gcc option to accept ISO C99
[...]
configure:4077: /home/test/buildroot/output/host/usr/bin/i586-buildroot-linux-uclibc-gcc -std=gnu99 -c -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 conftest.c >&5
conftest.c:54:3: error: unknown type name 'wchar_t'
   const wchar_t *name;
   ^

So, just like we did in libv4l in commit
f01396a158f14c53b781c35f7ff29da0bea8c8d6 ("libv4l: fix uclibc-ng
configure/compile"), let's hint directly the configure script that it
should use -std=gnu99. This fixes the build of libfastjson with old
compilers and wchar disabled.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 package/libfastjson/libfastjson.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/package/libfastjson/libfastjson.mk b/package/libfastjson/libfastjson.mk
index b1cdd6a158..06da0d8edd 100644
--- a/package/libfastjson/libfastjson.mk
+++ b/package/libfastjson/libfastjson.mk
@@ -7,6 +7,7 @@
 LIBFASTJSON_VERSION = v0.99.4
 LIBFASTJSON_SITE = $(call github,rsyslog,libfastjson,$(LIBFASTJSON_VERSION))
 LIBFASTJSON_INSTALL_STAGING = YES
+LIBFASTJSON_CONF_ENV = ac_cv_prog_cc_c99='-std=gnu99'
 # From git
 LIBFASTJSON_AUTORECONF = YES
 LIBFASTJSON_LICENSE = MIT
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH] libfastjson: indicate explicitly which gcc -std option to use
  2017-11-17 15:14 [Buildroot] [PATCH] libfastjson: indicate explicitly which gcc -std option to use Thomas Petazzoni
@ 2017-11-18  8:04 ` Peter Korsgaard
  2017-11-27  9:35 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2017-11-18  8:04 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

 > This commit fixes the following build issue of libfastjson with old
 > enough compilers (4.8) and wchar disabled:

 > json_object.c: In function 'fjson_object_object_delete':
 > json_object.c:385:3: error: 'for' loop initial declarations are only allowed in C99 mode
 >    for (int i = 0 ; i < FJSON_OBJECT_CHLD_PG_SIZE ; ++i) {
 >    ^

 > The code of libfastjson requires C99. If your compiler is recent
 > enough (gcc 5.x), then no problem, it is C99 by default, no additional
 > flags are needed.

 > If your compiler is older (for example gcc 4.8), then -std=c99 or
 > -std=gnu99 is explicitly needed to tell the compiler to accept C99
 > constructs. Testing the compiler for the availability of such flags is
 > done by libfastjson configure script. However, the test program used
 > by the configure script uses some wchar_t types, and therefore the
 > test checking for C99 availability fails on toolchains with wchar
 > disabled. From config.log:

 > configure:3928: checking for /home/test/buildroot/output/host/usr/bin/i586-buildroot-linux-uclibc-gcc option to accept ISO C99
 > [...]
 > configure:4077: /home/test/buildroot/output/host/usr/bin/i586-buildroot-linux-uclibc-gcc -std=gnu99 -c -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 conftest.c >&5
 > conftest.c:54:3: error: unknown type name 'wchar_t'
 >    const wchar_t *name;
 >    ^

 > So, just like we did in libv4l in commit
 > f01396a158f14c53b781c35f7ff29da0bea8c8d6 ("libv4l: fix uclibc-ng
 > configure/compile"), let's hint directly the configure script that it
 > should use -std=gnu99. This fixes the build of libfastjson with old
 > compilers and wchar disabled.

 > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

Committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH] libfastjson: indicate explicitly which gcc -std option to use
  2017-11-17 15:14 [Buildroot] [PATCH] libfastjson: indicate explicitly which gcc -std option to use Thomas Petazzoni
  2017-11-18  8:04 ` Peter Korsgaard
@ 2017-11-27  9:35 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2017-11-27  9:35 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

 > This commit fixes the following build issue of libfastjson with old
 > enough compilers (4.8) and wchar disabled:

 > json_object.c: In function 'fjson_object_object_delete':
 > json_object.c:385:3: error: 'for' loop initial declarations are only allowed in C99 mode
 >    for (int i = 0 ; i < FJSON_OBJECT_CHLD_PG_SIZE ; ++i) {
 >    ^

 > The code of libfastjson requires C99. If your compiler is recent
 > enough (gcc 5.x), then no problem, it is C99 by default, no additional
 > flags are needed.

 > If your compiler is older (for example gcc 4.8), then -std=c99 or
 > -std=gnu99 is explicitly needed to tell the compiler to accept C99
 > constructs. Testing the compiler for the availability of such flags is
 > done by libfastjson configure script. However, the test program used
 > by the configure script uses some wchar_t types, and therefore the
 > test checking for C99 availability fails on toolchains with wchar
 > disabled. From config.log:

 > configure:3928: checking for /home/test/buildroot/output/host/usr/bin/i586-buildroot-linux-uclibc-gcc option to accept ISO C99
 > [...]
 > configure:4077: /home/test/buildroot/output/host/usr/bin/i586-buildroot-linux-uclibc-gcc -std=gnu99 -c -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 conftest.c >&5
 > conftest.c:54:3: error: unknown type name 'wchar_t'
 >    const wchar_t *name;
 >    ^

 > So, just like we did in libv4l in commit
 > f01396a158f14c53b781c35f7ff29da0bea8c8d6 ("libv4l: fix uclibc-ng
 > configure/compile"), let's hint directly the configure script that it
 > should use -std=gnu99. This fixes the build of libfastjson with old
 > compilers and wchar disabled.

 > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

Committed to 2017.02.x and 2017.08.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-27  9:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-17 15:14 [Buildroot] [PATCH] libfastjson: indicate explicitly which gcc -std option to use Thomas Petazzoni
2017-11-18  8:04 ` Peter Korsgaard
2017-11-27  9:35 ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.