Skip to content
  • Sergei Trofimovich's avatar
    rts: tweak cross-compilation to mingw32 · 745032dd
    Sergei Trofimovich authored
    
    
    Found the problem on x86_64-linux host where
    I tried to cross-compile GHC to windows as:
    
        $ ./configure --target=i686-w64-mingw32 \
                      Windres=i686-w64-mingw32-windres \
                      DllWrap=i686-w64-mingw32-dllwrap
    
    As a result build failed as POSIX bits of RTS.
    For example 'rts/posix/OSMem.c' contains unix-specific
    mmap() syscalls and constants and thus can't be compiled
    by i686-w64-mingw32 toolchain.
    
    It's caused by the following part of 'rts/ghc.mk':
    
      ifeq "$(HostOS_CPP)" "mingw32"
      ALL_DIRS += win32
      else
      ALL_DIRS += posix
      endif
    
    In our case _CPP variables are defined this way (project.mk):
      BuildOS_CPP                = linux
      HostOS_CPP                 = linux
      TargetOS_CPP               = mingw32
    
    RTS should never be built for 'BuildOS' or 'HostOS' as it's
    always built by ghc-stage1 (targeted at TargetOS).
    
    The change is to flip 'HostOS_CPP' to 'TargetOS_CPP' in 'rts/ghc.mk'.
    
    Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
    745032dd