Subject: toolchain/23260: host tool build needs byteorder.h check
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dmcmahill@netbsd.org>
List: netbsd-bugs
Date: 10/24/2003 08:15:52
>Number:         23260
>Category:       toolchain
>Synopsis:       host tool build needs byteorder.h check
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 24 12:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Dan McMahill
>Release:        NetBSD 20031020
>Organization:
NetBSD
>Environment:
Solaris-2.6/sparc with gcc-2.95.1 as the host system
	
	
System: NetBSD bondage 1.6.1 NetBSD 1.6.1 (BONDAGE) #0: Mon Apr 21 18:28:45 EDT 2003 dan@bondage:/export/disk1/src/src-netbsd-1-6-1/sys/arch/alpha/compile/BONDAGE alpha
Architecture: alpha
Machine: alpha
>Description:
When trying to build the cross toolchain with build.sh, a couple of the tools
fail on solairs-2.6 due to missing htonl() and htons().  These are defined in
sys/byteorder.h.  Patches are attached to add an autoconf test for that header
and include it if found.  This makes it go on solaris.

	
>How-To-Repeat:
env HOST_CC=gcc ./build.sh -m i386 -T /export/home1/software/build/tools \
   -D /export/home1/software/build/destdir.i386 \
   -R /export/home1/software/build/release/i386 release

watch the build fail with undefined htonl() and htons() when a couple of the
tools try to link.

	
>Fix:

Index: lib/libc/citrus/citrus_db_factory.c
===================================================================
RCS file: /cvsroot/src/lib/libc/citrus/citrus_db_factory.c,v
retrieving revision 1.5
diff -u -2 -r1.5 citrus_db_factory.c
--- lib/libc/citrus/citrus_db_factory.c	2003/06/30 12:32:21	1.5
+++ lib/libc/citrus/citrus_db_factory.c	2003/10/23 21:34:22
@@ -44,4 +44,9 @@
 #include <sys/queue.h>
 
+/* needed to get htonl() and htons() on Solaris */
+#ifdef HAVE_SYS_BYTEORDER_H
+#include <sys/byteorder.h>
+#endif
+
 #include "citrus_namespace.h"
 #include "citrus_region.h"
Index: tools/compat/config.h.in
===================================================================
RCS file: /cvsroot/src/tools/compat/config.h.in,v
retrieving revision 1.30
diff -u -2 -r1.30 config.h.in
--- tools/compat/config.h.in	2003/07/25 03:21:16	1.30
+++ tools/compat/config.h.in	2003/10/23 21:34:52
@@ -22,4 +22,5 @@
 #undef HAVE_STRING_H
 #undef HAVE_SYS_DIR_H
+#undef HAVE_SYS_BYTEORDER_H
 #undef HAVE_SYS_ENDIAN_H
 #undef HAVE_SYS_NDIR_H
Index: tools/compat/configure
===================================================================
RCS file: /cvsroot/src/tools/compat/configure,v
retrieving revision 1.41
diff -u -2 -r1.41 configure
--- tools/compat/configure	2003/07/26 20:23:59	1.41
+++ tools/compat/configure	2003/10/23 21:34:52
@@ -3696,6 +3696,6 @@
 
 
-for ac_header in machine/bswap.h sys/cdefs.h sys/endian.h sys/featuretest.h \
-	err.h inttypes.h libgen.h paths.h stdint.h util.h
+for ac_header in machine/bswap.h sys/cdefs.h sys/byteorder.h sys/endian.h sys/featuretest.h \
+	err.h inttypes.h libgen.h paths.h stdint.h util.h 
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
Index: tools/compat/configure.ac
===================================================================
RCS file: /cvsroot/src/tools/compat/configure.ac,v
retrieving revision 1.40
diff -u -2 -r1.40 configure.ac
--- tools/compat/configure.ac	2003/07/26 20:24:00	1.40
+++ tools/compat/configure.ac	2003/10/23 21:34:52
@@ -39,6 +39,6 @@
 AC_CHECK_HEADERS(sys/sysmacros.h sys/syslimits.h \
 	features.h malloc.h poll.h stddef.h)
-AC_CHECK_HEADERS(machine/bswap.h sys/cdefs.h sys/endian.h sys/featuretest.h \
-	err.h inttypes.h libgen.h paths.h stdint.h util.h,,
+AC_CHECK_HEADERS(machine/bswap.h sys/cdefs.h sys/byteorder.h sys/endian.h sys/featuretest.h \
+	err.h inttypes.h libgen.h paths.h stdint.h util.h,,
 	[test -f include/$ac_header || touch include/$ac_header])
 AC_CHECK_HEADERS(rpc/types.h getopt.h netconfig.h,,
Index: usr.bin/fgen/fgen.l
===================================================================
RCS file: /cvsroot/src/usr.bin/fgen/fgen.l,v
retrieving revision 1.22
diff -u -2 -r1.22 fgen.l
--- usr.bin/fgen/fgen.l	2003/07/20 01:09:07	1.22
+++ usr.bin/fgen/fgen.l	2003/10/23 21:34:53
@@ -42,4 +42,9 @@
 	    #define TOKEN struct tok
 */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <sys/cdefs.h>
 
@@ -69,4 +74,9 @@
 #include <string.h>
 #include <unistd.h>
+
+/* for htonl() and friends.  Needed on Solaris-2.6 for example. */
+#ifdef HAVE_SYS_BYTEORDER_H
+#include <sys/byteorder.h>
+#endif
 
 #include "fgen.h"
Index: usr.bin/mkcsmapper/yacc.y
===================================================================
RCS file: /cvsroot/src/usr.bin/mkcsmapper/yacc.y,v
retrieving revision 1.2
diff -u -2 -r1.2 yacc.y
--- usr.bin/mkcsmapper/yacc.y	2003/07/12 15:39:21	1.2
+++ usr.bin/mkcsmapper/yacc.y	2003/10/23 21:34:54
@@ -47,4 +47,8 @@
 #include <sys/types.h>
 
+#ifdef HAVE_SYS_BYTEORDER_H
+#include <sys/byteorder.h>
+#endif
+
 #include "ldef.h"
 
	
>Release-Note:
>Audit-Trail:
>Unformatted: