Subject: Re: Cygwin NetBSD cross tools
To: None <tech-toolchain@netbsd.org>
From: Jesse Off <joff@embeddedARM.com>
List: tech-toolchain
Date: 06/17/2006 23:14:25
A few more bugs in the build uncovered by attempting to build NetBSD 
with Cygwin.  I'll have you know I was able to "./build.sh release" at 
the end of the day today!  Most all of them have to do with case 
insensitivity in the DESTDIR but we're actually very close to "working 
out of the box" save a few minor, very fixable problems

*) Building libc uses a shell script 'makelintstub' that uses the 
'getopt' shell command.  This isn't present in the Cygwin shell and you 
have to install "util-linux" to get it.  "util-linux" may not be 
installed in a default setup of Cygwin

*) libc build blows up saying conflicting definitions of _Exit() in a 
lib.  in src/lib/libc/stdlib there are two source files exit.c and 
_Exit.c.  _Exit.c includes a wrapper definition for Exit() that just 
calls exit().   It seems some intermediary step provokes a name conflict 
despite the "_" in _Exit.c that in effect overwrites the exit.o object 
file with the _Exit.o object file and therefore looses exit.o and has 2 
_Exit.c objects in the lib.  The error is below:

libc_pic.a(_Exit.so)(.text+0x0): In function `_Exit': : multiple 
definition of `_Exit'
libc_pic.a(_exit.so)(.text+0x0): first defined here
collect2: ld returned 1 exit status

This problem has come up before: 
http://mail-index.netbsd.org/tech-toolchain/2006/01/20/0000.html with 
someone using Cygwin and Mac OS X.

This was fixed by including the definition of Exit() in exit.c along 
with exit() and removing _Exit.c from the build altogether.  Another fix 
would have been renaming _Exit.c to exit2.c-- the leading underscore in 
_Exit.c seems to not be enough.

*) With the above fixed, I was able to get all the way to the 
"checkflist" stage of a "./build.sh release"  At this point, checkflist 
found all the naming conflicts from the build assuming a case sensitive 
filesystem for DESTDIR.  Most of the "violations" were in creating 
manpage symlinks (both DELAY.0 and delay.0 in same dir), but there were 
a few others (src/usr.bin/mail installs a /usr/bin/Mail -> /usr/bin/mail 
symlink that gets blown away on case insensitive DESTDIRs)  I'm not 
quite sure yet why /etc/rc.d/network was missed and 
/usr/share/local/zh_TW.Big5.

