Serge S. Gulin pushed to branch wip/T25974 at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • .gitlab/ci.sh
    ... ... @@ -22,16 +22,16 @@ CABAL_CACHE="$TOP/${CABAL_CACHE:-cabal-cache}"
    22 22
     source "$TOP/.gitlab/common.sh"
    
    23 23
     
    
    24 24
     function time_it() {
    
    25
    -  local name="$1"
    
    25
    +  local -r name="$1"
    
    26 26
       shift
    
    27
    -  local start=$(date +%s)
    
    27
    +  local -r start=$(date +%s)
    
    28 28
       local res=0
    
    29 29
       set +e
    
    30 30
       ( set -e ; $@ )
    
    31 31
       res=$?
    
    32 32
       set -e
    
    33
    -  local end=$(date +%s)
    
    34
    -  local delta=$(expr $end - $start)
    
    33
    +  local -r end=$(date +%s)
    
    34
    +  local -r delta=$((end - start))
    
    35 35
     
    
    36 36
       echo "$name took $delta seconds"
    
    37 37
       printf "%15s | $delta" > ci-timings
    
    ... ... @@ -83,7 +83,8 @@ Environment variables affecting both build systems:
    83 83
                         - "extracted":
    
    84 84
                                  Toolchains will be downloaded and extracted through the
    
    85 85
                                  CI process. Default for other systems. Windows and FreeBSD
    
    86
    -                             are included.
    
    86
    +                             are included. PATH variable will be extended with a location
    
    87
    +                             to which toolchains will be installed.
    
    87 88
     
    
    88 89
     Environment variables determining build configuration of Hadrian system:
    
    89 90
     
    
    ... ... @@ -176,11 +177,6 @@ function mingw_init() {
    176 177
       esac
    
    177 178
     }
    
    178 179
     
    
    179
    -# This will contain GHC's local native toolchain
    
    180
    -toolchain="$TOP/toolchain"
    
    181
    -mkdir -p "$toolchain/bin"
    
    182
    -PATH="$toolchain/bin:$PATH"
    
    183
    -
    
    184 180
     export METRICS_FILE="$TOP/performance-metrics.tsv"
    
    185 181
     
    
    186 182
     cores="$(mk/detect-cpu-count.sh)"
    
    ... ... @@ -198,6 +194,8 @@ function show_tool() {
    198 194
     }
    
    199 195
     
    
    200 196
     function set_toolchain_paths() {
    
    197
    +  local -r toolchain_path="$1"
    
    198
    +
    
    201 199
       if [ -z "${TOOLCHAIN_SOURCE:-}" ]
    
    202 200
       then
    
    203 201
         # Fallback to automatic detection which could not work for cases
    
    ... ... @@ -214,11 +212,14 @@ function set_toolchain_paths() {
    214 212
     
    
    215 213
       case "$TOOLCHAIN_SOURCE" in
    
    216 214
         extracted)
    
    215
    +      mkdir -p "$toolchain_path/bin"
    
    216
    +      PATH="$toolchain_path/bin:$PATH"
    
    217
    +
    
    217 218
           # These are populated by setup_toolchain
    
    218
    -      GHC="$toolchain/bin/ghc$exe"
    
    219
    -      CABAL="$toolchain/bin/cabal$exe"
    
    220
    -      HAPPY="$toolchain/bin/happy$exe"
    
    221
    -      ALEX="$toolchain/bin/alex$exe"
    
    219
    +      GHC="$toolchain_path/bin/ghc$exe"
    
    220
    +      CABAL="$toolchain_path/bin/cabal$exe"
    
    221
    +      HAPPY="$toolchain_path/bin/happy$exe"
    
    222
    +      ALEX="$toolchain_path/bin/alex$exe"
    
    222 223
           if [ "$(uname)" = "FreeBSD" ]; then
    
    223 224
             GHC=/usr/local/bin/ghc
    
    224 225
           fi
    
    ... ... @@ -265,6 +266,8 @@ function cabal_update() {
    265 266
     
    
    266 267
     # Extract GHC toolchain
    
    267 268
     function setup() {
    
    269
    +  local -r toolchain_path="$1"
    
    270
    +
    
    268 271
       echo "=== TIMINGS ===" > ci-timings
    
    269 272
     
    
    270 273
       if [ -d "$CABAL_CACHE" ]; then
    
    ... ... @@ -274,7 +277,7 @@ function setup() {
    274 277
       fi
    
    275 278
     
    
    276 279
       case $TOOLCHAIN_SOURCE in
    
    277
    -    extracted) time_it "setup" setup_toolchain ;;
    
    280
    +    extracted) time_it "setup" setup_toolchain "${toolchain_path}" ;;
    
    278 281
         *) ;;
    
    279 282
       esac
    
    280 283
     
    
    ... ... @@ -299,6 +302,8 @@ function setup() {
    299 302
     }
    
    300 303
     
    
    301 304
     function fetch_ghc() {
    
    305
    +  local -r toolchain_path="$1"
    
    306
    +
    
    302 307
       local boot_triple_to_fetch
    
    303 308
       case "$(uname)" in
    
    304 309
         MSYS_*|MINGW*)
    
    ... ... @@ -324,31 +329,33 @@ function fetch_ghc() {
    324 329
       readonly boot_triple_to_fetch
    
    325 330
     
    
    326 331
       local -r v="$GHC_VERSION"
    
    327
    -      if [[ -z "$v" ]]; then
    
    328
    -          fail "neither GHC nor GHC_VERSION are not set"
    
    329
    -      fi
    
    332
    +  if [[ -z "$v" ]]; then
    
    333
    +    fail "neither GHC nor GHC_VERSION are not set"
    
    334
    +  fi
    
    330 335
     
    
    331
    -      start_section "fetch GHC"
    
    332
    -  url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple_to_fetch}.tar.xz"
    
    333
    -      info "Fetching GHC binary distribution from $url..."
    
    334
    -      curl "$url" > ghc.tar.xz || fail "failed to fetch GHC binary distribution"
    
    335
    -      $TAR -xJf ghc.tar.xz || fail "failed to extract GHC binary distribution"
    
    336
    -      case "$(uname)" in
    
    337
    -        MSYS_*|MINGW*)
    
    338
    -          cp -r ghc-${GHC_VERSION}*/* "$toolchain"
    
    339
    -          ;;
    
    340
    -        *)
    
    341
    -          pushd ghc-${GHC_VERSION}*
    
    342
    -          ./configure --prefix="$toolchain"
    
    343
    -          "$MAKE" install
    
    344
    -          popd
    
    345
    -          ;;
    
    346
    -      esac
    
    347
    -      rm -Rf "ghc-${GHC_VERSION}" ghc.tar.xz
    
    348
    -      end_section "fetch GHC"
    
    336
    +  start_section "fetch GHC"
    
    337
    +  local -r url="https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-${boot_triple_to_fetch}.tar.xz"
    
    338
    +  info "Fetching GHC binary distribution from $url..."
    
    339
    +  curl "$url" > ghc.tar.xz || fail "failed to fetch GHC binary distribution"
    
    340
    +  $TAR -xJf ghc.tar.xz || fail "failed to extract GHC binary distribution"
    
    341
    +  case "$(uname)" in
    
    342
    +    MSYS_*|MINGW*)
    
    343
    +      cp -r ghc-${GHC_VERSION}*/* "$toolchain_path"
    
    344
    +      ;;
    
    345
    +    *)
    
    346
    +      pushd ghc-${GHC_VERSION}*
    
    347
    +      ./configure --prefix="$toolchain_path"
    
    348
    +      "$MAKE" install
    
    349
    +      popd
    
    350
    +      ;;
    
    351
    +  esac
    
    352
    +  rm -Rf "ghc-${GHC_VERSION}" ghc.tar.xz
    
    353
    +  end_section "fetch GHC"
    
    349 354
     }
    
    350 355
     
    
    351 356
     function fetch_cabal() {
    
    357
    +  local -r toolchain_path="$1"
    
    358
    +
    
    352 359
       local v="$CABAL_INSTALL_VERSION"
    
    353 360
       if [[ -z "$v" ]]; then
    
    354 361
           fail "neither CABAL nor CABAL_INSTALL_VERSION are not set"
    
    ... ... @@ -381,9 +388,9 @@ function fetch_cabal() {
    381 388
           $TAR -xJf cabal.tar.xz
    
    382 389
           # Check if the bindist has directory structure
    
    383 390
           if [[ "$tmp" = "cabal" ]]; then
    
    384
    -          mv cabal "$toolchain/bin"
    
    391
    +          mv cabal "${toolchain_path}/bin"
    
    385 392
           else
    
    386
    -          mv "$tmp/cabal" "$toolchain/bin"
    
    393
    +          mv "$tmp/cabal" "${toolchain_path}/bin"
    
    387 394
           fi
    
    388 395
           ;;
    
    389 396
       esac
    
    ... ... @@ -394,12 +401,14 @@ function fetch_cabal() {
    394 401
     # here. For Docker platforms this is done in the Docker image
    
    395 402
     # build.
    
    396 403
     function setup_toolchain() {
    
    404
    +  local -r toolchain_path="$1"
    
    405
    +
    
    397 406
       if [ ! -e "$GHC" ]; then
    
    398
    -    fetch_ghc
    
    407
    +    fetch_ghc "${toolchain_path}"
    
    399 408
       fi
    
    400 409
     
    
    401 410
       if [ ! -e "$CABAL" ]; then
    
    402
    -    fetch_cabal
    
    411
    +    fetch_cabal "${toolchain_path}"
    
    403 412
       fi
    
    404 413
     
    
    405 414
       cabal_update
    
    ... ... @@ -407,7 +416,7 @@ function setup_toolchain() {
    407 416
       local cabal_install="$CABAL v2-install \
    
    408 417
         --with-compiler=$GHC \
    
    409 418
         --index-state=$HACKAGE_INDEX_STATE \
    
    410
    -    --installdir=$toolchain/bin \
    
    419
    +    --installdir=${toolchain_path}/bin \
    
    411 420
         --ignore-project \
    
    412 421
         --overwrite-policy=always"
    
    413 422
     
    
    ... ... @@ -1081,11 +1090,13 @@ if [[ -z ${BIGNUM_BACKEND:-} ]]; then BIGNUM_BACKEND=gmp; fi
    1081 1090
     
    
    1082 1091
     determine_metric_baseline
    
    1083 1092
     
    
    1084
    -set_toolchain_paths
    
    1093
    +# This will contain GHC's local native toolchain when TOOLCHAIN_SOURCE=extracted
    
    1094
    +toolchain="$TOP/toolchain"
    
    1095
    +set_toolchain_paths "${toolchain}"
    
    1085 1096
     
    
    1086 1097
     case ${1:-help} in
    
    1087 1098
       help|usage) usage ;;
    
    1088
    -  setup) setup && cleanup_submodules ;;
    
    1099
    +  setup) setup "${toolchain}" && cleanup_submodules ;;
    
    1089 1100
       configure) time_it "configure" configure ;;
    
    1090 1101
       build_hadrian) time_it "build" build_hadrian ;;
    
    1091 1102
       # N.B. Always push notes, even if the build fails. This is okay to do as the