Opened 7 years ago

Closed 7 years ago

#4871 closed bug (worksforme)

Build failure on windows: rts/Linker.c

Reported by: nsch Owned by:
Priority: normal Milestone:
Component: Runtime System Version:
Keywords: mingw Cc:
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: Building GHC failed Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I'm getting this error when trying to compile current GHC-HEAD on windows:

"inplace/bin/ghc-stage1.exe" -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Wi
nline -optc-Waggregate-return -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Iincludes -opt
c-Irts -optc-DCOMPILING_RTS -optc-fno-strict-aliasing -optc-fno-common -optc-Ilibffi/build/include -optc-fomit-frame-pointer -optc-DRtsWay=\
"rts_thr\" -optc-DTHREADED_RTS  -H32m -O -Iincludes -Irts -DCOMPILING_RTS -package-name rts  -dcmm-lint  -Ilibffi/build/include     -i -irts
 -irts/dist/build -irts/dist/build/autogen -Irts/dist/build -Irts/dist/build/autogen          -optc-O2   -c rts/Linker.c -o rts/dist/build/L

rts\Linker.c:1039:1:  error: conflicting types for 'mktime'
c:\haskell\ghc-src\inplace\mingw\bin\../lib/gcc/mingw32/4.5.0/../../../../include/time.h:104:40: note: previous declaration of 'mktime' was

rts\Linker.c:1039:1:  error: conflicting types for 'localtime'
c:\haskell\ghc-src\inplace\mingw\bin\../lib/gcc/mingw32/4.5.0/../../../../include/time.h:121:45: note: previous declaration of 'localtime' w
as here

rts\Linker.c:1039:1:  error: conflicting types for 'gmtime'
c:\haskell\ghc-src\inplace\mingw\bin\../lib/gcc/mingw32/4.5.0/../../../../include/time.h:120:45: note: previous declaration of 'gmtime' was
make[1]: *** [rts/dist/build/Linker.thr_o] Error 1
make: *** [all] Error 2

rts/Linker.c:1039 basicly is just:


with the definition somewhere below line 381:

/* These are statically linked from the mingw libraries into the ghc
   executable, so we have to employ this hack. */
#define RTS_MINGW_ONLY_SYMBOLS                           \
      SymI_NeedsProto(mktime)                            \
      SymI_NeedsProto(localtime)                         \
      SymI_NeedsProto(gmtime)                            \

I tried all different versions of MinGW - the one of the current Haskell Platform 2010.2.0.0 and the one currently available at and an old version I had installed.

However, removing these 3 lines will result in another error, so the changes to fix this won't be that trivial:

rts\sm\GC.c: In function 'new_gc_thread':

     error: incompatible types when assigning to type 'OSThreadId' from type 'int'
make[1]: *** [rts/dist/build/sm/GC.thr_o] Error 1
make: *** [all] Error 2

(even though I'm not 100% if that's because of those changes, since I probably never got that far in the building process...)

Change History (4)

comment:1 Changed 7 years ago by simonmar

GHC comes with its own version of MinGW, which as far as I'm aware doesn't provoke these problems. Did you somehow replace it with a different version?

comment:2 Changed 7 years ago by nsch

To be honest, I'm somehow confused on which tools you should use to build GHC on windows. The different links to the MinGW tools on Building/Preparation/Windows are broken (there's no anymore) and by just downloading the latest MinGW versions from I get another error:

"inplace/bin/ghc-stage1.exe" -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Waggregate-return -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Iincludes -optc-Irts -optc-DCOMPILING_RTS -optc-fno-strict-aliasing -optc-fno-common -optc-Ilibffi/build/include -optc-fomit-frame-pointer -optc-DRtsWay=\"rts_thr\" -optc-Wno-strict-prototypes -optc-DTHREADED_RTS  -H32m -O -Iincludes -Irts -DCOMPILING_RTS -package-name rts  -dcmm-lint  -Ilibffi/build/include     -i -irts -irts/dist/build -irts/dist/build/autogen -Irts/dist/build -Irts/dist/build/autogen          -optc-O2   -c rts/Adjustor.c -o rts/dist/build/Adjustor.thr_o
In file included from c:/mingw/lib/gcc/mingw32/4.5.0/../../../../include/pthread.h:288:0,
                 from includes/rts/OSThreads.h:30,
                 from includes/Rts.h:178,

                 from rts\Adjustor.c:40:0:
c:/mingw/lib/gcc/mingw32/4.5.0/../../../../include/sched.h:152:53: error: expected ')' before 'pid'
c:/mingw/lib/gcc/mingw32/4.5.0/../../../../include/sched.h:154:53: error: expected ')' before 'pid'
make[1]: *** [rts/dist/build/Adjustor.thr_o] Error 1
make: *** [all] Error 2

Yes, there's that ghc-tarballs repository, but it's missing at least "make" and "autoreconf" (and I think "sh" and stuff like that), so I need at least some tools from the msys/mingw packages.

This might be just some missing/unclear documentation, but I spend the last couple of days trying to fix this and I'm not entirely sure anymore if it's really all my own fault...

comment:3 Changed 7 years ago by igloo

I've copied ghc/tools/Win32 across to the new server.

You shouldn't need to install MinGW at all, and I thinkg MSYS complains if it finds it installed in c:/mingw. I've removed that step from the wiki page.

The build oughtn't break if c:/mingw exists, but I suspect it would be hard to fix. The path seems to be hardwired into the tools, and presumably the versions were incompatible.

comment:4 Changed 7 years ago by nsch

Resolution: worksforme
Status: newclosed

Thanks for the explanation & the copy. It's working now.

Note: See TracTickets for help on using tickets.