building cygwin with gcc4

Brian Dessent
Tue May 17 22:49:00 GMT 2005

Has anyone experimented with building Cygwin with gcc4?  I've been
fooling around with it, but there's still a ways to go.

The first thing I ran into was that ilockincr() gets called with a null
pointer somewhere.  When I changed the line "#define
InterlockedIncrement ilockincr" to also spit out an OutputDebugString()
the problem went away, so it would seem that some optimization was
causing a register to be used for the pointer and not converted back to
a memory location.  I just rebuilt with -O0 and that cured it.  Hardly a
good solution though.

The next thing I ran into was this: (I added extra info to the output
while trying to figure out what was happening):

[main] ? 4908 cygheap_user::init: SetTokenInformation (0x7D0,
TokenDefaultDacl, 0x22F950 [dacl.DefaultDacl = 0x22F46F], 4), Win32
error 998
[main] ? 4908 cygheap_user::init: SetKernelObjectSecurity (0x7D8,
DACL_SECURITY_INFORMATION, 0x22F45B), Win32 error 998

I can't see anything blatantly wrong with the parameters being passed
that would cause windows to barf, but I'm sure there's something I'm not
seeing.  Because those were system_printf()s they cause every test in
the test suite to fail as they write to stderr, so I changed them to
debug_printf()s temporarily.  After doing that and rerunning the
testsuite, everything seemed to pass except for mmap(), which suffers
from a divide by zero:

[main] mmaptest01 3204 handle_exceptions: Exception:
[main] mmaptest01 3204 open_stackdumpfile: Dumping stack trace to
FAIL: mmaptest01.c (execute)

Looking into it further, the offending line is this in

 gran_len = howmany (off + len, granularity) * granularity - gran_off;

'granularity' had a value of 0.  Something must have changed in the way
that g++ interprets static initializers -- I'm really not sure of
language details here.  But I moved the declaration of the variable out
of the function into file scope and that fixed it.

With those changes my gcc-4 built cygwin1.dll passes all but one of the

                === winsup Summary ===

# of expected passes            272
# of unexpected failures        1
# of expected failures          8

The failing test is:

running /usr/src/cygwin/build/i686-pc-cygwin/winsup/testsuite/cygrun
./pthread-cancel11.exe > ./pthread-cancel11.log

pthread/cancel11.c: Assertion failed: (result == PTHREAD_CANCELED), file
/usr/src/cygwin/src/winsup/testsuite/winsup.api/pthread/cancel11.c, line
FAIL: pthread/cancel11.c (execute)

That's about as far as I got.  Oh, and I had to patch some of the
testcases themselves to get rid of a warning in gcc4, but that was
pretty simple.  I'll post the patches for these on the patches list.


More information about the Cygwin-developers mailing list