===========  141 missing files  ==============
Files in flist but missing from DESTDIR.
File wasn't installed ?
This is non-fatal.
------------------------------------------
./etc/rc.d/network
./usr/bin/Mail
./usr/share/locale/zh_TW.Big5/LC_CTYPE
./usr/share/man/cat1/Mail.0
./usr/share/man/cat2/_Exit.0
./usr/share/man/cat3/CIRCLEQ_EMPTY.0
./usr/share/man/cat3/CIRCLEQ_ENTRY.0
./usr/share/man/cat3/CIRCLEQ_FIRST.0
./usr/share/man/cat3/CIRCLEQ_HEAD.0
./usr/share/man/cat3/CIRCLEQ_HEAD_INITIALIZER.0
./usr/share/man/cat3/CIRCLEQ_INIT.0
./usr/share/man/cat3/CIRCLEQ_INSERT_AFTER.0
./usr/share/man/cat3/CIRCLEQ_INSERT_BEFORE.0
./usr/share/man/cat3/CIRCLEQ_INSERT_HEAD.0
./usr/share/man/cat3/CIRCLEQ_INSERT_TAIL.0
./usr/share/man/cat3/CIRCLEQ_LAST.0
./usr/share/man/cat3/CIRCLEQ_NEXT.0
./usr/share/man/cat3/CIRCLEQ_PREV.0
./usr/share/man/cat3/CIRCLEQ_REMOVE.0
./usr/share/man/cat3/LIST_EMPTY.0
./usr/share/man/cat3/LIST_ENTRY.0
./usr/share/man/cat3/LIST_FIRST.0
./usr/share/man/cat3/LIST_HEAD.0
./usr/share/man/cat3/LIST_HEAD_INITIALIZER.0
./usr/share/man/cat3/LIST_INIT.0
./usr/share/man/cat3/LIST_INSERT_AFTER.0
./usr/share/man/cat3/LIST_INSERT_BEFORE.0
./usr/share/man/cat3/LIST_INSERT_HEAD.0
./usr/share/man/cat3/LIST_NEXT.0
./usr/share/man/cat3/LIST_REMOVE.0
./usr/share/man/cat3/SIMPLEQ_EMPTY.0
./usr/share/man/cat3/SIMPLEQ_ENTRY.0
./usr/share/man/cat3/SIMPLEQ_FIRST.0
./usr/share/man/cat3/SIMPLEQ_HEAD.0
./usr/share/man/cat3/SIMPLEQ_HEAD_INITIALIZER.0
./usr/share/man/cat3/SIMPLEQ_INIT.0
./usr/share/man/cat3/SIMPLEQ_INSERT_AFTER.0
./usr/share/man/cat3/SIMPLEQ_INSERT_HEAD.0
./usr/share/man/cat3/SIMPLEQ_INSERT_TAIL.0
./usr/share/man/cat3/SIMPLEQ_NEXT.0
./usr/share/man/cat3/SIMPLEQ_REMOVE_HEAD.0
./usr/share/man/cat3/TAILQ_EMPTY.0
./usr/share/man/cat3/TAILQ_ENTRY.0
./usr/share/man/cat3/TAILQ_FIRST.0
./usr/share/man/cat3/TAILQ_HEAD.0
./usr/share/man/cat3/TAILQ_HEAD_INITIALIZER.0
./usr/share/man/cat3/TAILQ_INIT.0
./usr/share/man/cat3/TAILQ_INSERT_AFTER.0
./usr/share/man/cat3/TAILQ_INSERT_BEFORE.0
./usr/share/man/cat3/TAILQ_INSERT_HEAD.0
./usr/share/man/cat3/TAILQ_INSERT_TAIL.0
./usr/share/man/cat3/TAILQ_NEXT.0
./usr/share/man/cat3/TAILQ_REMOVE.0
./usr/share/man/cat4/i386/PCIBIOS.0
./usr/share/man/cat8/makedev.0
./usr/share/man/cat9/Cardbus_conf_read.0
./usr/share/man/cat9/Cardbus_conf_write.0
./usr/share/man/cat9/Cardbus_free_tag.0
./usr/share/man/cat9/Cardbus_function_disable.0
./usr/share/man/cat9/Cardbus_function_enable.0
./usr/share/man/cat9/Cardbus_make_tag.0
./usr/share/man/cat9/Cardbus_mapreg_map.0
./usr/share/man/cat9/Cardbus_mapreg_unmap.0
./usr/share/man/cat9/DELAY.0
./usr/share/man/cat9/FREE.0
./usr/share/man/cat9/HOLDRELE.0
./usr/share/man/cat9/KNOTE.0
./usr/share/man/cat9/MALLOC.0
./usr/share/man/cat9/M_PREPEND.0
./usr/share/man/cat9/VATTR_NULL.0
./usr/share/man/cat9/VHOLD.0
./usr/share/man/cat9/VREF.0
./usr/share/man/man1/Mail.1
./usr/share/man/man2/_Exit.2
./usr/share/man/man3/CIRCLEQ_EMPTY.3
./usr/share/man/man3/CIRCLEQ_ENTRY.3
./usr/share/man/man3/CIRCLEQ_FIRST.3
./usr/share/man/man3/CIRCLEQ_HEAD.3
./usr/share/man/man3/CIRCLEQ_HEAD_INITIALIZER.3
./usr/share/man/man3/CIRCLEQ_INIT.3
./usr/share/man/man3/CIRCLEQ_INSERT_AFTER.3
./usr/share/man/man3/CIRCLEQ_INSERT_BEFORE.3
./usr/share/man/man3/CIRCLEQ_INSERT_HEAD.3
./usr/share/man/man3/CIRCLEQ_INSERT_TAIL.3
./usr/share/man/man3/CIRCLEQ_LAST.3
./usr/share/man/man3/CIRCLEQ_NEXT.3
./usr/share/man/man3/CIRCLEQ_PREV.3
./usr/share/man/man3/CIRCLEQ_REMOVE.3
./usr/share/man/man3/LIST_EMPTY.3
./usr/share/man/man3/LIST_ENTRY.3
./usr/share/man/man3/LIST_FIRST.3
./usr/share/man/man3/LIST_HEAD.3
./usr/share/man/man3/LIST_HEAD_INITIALIZER.3
./usr/share/man/man3/LIST_INIT.3
./usr/share/man/man3/LIST_INSERT_AFTER.3
./usr/share/man/man3/LIST_INSERT_BEFORE.3
./usr/share/man/man3/LIST_INSERT_HEAD.3
./usr/share/man/man3/LIST_NEXT.3
./usr/share/man/man3/LIST_REMOVE.3
./usr/share/man/man3/SIMPLEQ_EMPTY.3
./usr/share/man/man3/SIMPLEQ_ENTRY.3
./usr/share/man/man3/SIMPLEQ_FIRST.3
./usr/share/man/man3/SIMPLEQ_HEAD.3
./usr/share/man/man3/SIMPLEQ_HEAD_INITIALIZER.3
./usr/share/man/man3/SIMPLEQ_INIT.3
./usr/share/man/man3/SIMPLEQ_INSERT_AFTER.3
./usr/share/man/man3/SIMPLEQ_INSERT_HEAD.3
./usr/share/man/man3/SIMPLEQ_INSERT_TAIL.3
./usr/share/man/man3/SIMPLEQ_NEXT.3
./usr/share/man/man3/SIMPLEQ_REMOVE_HEAD.3
./usr/share/man/man3/TAILQ_EMPTY.3
./usr/share/man/man3/TAILQ_ENTRY.3
./usr/share/man/man3/TAILQ_FIRST.3
./usr/share/man/man3/TAILQ_HEAD.3
./usr/share/man/man3/TAILQ_HEAD_INITIALIZER.3
./usr/share/man/man3/TAILQ_INIT.3
./usr/share/man/man3/TAILQ_INSERT_AFTER.3
./usr/share/man/man3/TAILQ_INSERT_BEFORE.3
./usr/share/man/man3/TAILQ_INSERT_HEAD.3
./usr/share/man/man3/TAILQ_INSERT_TAIL.3
./usr/share/man/man3/TAILQ_NEXT.3
./usr/share/man/man3/TAILQ_REMOVE.3
./usr/share/man/man4/i386/PCIBIOS.4
./usr/share/man/man8/makedev.8
./usr/share/man/man9/Cardbus_conf_read.9
./usr/share/man/man9/Cardbus_conf_write.9
./usr/share/man/man9/Cardbus_free_tag.9
./usr/share/man/man9/Cardbus_function_disable.9
./usr/share/man/man9/Cardbus_function_enable.9
./usr/share/man/man9/Cardbus_make_tag.9
./usr/share/man/man9/Cardbus_mapreg_map.9
./usr/share/man/man9/Cardbus_mapreg_unmap.9
./usr/share/man/man9/DELAY.9
./usr/share/man/man9/FREE.9
./usr/share/man/man9/HOLDRELE.9
./usr/share/man/man9/KNOTE.9
./usr/share/man/man9/MALLOC.9
./usr/share/man/man9/M_PREPEND.9
./usr/share/man/man9/VATTR_NULL.9
./usr/share/man/man9/VHOLD.9
./usr/share/man/man9/VREF.9
========  end of 141 missing files  ==========

