Discussion:
Compiling GNU Sharutils on NetBSD
(too old to reply)
HIRAMATSU Yoshifumi
2015-04-06 09:47:33 UTC
Permalink
Hello,

Compiling Sharutil on recent NetBSD fails. This mail describes shortly.


In GNU Sharutil's lib/fseeko.c, line 134 starts comment about NetBSD.

/* Use a union, since on NetBSD, the compilation flags
determine whether fpos_t is typedef'd to off_t or a struct
containing a single off_t member. */

However, NetBSD changed definition of _offset from fpos_t struct to __off_t,
which is typedef of __int64_t.

So the following code does not match the definition of FILE, results in build fail.

See -> http://cvsweb.netbsd.org/bsdweb.cgi/src/include/stdio.h.diff?r1=1.79&r2=1.80&f=h


This patch fixes compilation and "make check" succeed.

--- lib/fseeko.c.orig 2015-04-05 22:42:44.000000000 +0900
+++ lib/fseeko.c 2015-04-05 22:42:52.000000000 +0900
@@ -125,7 +125,7 @@
fp->_flags &= ~_IO_EOF_SEEN;
fp->_offset = pos;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
-# if defined __CYGWIN__
+# if defined __CYGWIN__ || defined __NetBSD__
/* fp_->_offset is typed as an integer. */
fp_->_offset = pos;
# else


Kind regards,
HIRAMATSU, Yoshifumi
Eric Blake
2015-04-06 14:54:07 UTC
Permalink
[adding gnulib, as owner of the file in question]
Post by HIRAMATSU Yoshifumi
Hello,
Compiling Sharutil on recent NetBSD fails. This mail describes shortly.
In GNU Sharutil's lib/fseeko.c, line 134 starts comment about NetBSD.
/* Use a union, since on NetBSD, the compilation flags
determine whether fpos_t is typedef'd to off_t or a struct
containing a single off_t member. */
However, NetBSD changed definition of _offset from fpos_t struct to __off_t,
which is typedef of __int64_t.
When did this change occur? Yes, gnulib should be taught to support it.
Post by HIRAMATSU Yoshifumi
So the following code does not match the definition of FILE, results in build fail.
See -> http://cvsweb.netbsd.org/bsdweb.cgi/src/include/stdio.h.diff?r1=1.79&r2=1.80&f=h
This patch fixes compilation and "make check" succeed.
Thanks for the patch; hopefully someone with more NetBSD familiarity
will confirm if this works for both pre- and post-change NetBSD FILE
definitions; otherwise, we may need to be a bit more careful to ensure
that we aren't breaking older systems.
Post by HIRAMATSU Yoshifumi
--- lib/fseeko.c.orig 2015-04-05 22:42:44.000000000 +0900
+++ lib/fseeko.c 2015-04-05 22:42:52.000000000 +0900
@@ -125,7 +125,7 @@
fp->_flags &= ~_IO_EOF_SEEN;
fp->_offset = pos;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
-# if defined __CYGWIN__
+# if defined __CYGWIN__ || defined __NetBSD__
/* fp_->_offset is typed as an integer. */
fp_->_offset = pos;
# else
Kind regards,
HIRAMATSU, Yoshifumi
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
HIRAMATSU Yoshifumi
2015-04-06 18:26:50 UTC
Permalink
On Mon, 06 Apr 2015 23:54:07 +0900,
Post by Eric Blake
When did this change occur? Yes, gnulib should be taught to support it.
Changed when NetBSD 6 is released.
Post by Eric Blake
Thanks for the patch; hopefully someone with more NetBSD familiarity
will confirm if this works for both pre- and post-change NetBSD FILE
definitions; otherwise, we may need to be a bit more careful to ensure
that we aren't breaking older systems.
Yes, I agree. My previous patch broke for NetBSD 5.

I modified the patch to use "__NetBSD_Version__" macro, tested and confirmed
that compile succeeded both 5 and 6.

--- lib/fseeko.c.orig 2015-04-05 22:42:44.000000000 +0900
+++ lib/fseeko.c 2015-04-05 22:42:52.000000000 +0900
@@ -125,7 +125,7 @@
fp->_flags &= ~_IO_EOF_SEEN;
fp->_offset = pos;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
-# if defined __CYGWIN__
+# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000)
/* fp_->_offset is typed as an integer. */
fp_->_offset = pos;
# else


Kind regards,
HIRAMATSU, Yoshifumi
Bruce Korb
2015-04-08 19:23:20 UTC
Permalink
Post by HIRAMATSU Yoshifumi
--- lib/fseeko.c.orig 2015-04-05 22:42:44.000000000 +0900
+++ lib/fseeko.c 2015-04-05 22:42:52.000000000 +0900
@@ -125,7 +125,7 @@
fp->_flags &= ~_IO_EOF_SEEN;
fp->_offset = pos;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
-# if defined __CYGWIN__
+# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000)
/* fp_->_offset is typed as an integer. */
fp_->_offset = pos;
# else
$ grep -E $'^[ \t]*.*NetBSD' lib/fseeko.c
Please let me know when this has been patched so I can re-roll sharutils. Thanks.
Pádraig Brady
2015-04-14 10:23:06 UTC
Permalink
Post by Bruce Korb
Post by HIRAMATSU Yoshifumi
--- lib/fseeko.c.orig 2015-04-05 22:42:44.000000000 +0900
+++ lib/fseeko.c 2015-04-05 22:42:52.000000000 +0900
@@ -125,7 +125,7 @@
fp->_flags &= ~_IO_EOF_SEEN;
fp->_offset = pos;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
-# if defined __CYGWIN__
+# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000)
/* fp_->_offset is typed as an integer. */
fp_->_offset = pos;
# else
$ grep -E $'^[ \t]*.*NetBSD' lib/fseeko.c
Please let me know when this has been patched so I can re-roll sharutils. Thanks.
Pushed at http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=f2c88dc
Loading...