[U-Boot] [PATCH 12/15] Add support for building native win32 tools

Peter Tyser ptyser at xes-inc.com
Thu Mar 5 19:32:27 CET 2009


On Wed, 2009-03-04 at 19:21 -0500, Mike Frysinger wrote:
> On Wednesday 04 March 2009 18:33:02 Peter Tyser wrote:
> > --- a/README
> > +++ b/README
> > +      the tools directory you can use the MinGW toolchain
> > +      (http://www.mingw.org).  Set your HOST tools to the MinGW
> > +      binaries and execute 'make tools'.  For example:
> 
> binaries -> cross-compiler

I think binaries is more fitting than cross-compiler since the mingw
strip utility is also used.  In theory other HOST tools might be used
down the road.

> > --- a/include/linux/types.h
> > +++ b/include/linux/types.h
> > @@ -10,10 +10,13 @@
> >
> >  #ifndef __KERNEL_STRICT_NAMES
> >
> > +#ifndef __MINGW32__
> > +/* prevent mingw overlaps for certain typedefs */
> >  typedef __kernel_fd_set		fd_set;
> >  typedef __kernel_dev_t		dev_t;
> >  typedef __kernel_ino_t		ino_t;
> >  typedef __kernel_mode_t		mode_t;
> > +#endif
> >  typedef __kernel_nlink_t	nlink_t;
> >  typedef __kernel_off_t		off_t;
> >  typedef __kernel_pid_t		pid_t;
> > @@ -54,7 +57,7 @@ typedef __kernel_loff_t		loff_t;
> >  typedef __kernel_size_t		size_t;
> >  #endif
> >
> > -#ifndef _SSIZE_T
> > +#if !defined(_SSIZE_T) && !defined(__MINGW32__)
> >  #define _SSIZE_T
> >  typedef __kernel_ssize_t	ssize_t;
> >  #endif
> 
> perhaps we should be defining __KERNEL_STRICT_NAMES for host builds instead

I'll look into it.

> > --- a/tools/Makefile
> > +++ b/tools/Makefile
> > @@ -79,6 +79,14 @@ SFX =
> >  endif
> >
> >  #
> > +# mingw toolchain requires mingw_support.c and generates .exe files
> > +#
> > +ifneq (,$(findstring mingw,$(shell $(HOSTCC) -v 2>&1 | grep mingw)))
> > +MINGW_OBJ_FILES-y += mingw_support.o
> > +SFX = .exe
> > +endif
> 
> perhaps we should create a sfx.sh script which handles the logic of detecting 
> the default suffix.  would be a lot cleaner than relying on strings in 
> toolchain names.

The above looks at the output of the "HOSTCC -v" command.  The "Target:
XXX" strings should contain mingw regardless of the naming of HOSTCC.
How about combining the SFX detection into:


ifeq ($(HOSTOS),cygwin)
HOST_CFLAGS += -ansi
endif

#
# toolchains targeting win32 generate .exe files
#
ifneq (,$(findstring WIN32 ,$(shell echo "" | $(HOSTCC) -E -dM -)))
SFX = .exe
else
SFX =
endif

> > +void *mmap(void *addr, size_t len, int prot, int flags, int fd, int
> > offset) +{
> 
> this is a pretty naïve implementation ... but it seems like for u-boot's 
> usage, it should be complete ?

I hope:)  It looks sufficient based on my limited win32 programming
knowledge and I tested the resulting mkimage.exe to validate its
functionality.

> > --- a/tools/mkimage.c
> > +++ b/tools/mkimage.c
> > @@ -25,6 +25,10 @@
> > +#ifdef __MINGW32__
> > +#include "mingw_support.h"
> > +#endif
> > --- a/tools/mkimage.h
> > +++ b/tools/mkimage.h
> > @@ -28,7 +28,11 @@
> >  #ifndef __WIN32__
> >  #include <netinet/in.h>		/* for host / network byte order conversions	*/
> >  #endif
> > +#ifdef __MINGW32__
> > +#include <stdint.h>
> > +#else
> >  #include <sys/mman.h>
> > +#endif
> 
> why not move the mingw_support.h to mkimage.h ... then you wont have to touch 
> mkimage.c.  or create a new "os_support.h" header and move these differences 
> there.  then you wont have to copy & paste the same code to every tool that 
> uses mmap().

I'll implement the os_support.[ch] idea as suggested.

Best,
Peter



More information about the U-Boot mailing list