I was able to get past this by adding "CHECKFLIST_FLAGS=-e -m" to 
/etc/mk.conf which forces checkflist to ignore differences.

*) With the above worked around, the build continued all the way to the 
last step where "maketars" was being run.  The build failed again here 
because of the 141 missing files.  Fortunately, the tar set was still 
created, but with a .tmp suffix (base.tgz.tmp).  I renamed these to 
base.tgz, reran make release and the build finished!  I have since 
installed the cygwin NFS server and have been successful in NFS booting 
my TS-7300 to NetBSD with nothing but a Windows machine.  My Windows 
machine also now has a working netbsd ARM cross-gdb which is just wonderful.

*) I tried to use MKSHARE=no to avoid the man pages in the build, but it 
seems to cause breakage:

#   install  /usr/nbsd3obj/usr/nbsd3src/destdir.evbarm/etc/mail/submit.cf
nbinstall: etcsubmit.cf: stat: No such file or directory

What do you suppose the best solution for the uppercase/lowercase 
manpages?  Could something clever be done with the METALOG to "fake-up" 
the tar file, but install into a case insensitive DESTDIR with a 
semi-mangled unique name?

//Jesse Off


Jesse Off wrote:
> I've been attempting to use Windows with Cygwin to compile NetBSD.  I 
> wanted to "seed" the inevitable Google search our customers will be 
> doing when they attempt the same with NetBSD on our products by 
> offering some tidbits of information.  The current information google 
> returns is a bit out-dated.
>
> *) The top-level "build.sh" shell script in the NetBSD source 
> distribution needs a small modification on cygwin because cygwin's 
> /bin/pwd does not support -P:
>
> --- build.sh.orig       2006-06-16 10:00:25.812500000 -0700
> +++ build.sh    2006-06-16 10:05:13.468750000 -0700
> @@ -89,6 +89,12 @@
>        unset PWD
>        TOP=$(/bin/pwd -P 2>/dev/null)
>
> +       # Some systems do not support the -P option to /bin/pwd
> +       #
> +       if [ -z "$TOP" ]; then
> +               TOP=$(/bin/pwd 2>/dev/null)
> +       fi
> +
>        # Set defaults.
>        #
>        toolprefix=nb
>
> *) I'd recommend normalizing your PATH while in cygwin to 
> /bin:/usr/bin e.g. export PATH=/bin:/usr/bin  I had some programs in 
> my path that happened to conflict with some of the tools used in the 
> build.
>
> *) Make sure you get the "minires-devel" package from Cygwin or else 
> you will get a tools build failure in asn1_compile.   That build will 
> be looking for the "resolv.h" and "nameser.h" include files that come 
> with that package and I don't think that package is selected by 
> default when installing cygwin.
>
> *) The current Cygwin distribution as of 6/16/2006 has a problem with 
> the cygwin /usr/include/sys/stdio.h-- It includes an unconditional 
> declaration of getline().  This has been fixed in the current Cygwin 
> CVS for many months, but hasn't made it to a release yet.  You can do 
> the modification yourself to this file:
>
> --- stdio.h.orig        2006-06-16 10:31:46.187500000 -0700
> +++ stdio.h     2006-06-16 09:51:16.421875000 -0700
> @@ -28,8 +28,10 @@
>
> __BEGIN_DECLS
>
> +#ifdef _GNU_SOURCE
> ssize_t        _EXFUN(getline, (char **, size_t *, FILE *));
> ssize_t        _EXFUN(getdelim, (char **, size_t *, int, FILE *));
> +#endif /* _GNU_SOURCE */
>
> __END_DECLS
>
> *) Due to the nature of the Windows filesystem you can't e.g. have 
> both a 'CVS' dir and a 'cvs' executable in the same directory.  This 
> will cause build problems
> when traversing the cleandir rule of cvs where it tried to "rm -f *.o 
> blah blah cvs".  The build will fail with "Can't remove cvs -- is a 
> directory"  I fixed this by just recursively removing the 'CVS' 
> directories in the source dist-- you don't really need them unless you 
> want to track future CVS changes.  You can do that with this command 
> from the top-level directory: find . -type d -name 'CVS' | xargs rm -rf
>
> With the above worked around, I was successfully able to build the 
> cross tools and also use ./build.sh to compile a kernel for evbarm 
> (./build.sh -m evbarm kernel=TS7200)  I haven't attempted to make 
> release yet so there may be some more unknown issues there.
>
> //Jesse Off
>