Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] libnfs: fix build of applications like mpd on musl
@ 2018-09-22 19:43 Fabrice Fontaine
  2018-09-23 14:52 ` Thomas Petazzoni
  0 siblings, 1 reply; 3+ messages in thread
From: Fabrice Fontaine @ 2018-09-22 19:43 UTC (permalink / raw)
  To: buildroot

Include sys/time.h if __linux__ is defined otherwise applications
including libnfs.h (such as mpd) will fail to build on musl:

/home/rclinux/rc-buildroot-test/scripts/instance-1/output/host/bin/x86_64-linux-g++ -DHAVE_CONFIG_H -I.  -DNDEBUG -I./src  -DSYSTEM_CONFIG_FILE_LOCATION='"/etc/mpd.conf"'  -I/home/rclinux/rc-buildroot-test/scripts/instance-1/output/host/bin/../x86_64-buildroot-linux-musl/sysroot/usr/include   -I/home/rclinux/rc-buildroot-test/scripts/instance-1/output/host/bin/../x86_64-buildroot-linux-musl/sysroot/usr/include    -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -pthread -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os   -fvisibility=hidden -fno-threadsafe-statics -fmerge-all-constants -ffast-math -ftree-vectorize -ffunction-sections -fdata-sections -Wall -Wextra -Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings -Wsign-compare -Wno-noexcept-type -c -o src/lib/nfs/libstorage_a-Error.o `test -f 'src/lib/nfs/Error.cxx' || echo './'`src/lib/nfs/Error.cxx
In file included from src/lib/nfs/Error.cxx:37:0:
/home/rclinux/rc-buildroot-test/scripts/instance-1/output/host/x86_64-buildroot-linux-musl/sysroot/usr/include/nfsc/libnfs.h:965:23: error: field 'atime' has incomplete type 'timeval'
        struct timeval atime;
                       ^~~~~
/home/rclinux/rc-buildroot-test/scripts/instance-1/output/host/x86_64-buildroot-linux-musl/sysroot/usr/include/nfsc/libnfs.h:965:15: note: forward declaration of 'struct timeval'
        struct timeval atime;

Fixes:
 - http://autobuild.buildroot.org/results/892469e34cb2f7e8fac4a79f8c51ca8e7235aef3

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 ...nally-include-sys-time.h-in-libnfs.h.patch | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 package/libnfs/0001-conditionally-include-sys-time.h-in-libnfs.h.patch

diff --git a/package/libnfs/0001-conditionally-include-sys-time.h-in-libnfs.h.patch b/package/libnfs/0001-conditionally-include-sys-time.h-in-libnfs.h.patch
new file mode 100644
index 0000000000..80b4fdca70
--- /dev/null
+++ b/package/libnfs/0001-conditionally-include-sys-time.h-in-libnfs.h.patch
@@ -0,0 +1,40 @@
+From e2b7bcfbc38336d12dfdd4e36af87be4352a16a9 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Sat, 22 Sep 2018 13:27:18 +0200
+Subject: [PATCH] conditionally include sys/time.h in libnfs.h
+
+Include sys/time.h if __linux__ is defined otherwise applications
+including libnfs.h (such as mpd) will fail to build on musl:
+
+/home/rclinux/rc-buildroot-test/scripts/instance-1/output/host/bin/x86_64-linux-g++ -DHAVE_CONFIG_H -I.  -DNDEBUG -I./src  -DSYSTEM_CONFIG_FILE_LOCATION='"/etc/mpd.conf"'  -I/home/rclinux/rc-buildroot-test/scripts/instance-1/output/host/bin/../x86_64-buildroot-linux-musl/sysroot/usr/include   -I/home/rclinux/rc-buildroot-test/scripts/instance-1/output/host/bin/../x86_64-buildroot-linux-musl/sysroot/usr/include    -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -pthread -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os   -fvisibility=hidden -fno-threadsafe-statics -fmerge-all-constants -ffast-math -ftree-vectorize -ffunction-sections -fdata-sections -Wall -Wextra -Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings -Wsign-compare -Wno-noexcept-type -c -o src/lib/nfs/libstorage_a-Error.o `test -f 'src/lib/nfs/Error.cxx' || echo './'`src/lib/nfs/Error.cxx
+In file included from src/lib/nfs/Error.cxx:37:0:
+/home/rclinux/rc-buildroot-test/scripts/instance-1/output/host/x86_64-buildroot-linux-musl/sysroot/usr/include/nfsc/libnfs.h:965:23: error: field 'atime' has incomplete type 'timeval'
+        struct timeval atime;
+                       ^~~~~
+/home/rclinux/rc-buildroot-test/scripts/instance-1/output/host/x86_64-buildroot-linux-musl/sysroot/usr/include/nfsc/libnfs.h:965:15: note: forward declaration of 'struct timeval'
+        struct timeval atime;
+
+Fixes:
+ - http://autobuild.buildroot.org/results/892469e34cb2f7e8fac4a79f8c51ca8e7235aef3
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ include/nfsc/libnfs.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/nfsc/libnfs.h b/include/nfsc/libnfs.h
+index 09dcf1c..23dcc98 100755
+--- a/include/nfsc/libnfs.h
++++ b/include/nfsc/libnfs.h
+@@ -24,7 +24,7 @@
+ #define _LIBNFS_H_
+ 
+ #include <stdint.h>
+-#if defined(__ANDROID__) || defined(AROS) \
++#if defined(__ANDROID__) || defined(AROS) || defined(__linux__) \
+  || ( defined(__APPLE__) && defined(__MACH__) )
+ #include <sys/time.h>
+ #else
+-- 
+2.17.1
+
-- 
2.17.1

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

* [Buildroot] [PATCH 1/1] libnfs: fix build of applications like mpd on musl
  2018-09-22 19:43 [Buildroot] [PATCH 1/1] libnfs: fix build of applications like mpd on musl Fabrice Fontaine
@ 2018-09-23 14:52 ` Thomas Petazzoni
  2018-09-23 16:24   ` Fabrice Fontaine
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2018-09-23 14:52 UTC (permalink / raw)
  To: buildroot

Hello,

On Sat, 22 Sep 2018 21:43:05 +0200, Fabrice Fontaine wrote:

> + #include <stdint.h>
> +-#if defined(__ANDROID__) || defined(AROS) \
> ++#if defined(__ANDROID__) || defined(AROS) || defined(__linux__) \
> +  || ( defined(__APPLE__) && defined(__MACH__) )
> + #include <sys/time.h>
> + #else

I think the proper fix would be to use the AC_HEADER_TIME macro
(https://www.gnu.org/software/autoconf/manual/autoconf.html#Particular-Headers).
First need to add:

AC_HEADER_TIME
AC_CHECK_HEADERS([sys/time.h])

And then in the code, do:

          #ifdef TIME_WITH_SYS_TIME
          # include <sys/time.h>
          # include <time.h>
          #else
          # ifdef HAVE_SYS_TIME_H
          #  include <sys/time.h>
          # else
          #  include <time.h>
          # endif
          #endif

Instead of the mess that is currently done based on the system on which
the stuff is being compiled.

Could you try to do this, and upstream the corresponding patch ?

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* [Buildroot] [PATCH 1/1] libnfs: fix build of applications like mpd on musl
  2018-09-23 14:52 ` Thomas Petazzoni
@ 2018-09-23 16:24   ` Fabrice Fontaine
  0 siblings, 0 replies; 3+ messages in thread
From: Fabrice Fontaine @ 2018-09-23 16:24 UTC (permalink / raw)
  To: buildroot

Dear Thomas,

Le dim. 23 sept. 2018 ? 16:52, Thomas Petazzoni <
thomas.petazzoni@bootlin.com> a ?crit :

> Hello,
>
> On Sat, 22 Sep 2018 21:43:05 +0200, Fabrice Fontaine wrote:
>
> > + #include <stdint.h>
> > +-#if defined(__ANDROID__) || defined(AROS) \
> > ++#if defined(__ANDROID__) || defined(AROS) || defined(__linux__) \
> > +  || ( defined(__APPLE__) && defined(__MACH__) )
> > + #include <sys/time.h>
> > + #else
>
> I think the proper fix would be to use the AC_HEADER_TIME macro
> (
> https://www.gnu.org/software/autoconf/manual/autoconf.html#Particular-Headers
> ).
> First need to add:
>
> AC_HEADER_TIME
> AC_CHECK_HEADERS([sys/time.h])
>
> And then in the code, do:
>
>           #ifdef TIME_WITH_SYS_TIME
>           # include <sys/time.h>
>           # include <time.h>
>           #else
>           # ifdef HAVE_SYS_TIME_H
>           #  include <sys/time.h>
>           # else
>           #  include <time.h>
>           # endif
>           #endif
>
> Instead of the mess that is currently done based on the system on which
> the stuff is being compiled.
>
> Could you try to do this, and upstream the corresponding patch ?
>
Actually, that's what has been done upstream for libnfs.c (
https://github.com/sahlberg/libnfs/commit/5c1444f391f8c29cc18fd644ab282b5a037e5798)
but this will not fix our issue.
Indeed, the build is not failing on libnfs but on mpd because mpd includes
libnfs.h which is a public header.
We can't enforce that all applications that use libnfs.h such as mpd should
make a call to AC_HEADER_TIME or AC_CHECK_HEADERS([sys/time.h]), do we?

>
> Thanks,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

Best Regards,

Fabrice
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180923/1d229520/attachment.html>

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

end of thread, other threads:[~2018-09-23 16:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-22 19:43 [Buildroot] [PATCH 1/1] libnfs: fix build of applications like mpd on musl Fabrice Fontaine
2018-09-23 14:52 ` Thomas Petazzoni
2018-09-23 16:24   ` Fabrice Fontaine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox