[Help-gnutls] Re: Build gnutls on windows

Simon Josefsson jas at extundo.com
Sat Sep 24 10:04:02 CEST 2005


Martin Lambers <marlam at marlam.de> writes:

> On Fri, 23. Sep 2005, 00:46:27 +0200, Simon Josefsson wrote:
>> > Reasonable POSIX support on Win32 is not just a collection of fixes for
>> > minor misbehaviour; it is a major task. Perhaps it would be better to
>> > leave that to an external project and only support "MinGW + plibc" (or
>> > something similar) as a target platform.
>> 
>> Yes, I think you are right.  However, it isn't impossible to integrate
>> something like plibc in gnulib, or in GnuTLS itself.  Then the GnuTLS
>> core code will be good and the resulting binaries should run properly
>> too.  I'm not sure GnuTLS need a lot from POSIX, perhaps we can even
>> integrate the plibc functions we need in GnuTLS.
>
> Judging from some quick greps, I think at least the following is
> necessary to get rid of #ifdef _WIN32:

Many thanks for checking this!

> - Integration of existing gnulib modules:
>   - inet_ntop

The module is LGPL so this isn't a problem.

> - New gnulib modules for missing headers:
>   - <sys/socket.h>
>   - <netinet/in.h>
>   - <arpa/inet.h>
>   - <netdb.h>

Bruno said on the gnulib list that this was doable.

> - New gnulib modules to make socket functions set errno, provide
>   the missing errnos such as ECONNREFUSED, and provide a strerror() that
>   understands these additional errnos.
>   - select()
>   - connect()
>   - accept()
>   - recv()
>   - send()
>   - ...

We could do this too, but it would take more time to figure out which
functions need to be re-implemented.  And also to write the
re-implementation, I haven't looked at plibc enough to know whether it
would work or not.

> - New gnulib modules to make some functions work with sockets:
>   - close()
>   - fcntl() which handles O_NONBLOCK for sockets
>
> - Call WSAStartup() / WSACleanup() somewhere without having them in the
>   main code.

I'm not sure how to do this, but may be doable.  Perhaps calling
WSAStartup/WSACleanup in a #ifdef WIN32 is acceptable.

> - Non-networking issues:
>   - getpwuid(), getuid()
>   - signal handling:
>     Using SIGALARM for network timeouts could be replaced by using
>     setsockopt with SO_RCVTIMEO and SO_SNDTIMEO. But this does not work on
>     Windows <= 2000 and on several UNIX versions including Solaris. It does
>     work on GNU/Linux and *BSD.

I wonder if there is a better solution.

> I'm sorry to say that I currently don't have enough spare time to be
> able to work on these things.

Your message is a very good stating point...

>> Btw, have you tested to run a mingw32 built gnutls-cli on a Windows
>> platform?  It shouldn't be too hard to test it to see whether it works
>> or almost works.
>
> It does not. I tested
> $ gnutls-cli.exe --print-cert --port 25 --starttls some.smtp.server
> It hangs after printing "Simple Client Mode:".  That's because select()
> is called and the test after the call assumes that errno is set. This
> results in an endless loop.

The next step would be to integrate the plibc select and see what
breaks then.

Thanks,
Simon





More information about the Gnutls-help mailing list