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

Commits:

1 changed file:

Changes:

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