Sven Tennie pushed to branch wip/supersven/hadrian-cross-stage3 at Glasgow Haskell Compiler / GHC

Commits:

3 changed files:

Changes:

  • hadrian/src/BindistConfig.hs
    ... ... @@ -24,7 +24,7 @@ crossBindist = BindistConfig { library_stage = Stage2, executable_stage = Stage1
    24 24
     targetBindist ::  BindistConfig
    
    25 25
     targetBindist = BindistConfig { library_stage = Stage2, executable_stage = Stage2 }
    
    26 26
     
    
    27
    --- | Parent folder under build root ("bindist" or "bindist-stage3")
    
    27
    +-- | Folder relative to build root ("bindist" or "bindist-stage3")
    
    28 28
     bindistFolder :: BindistConfig ->  FilePath
    
    29 29
     bindistFolder conf | executable_stage conf == Stage2 = "bindist-stage3"
    
    30 30
     bindistFolder _conf = "bindist"
    

  • hadrian/src/Rules/BinaryDist.hs
    ... ... @@ -19,66 +19,83 @@ import BindistConfig
    19 19
     Note [Binary distributions]
    
    20 20
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    21 21
     
    
    22
    -Hadrian produces binary distributions under:
    
    22
    +Hadrian produces binary distributions that run on the build host architecture
    
    23
    +(build == host, target == host || target /= host) under:
    
    23 24
       <build root>/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>.tar.xz
    
    24 25
     
    
    25
    -For stage3 (target) bindists, a separate parent folder is used:
    
    26
    +For stage3 (build /= host, host == target) bindists, a separate parent folder
    
    27
    +is used:
    
    26 28
       <build root>/bindist-stage3/ghc-<X>.<Y>.<Z>-<arch>-<os>.tar.xz
    
    27 29
     
    
    28
    -The stage2/cross bindist is generated by creating an archive from:
    
    29
    -  <build root>/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>/
    
    30
    +While regular bindists are usual same-arch compilers or cross-compilers, stage3
    
    31
    +bindists are cross-compiled compilers.
    
    30 32
     
    
    31
    -The stage3/target bindist is generated by creating an archive from:
    
    32
    -  <build root>/bindist-stage3/ghc-<X>.<Y>.<Z>-<arch>-<os>/
    
    33
    +Bindists are generated by creating an archive from:
    
    34
    +  <build root>/<bindist|bindist-stage3>/ghc-<X>.<Y>.<Z>-<arch>-<os>/
    
    33 35
     
    
    34
    -It does so by following the steps below.
    
    36
    +Stage2 cross-compilers are a by-product of creating stage3 cross-compiled
    
    37
    +compilers. The additional build dir (bindist-stage3) lets us keep both, such
    
    38
    +that we can build them in one go on CI.
    
    39
    +Configuration files (e.g. configure script and default.host.target) differ in
    
    40
    +this case and keeping both targets separated also saves us some headache
    
    41
    +dealing with stale files.
    
    35 42
     
    
    36
    -- make sure we have a complete stage 2 compiler + haddock
    
    43
    +This table introduces variables to simplify the following step descriptions:
    
    44
    +
    
    45
    +| compiler kind    | <bindist-dir>  | <executable-stage-dir> | <library-stage-dir> |
    
    46
    +|------------------|----------------|------------------------|---------------------|
    
    47
    +| native           | bindist        | stage1/                | stage1/             |
    
    48
    +| cross compiler   | bindist        | stage1/                | stage2/             |
    
    49
    +| cross-compiled   | bindist-stage3 | stage2/                | stage2/             |
    
    50
    +
    
    51
    +These are the steps to build a bindist:
    
    52
    +
    
    53
    +- make sure we have a complete compiler + libraries + haddock for the stage(s)
    
    54
    +  to bundle
    
    37 55
     
    
    38 56
     - copy the specific binaries which should be in the bindist to the
    
    39 57
       bin folder and add the version suffix:
    
    40
    -    <build root>/stage1/bin/xxxx
    
    58
    +    <build root>/<executable-stage-dir>/bin/xxxx
    
    41 59
       to
    
    42
    -    <build root/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>/bin/xxxx-<VER>
    
    60
    +    <build root>/<bindist-dir>/ghc-<X>.<Y>.<Z>-<arch>-<os>/bin/[<target>-]xxxx-<VER>
    
    61
    +  where the optional <target>- prefix is the cross triple for cross-compilers.
    
    43 62
     
    
    44 63
     - create symlink (or bash) wrapper from unversioned to versioned executable:
    
    45
    -    <build root/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>/bin/xxxx
    
    64
    +    <build root>/<bindist-dir>/ghc-<X>.<Y>.<Z>-<arch>-<os>/bin/[<target>-]xxxx
    
    46 65
       points to:
    
    47
    -    <build root/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>/bin/xxxx-<VER>
    
    66
    +    <build root>/<bindist-dir>/ghc-<X>.<Y>.<Z>-<arch>-<os>/bin/[<target>-]xxxx-<VER>
    
    48 67
     
    
    49 68
     - copy the lib directories of the compiler we built:
    
    50
    -    <build root>/stage1/lib
    
    69
    +    <build root>/<library-stage-dir>/lib
    
    51 70
       to
    
    52
    -    <build root>/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>/lib
    
    71
    +    <build root>/<bindist-dir>/ghc-<X>.<Y>.<Z>-<arch>-<os>/lib
    
    53 72
     
    
    54 73
     - copy the generated docs (user guide, haddocks, etc):
    
    55
    -    <build root>/docs/
    
    74
    +    <build root>/doc/
    
    56 75
       to
    
    57
    -    <build root>/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>/docs/
    
    76
    +    <build root>/<bindist-dir>/ghc-<X>.<Y>.<Z>-<arch>-<os>/doc/
    
    58 77
     
    
    59
    -- use autoreconf to generate per-stage `configure` scripts from
    
    60
    -  aclocal.m4 and stage1/distrib/configure.ac (for cross/compiler bindists) or
    
    61
    -  stage2/distrib/configure.ac (for target-native bindists), that we move to:
    
    62
    -    <build root>/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>/configure
    
    63
    -    <build root>/bindist-stage3/ghc-<X>.<Y>.<Z>-<arch>-<os>/configure
    
    78
    +- use autoreconf to generate a staged `configure` script in
    
    79
    +    <build root>/<executable-stage>/distrib
    
    80
    +  that we move to:
    
    81
    +    <build root>/<bindist-dir>/ghc-<X>.<Y>.<Z>-<arch>-<os>/configure
    
    64 82
     
    
    65 83
     - write a (fixed) Makefile capable of supporting 'make install' to:
    
    66
    -    <build root>/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>/Makefile
    
    84
    +    <build root>/<bindist-dir>/ghc-<X>.<Y>.<Z>-<arch>-<os>/Makefile
    
    67 85
     
    
    68 86
     - write some (fixed) supporting bash code for the wrapper scripts to:
    
    69
    -    <build root>/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>/wrappers/<program>
    
    87
    +    <build root>/<bindist-dir>/ghc-<X>.<Y>.<Z>-<arch>-<os>/wrappers/<program>
    
    70 88
     
    
    71 89
       where <program> is the name of the executable that the bash file will
    
    72 90
       help wrapping.
    
    73 91
     
    
    74
    -- copy supporting configure/make related files
    
    75
    -  (see @bindistInstallFiles@) to:
    
    76
    -    <build root>/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>/<file>
    
    92
    +- copy supporting configure/make related files (see @bindistInstallFiles@) to:
    
    93
    +    <build root>/<bindist-dir>/ghc-<X>.<Y>.<Z>-<arch>-<os>/<file>
    
    77 94
     
    
    78 95
     - create a .tar.xz archive of the directory:
    
    79
    -    <build root>/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>/
    
    96
    +    <build root>/<bindist-dir>/ghc-<X>.<Y>.<Z>-<arch>-<os>/
    
    80 97
       at
    
    81
    -    <build root>/bindist/ghc-<X>.<Y>.<Z>-<arch>-<os>.tar.xz
    
    98
    +    <build root>/<bindist-dir>/ghc-<X>.<Y>.<Z>-<arch>-<os>.tar.xz
    
    82 99
     
    
    83 100
     
    
    84 101
     Note [Wrapper scripts and binary distributions]
    

  • hadrian/src/Rules/Generate.hs
    ... ... @@ -567,7 +567,7 @@ generateSettings settingsFile includeLibDir rel_pkg_db compilerStage = do
    567 567
         stage <- getStage
    
    568 568
     
    
    569 569
         -- The unit-id of the base package which is always linked against (#25382).
    
    570
    -    -- For stage2 cross compilers the target libraries live in the stage2 lib
    
    570
    +    -- For stage2 cross compilers the target libraries live in the stage3 lib
    
    571 571
         -- dir, so the base unit-id must come from stage2; for native stage2 the
    
    572 572
         -- libraries live in the stage1 lib dir.
    
    573 573
         base_unit_id <- expr $ do