Skip to content
Snippets Groups Projects

Fix build of Windows cross-compiler (#20697, #22805)

Closed Sylvain Henry requested to merge hsyl20/ghc:hsyl20/cross-win into master

Fix building of a Windows cross-compiler with Hadrian. First step towards #20697.

  • Fixed on Linux (tested on ArchLinux)
  • check that it also fixes cross-compilation from Darwin (first commit about AR; needs someone to check that it works): cf #22805 (closed)
  • check that third commit makes sense for W32 (whatever that is) and doesn't break CI
Edited by Sylvain Henry

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Sylvain Henry mentioned in issue #20697

    mentioned in issue #20697

  • mentioned in issue #22805 (closed)

  • Sylvain Henry changed the description

    changed the description

    • RE: Cross compilation on Darwin

      ar works, so this fixes #22805 (closed)

      I was able to get much further than before, however, the build failed here:

      ...
      | Run Ghc CompileHs (Stage0 InTreeLibs): utils/haddock/haddock-api/src/Haddock/Interface/Create.hs => _build/stage0/utils/haddock/build/Haddock/Interface/Create.o
      | Run Ghc CompileHs (Stage0 InTreeLibs): utils/haddock/haddock-api/src/Haddock/Backends/Xhtml.hs => _build/stage0/utils/haddock/build/Haddock/Backends/Xhtml.o
      | Run Ghc CompileHs (Stage0 InTreeLibs): utils/haddock/haddock-api/src/Haddock/Interface.hs => _build/stage0/utils/haddock/build/Haddock/Interface.o
      | Executable found: x86_64-w64-mingw32-ld => /opt/homebrew/bin/x86_64-w64-mingw32-ld
      | Package 'rts' configuration flags: configure --distdir /Users/romes/ghc-dev/x86_64-w64-mingw32-ghc/_build/stage1/rts --disable-executable-stripping --disable-library-stripping --disable-executable-stripping --disable-library-stripping --cabal-file rts/rts.cabal --ipid $pkg-$version --prefix ${pkgroot}/.. --htmldir ${pkgroot}/../../doc/html/libraries/rts-1.0.2 --with-ghc=/Users/romes/ghc-dev/x86_64-w64-mingw32-ghc/_build/stage0/bin/x86_64-w64-mingw32-ghc --with-ghc-pkg=/Users/romes/ghc-dev/x86_64-w64-mingw32-ghc/_build/stage0/bin/x86_64-w64-mingw32-ghc-pkg --with-gcc=/opt/homebrew/bin/x86_64-w64-mingw32-gcc --with-ar=/opt/homebrew/bin/x86_64-w64-mingw32-ar --ghc-option=-no-global-package-db --ghc-option=-package-db=/Users/romes/ghc-dev/x86_64-w64-mingw32-ghc/_build/stage1/inplace/package.conf.d --ghc-pkg-option=--global-package-db=/Users/romes/ghc-dev/x86_64-w64-mingw32-ghc/_build/stage1/inplace/package.conf.d --enable-library-vanilla --enable-library-profiling --disable-library-for-ghci --disable-shared --with-ld=x86_64-w64-mingw32-ld --with-alex=/Users/romes/.cabal/bin/alex --with-happy=/Users/romes/.cabal/bin/happy --configure-option=CFLAGS=-iquote /Users/romes/ghc-dev/x86_64-w64-mingw32-ghc/rts --gcc-options=-iquote /Users/romes/ghc-dev/x86_64-w64-mingw32-ghc/rts --configure-option=--host=x86_64-w64-mingw32 --configure-option=--with-cc=/opt/homebrew/bin/x86_64-w64-mingw32-gcc --ghc-option=-ghcversion-file=rts/include/ghcversion.h --ghc-option=-ghcversion-file=rts/include/ghcversion.h --flags=profiling debug -dynamic threaded -use-system-libffi -libffi-adjustors -find-ptr -v0
      # cabal-configure (for _build/stage1/rts/setup-config)
      configure: WARNING: unrecognized options: --with-compiler, --with-cc
      checking build system type... aarch64-apple-darwin22.1.0
      checking host system type... x86_64-pc-windows
      Unknown OS windows
      Error when running Shake build system:
        at action, called at src/Rules.hs:38:19 in main:Rules
        at need, called at src/Rules.hs:60:5 in main:Rules
      * Depends on: _build/stage1/lib/package.conf.d/rts-1.0.2.conf
        at apply1, called at src/Development/Shake/Internal/Rules/Oracle.hs:159:32 in shk-0.19.7-51192a6a:Development.Shake.Internal.Rules.Oracle
      * Depends on: OracleQ (ContextDataKey (Context {stage = Stage1, package = Package {pkgType = Library, pkgName = "rts", pkgPath = "rts"}, way = v, iplace = Final}))
        at need, called at src/Hadrian/Oracles/Cabal/Rules.hs:54:9 in main:Hadrian.Oracles.Cabal.Rules
      * Depends on: _build/stage1/rts/setup-config
      * Raised the exception:
      ExitFailure 1

      Seems to be the first step regarding stage1 (configure --distdir /Users/romes/ghc-dev/x86_64-w64-mingw32-ghc/_build/stage1/rts)

      Edited by Rodrigo Mesquita
    • Author Developer

      Could you try:

      diff --git m4/fptools_set_haskell_platform_vars.m4 m4/fptools_set_haskell_platform_vars.m4
      index 1a32b3046b..02b5b4e53c 100644
      --- m4/fptools_set_haskell_platform_vars.m4
      +++ m4/fptools_set_haskell_platform_vars.m4
      @@ -82,7 +82,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS_SHELL_FUNCTIONS],
               solaris2)
                   test -z "[$]2" || eval "[$]2=OSSolaris2"
                   ;;
      -        mingw32)
      +        mingw32|windows)
                   test -z "[$]2" || eval "[$]2=OSMinGW32"
                   ;;
               freebsd)
      diff --git m4/ghc_convert_os.m4 m4/ghc_convert_os.m4
      index 8e2825d940..d4aa639cd5 100644
      --- m4/ghc_convert_os.m4
      +++ m4/ghc_convert_os.m4
      @@ -22,6 +22,9 @@ AC_DEFUN([GHC_CONVERT_OS],[
             openbsd*)
               $3="openbsd"
               ;;
      +      windows)
      +        $3="mingw32"
      +        ;;
             # As far as I'm aware, none of these have relevant variants
             freebsd|dragonfly|hpux|linuxaout|kfreebsdgnu|freebsd2|mingw32|darwin|nextstep2|nextstep3|sunos4|ultrix|haiku)
               $3="$1"
    • With that patch I'm making further progress on stage1. I'll let you know if it succeeds

    • @hsyl20 this patch should be a commit :smile:

      I've successfully cross-compiled GHC on this (rebased) branch + that patch (on host aarch64-apple-darwin to target x86_64-w64-mingw32)

      Let's try to get this merged!

    • Author Developer

      Done!

    • Very good work both!

    • Please register or sign in to reply
  • Sylvain Henry added 403 commits

    added 403 commits

    Compare with previous version

  • Sylvain Henry marked the checklist item check that it also fixes cross-compilation from Darwin (first commit about AR; needs someone to check that it works): cf #22805 (closed) as completed

    marked the checklist item check that it also fixes cross-compilation from Darwin (first commit about AR; needs someone to check that it works): cf #22805 (closed) as completed

  • Sylvain Henry marked this merge request as ready

    marked this merge request as ready

  • Sylvain Henry changed title from Fix build of Windows cross-compiler (#20697) to Fix build of Windows cross-compiler (#20697, #22805)

    changed title from Fix build of Windows cross-compiler (#20697) to Fix build of Windows cross-compiler (#20697, #22805)

  • Sylvain Henry marked the checklist item check that third commit makes sense for W32 (whatever that is) and doesn't break CI as completed

    marked the checklist item check that third commit makes sense for W32 (whatever that is) and doesn't break CI as completed

  • Rodrigo Mesquita requested review from @bgamari

    requested review from @bgamari

  • Ben Gamari
  • Sylvain Henry added 28 commits

    added 28 commits

    Compare with previous version

  • Ben Gamari approved this merge request

    approved this merge request

  • assigned to @marge-bot

  • I will attempt to batch this MR (!9808 (closed))...

  • closed

  • Ben Gamari mentioned in merge request !9829 (closed)

    mentioned in merge request !9829 (closed)

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading