Magnus pushed to branch wip/mangoiv/ci-stages at Glasgow Haskell Compiler / GHC

Commits:

23 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -68,8 +68,8 @@ stages:
    68 68
       - tool-lint      # Source linting of the tools
    
    69 69
       - quick-build    # A very quick smoke-test to weed out broken commits
    
    70 70
       - full-build     # Build all the things
    
    71
    -  - packaging      # Source distribution, etc.
    
    72 71
       - testing        # head.hackage correctness and compiler performance testing
    
    72
    +  - packaging      # Source distribution, etc.
    
    73 73
       - deploy         # push documentation
    
    74 74
     
    
    75 75
     # Note [The CI Story]
    
    ... ... @@ -445,10 +445,7 @@ lint-submods-branch:
    445 445
     hadrian-ghc-in-ghci:
    
    446 446
       stage: quick-build
    
    447 447
       extends: .lint-ghc-toolchain
    
    448
    -  needs:
    
    449
    -    - job: lint-linters
    
    450
    -    - job: lint-submods
    
    451
    -      optional: true
    
    448
    +  needs: []
    
    452 449
       variables:
    
    453 450
         GHC_FLAGS: -Werror -Wwarn=unused-imports
    
    454 451
       script:
    
    ... ... @@ -546,9 +543,18 @@ stack-hadrian-build:
    546 543
     # Testing reinstallable ghc codepath
    
    547 544
     ####################################
    
    548 545
     
    
    546
    +# cabal-reinstall artifacts aren't in the
    
    547
    +# bindists so it needs to run its testsuite
    
    548
    +# in-tree.
    
    549 549
     test-cabal-reinstall-x86_64-linux-deb13:
    
    550 550
       extends: nightly-x86_64-linux-deb13-validate
    
    551 551
       stage: full-build
    
    552
    +  script:
    
    553
    +  - sudo chown ghc:ghc -R .
    
    554
    +  - .gitlab/ci.sh setup
    
    555
    +  - .gitlab/ci.sh configure
    
    556
    +  - .gitlab/ci.sh build_hadrian
    
    557
    +  - .gitlab/ci.sh test_hadrian
    
    552 558
       variables:
    
    553 559
         REINSTALL_GHC: "yes"
    
    554 560
         BUILD_FLAVOUR: validate
    

  • .gitlab/ci.sh
    ... ... @@ -614,12 +614,12 @@ function make_install_destdir() {
    614 614
       fi
    
    615 615
       info "merging file tree from $destdir to $instdir"
    
    616 616
       cp -a "$destdir/$instdir"/* "$instdir"/
    
    617
    -  "$instdir"/bin/${cross_prefix}ghc-pkg recache
    
    617
    +  "$instdir/bin/${cross_prefix}ghc-pkg" recache
    
    618 618
     }
    
    619 619
     
    
    620 620
     # install the binary distribution in directory $1 to $2.
    
    621 621
     function install_bindist() {
    
    622
    -  start_section install-bindist "Install bindist"
    
    622
    +  start_section install-bindist "Install bindist ($1 -> $2)"
    
    623 623
       case "${CONFIGURE_WRAPPER:-}" in
    
    624 624
         emconfigure) source "$EMSDK/emsdk_env.sh" ;;
    
    625 625
         *) ;;
    
    ... ... @@ -631,7 +631,7 @@ function install_bindist() {
    631 631
       case "$(uname)" in
    
    632 632
         MSYS_*|MINGW*)
    
    633 633
           mkdir -p "$instdir"
    
    634
    -      cp -a * "$instdir"
    
    634
    +      cp -a ./* "$instdir"
    
    635 635
           ;;
    
    636 636
         *)
    
    637 637
           read -r -a args <<< "${INSTALL_CONFIGURE_ARGS:-}"
    
    ... ... @@ -648,39 +648,75 @@ function install_bindist() {
    648 648
       end_section install-bindist
    
    649 649
     }
    
    650 650
     
    
    651
    +function find_bindist_tar() {
    
    652
    +  local tar_files
    
    653
    +  tar_files=( *ghc*.tar.xz )
    
    654
    +  if [[ ${#tar_files[@]} -gt 0 ]]; then
    
    655
    +    bindist_tar="${tar_files[0]}"
    
    656
    +  else
    
    657
    +    unset bindist_tar
    
    658
    +  fi
    
    659
    +}
    
    660
    +
    
    661
    +# stage 1 tests -- these do not run as part
    
    662
    +# of the test stage but already as part of the
    
    663
    +# build stage as they don't require a bindist
    
    664
    +function test_hadrian_stage1() {
    
    665
    +    # Ensure that statically-linked builds are actually static
    
    666
    +    if [[ "${BUILD_FLAVOUR}" = *static* ]]; then
    
    667
    +      bad_execs=""
    
    668
    +      for binary in _build/stage1/bin/*; do
    
    669
    +        if ldd "${binary}" &> /dev/null; then
    
    670
    +          warn "${binary} is not static!"
    
    671
    +          ldd "${binary}"
    
    672
    +          echo
    
    673
    +          bad_execs="$bad_execs $binary"
    
    674
    +        fi
    
    675
    +      done
    
    676
    +      if [ -n "$bad_execs" ]; then
    
    677
    +        fail "the following executables contain dynamic-object references: $bad_execs"
    
    678
    +      fi
    
    679
    +    fi
    
    680
    +
    
    681
    +    if [[ "${CI_JOB_NAME}" != *"windows"* ]] && [ -z "${CROSS_TARGET:-}" ] && [ -z "${REINSTALL_GHC:-}" ]
    
    682
    +
    
    683
    +    then
    
    684
    +      run_hadrian \
    
    685
    +        test \
    
    686
    +        --test-root-dirs=testsuite/tests/stage1 \
    
    687
    +        --test-compiler=stage1 \
    
    688
    +        ${TEST_WAYS[@]/#/--test-way=} \
    
    689
    +        "runtest.opts+=${RUNTEST_ARGS:-}" || fail "hadrian stage1 test"
    
    690
    +      info "STAGE1_TEST=$?"
    
    691
    +    fi
    
    692
    +}
    
    693
    +
    
    651 694
     function test_hadrian() {
    
    652
    -  check_msys2_deps _build/stage1/bin/ghc --version
    
    695
    +
    
    696
    +   find_bindist_tar
    
    697
    +   dist_dir="_build/bindist"
    
    698
    +
    
    699
    +   if [ -n "$bindist_tar" ]; then
    
    700
    +     mkdir -p "$dist_dir"
    
    701
    +     tar -xf "$bindist_tar" -C "$dist_dir"
    
    702
    +   fi
    
    703
    +
    
    653 704
       check_release_build
    
    654 705
     
    
    655 706
       # GitLab's log viewer renders ANSI colors, but stdout here is not a tty,
    
    656 707
       # so the driver must be told to emit them.
    
    657 708
       RUNTEST_ARGS="${RUNTEST_ARGS:-} --force-colors"
    
    658 709
     
    
    659
    -  # Ensure that statically-linked builds are actually static
    
    660
    -  if [[ "${BUILD_FLAVOUR}" = *static* ]]; then
    
    661
    -    bad_execs=""
    
    662
    -    for binary in _build/stage1/bin/*; do
    
    663
    -      if ldd "${binary}" &> /dev/null; then
    
    664
    -        warn "${binary} is not static!"
    
    665
    -        ldd "${binary}"
    
    666
    -        echo
    
    667
    -        bad_execs="$bad_execs $binary"
    
    668
    -      fi
    
    669
    -    done
    
    670
    -    if [ -n "$bad_execs" ]; then
    
    671
    -      fail "the following executables contain dynamic-object references: $bad_execs"
    
    672
    -    fi
    
    673
    -  fi
    
    674
    -
    
    675 710
     
    
    676 711
       if [[ "${CROSS_EMULATOR:-}" == "NOT_SET" ]]; then
    
    677 712
         info "Cannot test cross-compiled build without CROSS_EMULATOR being set."
    
    678 713
         return
    
    679 714
       # If we have set CROSS_EMULATOR, then can't test using normal testsuite.
    
    680 715
       elif [ -n "${CROSS_EMULATOR:-}" ] && [[ "${CROSS_TARGET:-}" != *"wasm"* ]]; then
    
    716
    +    info "Cross compiling with CROSS_EMULATOR='$CROSS_EMULATOR' and CROSS_TARGET='$CROSS_TARGET'"
    
    681 717
         local instdir="$TOP/_build/install"
    
    682 718
         local test_compiler="$instdir/bin/${cross_prefix}ghc$exe"
    
    683
    -    install_bindist _build/bindist/ghc-*/ "$instdir"
    
    719
    +    install_bindist $dist_dir/ghc-*/ "$instdir"
    
    684 720
         echo 'main = putStrLn "hello world"' > expected
    
    685 721
         run "$test_compiler" -package ghc "$TOP/.gitlab/hello.hs" -o hello
    
    686 722
     
    
    ... ... @@ -701,6 +737,7 @@ function test_hadrian() {
    701 737
         # > main = putStrLn "hello world"
    
    702 738
         run diff -w expected actual
    
    703 739
       elif [[ -n "${REINSTALL_GHC:-}" ]]; then
    
    740
    +    info "Running with reinstall GHC $REINSTALL_GHC"
    
    704 741
         run_hadrian \
    
    705 742
           test \
    
    706 743
           --test-root-dirs=testsuite/tests/stage1 \
    
    ... ... @@ -714,18 +751,9 @@ function test_hadrian() {
    714 751
       else
    
    715 752
         local instdir="$TOP/_build/install"
    
    716 753
         local test_compiler="$instdir/bin/${cross_prefix}ghc$exe"
    
    717
    -    install_bindist _build/bindist/ghc-*/ "$instdir"
    
    754
    +    install_bindist $dist_dir/ghc-*/ "$instdir"
    
    718 755
     
    
    719
    -    if [[ "${CI_JOB_NAME}" != *"windows"* ]] && [ -z "${CROSS_TARGET:-}" ]
    
    720
    -    then
    
    721
    -      run_hadrian \
    
    722
    -        test \
    
    723
    -        --test-root-dirs=testsuite/tests/stage1 \
    
    724
    -        --test-compiler=stage1 \
    
    725
    -        ${TEST_WAYS[@]/#/--test-way=} \
    
    726
    -        "runtest.opts+=${RUNTEST_ARGS:-}" || fail "hadrian stage1 test"
    
    727
    -      info "STAGE1_TEST=$?"
    
    728
    -    fi
    
    756
    +    check_msys2_deps "$test_compiler" --version
    
    729 757
     
    
    730 758
         # Ensure the resulting compiler has the correct bignum-flavour,
    
    731 759
         # except for cross-compilers as they may not support the interpreter
    
    ... ... @@ -735,6 +763,8 @@ function test_hadrian() {
    735 763
           if [ $test_compiler_backend != "\"$BIGNUM_BACKEND\"" ]; then
    
    736 764
             fail "Test compiler has a different BIGNUM_BACKEND ($test_compiler_backend) than requested ($BIGNUM_BACKEND)"
    
    737 765
           fi
    
    766
    +    else 
    
    767
    +      info "CROSS_TARGET=$CROSS_TARGET"
    
    738 768
         fi
    
    739 769
     
    
    740 770
         # If we are doing a release job, check the compiler can build a profiled executable
    
    ... ... @@ -747,15 +777,14 @@ function test_hadrian() {
    747 777
         run_hadrian \
    
    748 778
           test \
    
    749 779
           --summary-junit=./junit.xml \
    
    750
    -      --test-have-intree-files \
    
    751 780
           --test-compiler="${test_compiler}" \
    
    781
    +      --test-have-intree-files \
    
    752 782
           ${TEST_WAYS[@]/#/--test-way=} \
    
    753 783
           "runtest.opts+=${RUNTEST_ARGS:-}" \
    
    754 784
           "runtest.opts+=--unexpected-output-dir=$TOP/unexpected-test-output" \
    
    755 785
           || fail "hadrian main testsuite"
    
    756 786
     
    
    757 787
         info "STAGE2_TEST=$?"
    
    758
    -
    
    759 788
       fi
    
    760 789
     }
    
    761 790
     
    
    ... ... @@ -946,7 +975,7 @@ function run_hadrian() {
    946 975
       if [ -n "${VERBOSE:-}" ]; then args+=("-V"); fi
    
    947 976
       # Before running the compiler, unset variables gitlab env vars as these
    
    948 977
       # can destabilise the performance test (see #20341)
    
    949
    -  (unset $(compgen -v | grep CI_*);
    
    978
    +  (unset $(compgen -v | grep -E '^(CI_|FF_|GITLAB_)');
    
    950 979
         run "${HADRIAN_PATH:-hadrian/build-cabal}" \
    
    951 980
           --flavour="$BUILD_FLAVOUR" \
    
    952 981
           -j"$cores" \
    
    ... ... @@ -1131,6 +1160,10 @@ case ${1:-help} in
    1131 1160
         time_it "test" test_hadrian || res=$?
    
    1132 1161
         push_perf_notes
    
    1133 1162
         exit $res ;;
    
    1163
    +  test_hadrian_stage1)
    
    1164
    +    res=0
    
    1165
    +    time_it "stage1 tests" test_hadrian_stage1 || res=$?
    
    1166
    +    exit $res ;;
    
    1134 1167
       run_hadrian) shift; run_hadrian "$@" ;;
    
    1135 1168
       perf_test) run_perf_test ;;
    
    1136 1169
       abi_test) abi_test ;;
    

  • .gitlab/common.sh
    ... ... @@ -47,7 +47,7 @@ info() { echo_color "${LT_BLUE}" "$1"; }
    47 47
     fail() { error "error: $1"; exit 1; }
    
    48 48
     
    
    49 49
     function run() {
    
    50
    -  info "Running $*..."
    
    50
    +  info "Running $*"
    
    51 51
       "$@" || ( error "$* failed"; return 1; )
    
    52 52
     }
    
    53 53
     

  • .gitlab/generate-ci/gen_ci.hs
    1 1
     #!/usr/bin/env cabal
    
    2 2
     {-# LANGUAGE RecordWildCards #-}
    
    3 3
     {-# LANGUAGE OverloadedStrings #-}
    
    4
    +{-# LANGUAGE OverloadedRecordDot #-}
    
    4 5
     {-# LANGUAGE DeriveFunctor #-}
    
    5 6
     {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    
    6 7
     {-# LANGUAGE ViewPatterns #-}
    
    ... ... @@ -10,6 +11,8 @@
    10 11
     {-# HLINT ignore "Use newtype instead of data" #-}
    
    11 12
     {-# HLINT ignore "Use camelCase" #-}
    
    12 13
     {-# LANGUAGE DerivingStrategies #-}
    
    14
    +{-# LANGUAGE NamedFieldPuns #-}
    
    15
    +{-# LANGUAGE TypeFamilies #-}
    
    13 16
     
    
    14 17
     import Data.Aeson as A
    
    15 18
     import qualified Data.Map as Map
    
    ... ... @@ -172,6 +175,7 @@ data BuildConfig
    172 175
                     , textWithSIMDUTF :: Bool
    
    173 176
                     , testsuiteUsePerf :: Bool
    
    174 177
                     , testsuiteWays :: [String]
    
    178
    +                , extendName :: String -> String
    
    175 179
                     }
    
    176 180
     
    
    177 181
     -- Extra arguments to pass to ./configure due to the BuildConfig
    
    ... ... @@ -242,6 +246,7 @@ vanilla = BuildConfig
    242 246
       , textWithSIMDUTF = False
    
    243 247
       , testsuiteUsePerf = False
    
    244 248
       , testsuiteWays = []
    
    249
    +  , extendName = id
    
    245 250
       }
    
    246 251
     
    
    247 252
     splitSectionsBroken :: BuildConfig -> BuildConfig
    
    ... ... @@ -796,14 +801,17 @@ validateRuleString LoongArch64 = labelString "loongarch"
    796 801
     -- certain platforms and so on.
    
    797 802
     data Job
    
    798 803
       = Job { jobStage :: String
    
    799
    -        , jobNeeds :: [String]
    
    804
    +        , jobNeeds :: [(String, Bool)]
    
    805
    +        -- ^ needs mustn't be combined with
    
    806
    +        --   dependencies; since we have needs
    
    807
    +        --   we rule out dependencies by not
    
    808
    +        --   adding it to this record
    
    800 809
             , jobTags :: [String]
    
    801 810
             , jobAllowFailure :: Bool
    
    802 811
             , jobScript :: [String]
    
    803 812
             , jobAfterScript :: [String]
    
    804 813
             , jobDockerImage :: Maybe String
    
    805 814
             , jobVariables :: Variables
    
    806
    -        , jobDependencies :: [String]
    
    807 815
             , jobArtifacts :: Artifacts
    
    808 816
             , jobCache :: Cache
    
    809 817
             , jobRules :: OnOffRules
    
    ... ... @@ -818,8 +826,7 @@ instance ToJSON Job where
    818 826
         [ "stage" A..= jobStage
    
    819 827
           -- Convoluted to avoid download artifacts from ghci job
    
    820 828
           -- https://docs.gitlab.com/ee/ci/yaml/#needsartifacts
    
    821
    -    , "needs" A..= map (\j -> object [ "job" A..= j, "artifacts" A..= False ]) jobNeeds
    
    822
    -    , "dependencies" A..= jobDependencies
    
    829
    +    , "needs" A..= map (\(j, a) -> object [ "job" A..= j, "artifacts" A..= a ]) jobNeeds
    
    823 830
         , "image" A..= jobDockerImage
    
    824 831
         , "tags" A..= jobTags
    
    825 832
         , "allow_failure" A..= jobAllowFailure
    
    ... ... @@ -834,25 +841,48 @@ instance ToJSON Job where
    834 841
         ]
    
    835 842
     
    
    836 843
     -- | Build a job description from the system description and 'BuildConfig'
    
    837
    -job :: Arch -> Opsys -> BuildConfig -> NamedJob Job
    
    838
    -job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} }
    
    844
    +job :: Arch -> Opsys -> BuildConfig -> BuildAndTestJob Job
    
    845
    +job arch opsys buildConfig =
    
    846
    +  MkBuildAndTestJob
    
    847
    +    { buildJob = NamedJob { name = jobName, jobInfo = Job { jobScript = jobBuildScript, jobStage = "full-build", jobNeeds =  [("hadrian-ghc-in-ghci", False)], jobArtifacts = buildJobArtifacts, ..} }
    
    848
    +    , testJobs =
    
    849
    +      NamedJob { name = jobName <> "-test", jobInfo = testJobInfo } :
    
    850
    +      [ NamedJob
    
    851
    +        { name = jobName <> "-testperf"
    
    852
    +        , jobInfo = testJobInfo
    
    853
    +          { jobVariables = testJobInfo.jobVariables <> "RUNTEST_ARGS" =: "--config perf_path=perf"
    
    854
    +          , jobTags = [runnerPerfTag arch opsys]
    
    855
    +          } }
    
    856
    +        | testsuiteUsePerf buildConfig  ] }
    
    839 857
       where
    
    858
    +    testJobInfo = Job {jobScript = jobTestScript, jobNeeds = [(jobName, True)], jobStage = "testing", jobArtifacts = testJobArtifacts, ..}
    
    840 859
         jobPlatform = (arch, opsys)
    
    841 860
     
    
    842 861
         jobRules = emptyRules jobName
    
    843 862
     
    
    844
    -    jobName = testEnv arch opsys buildConfig
    
    863
    +    jobName =  extendName buildConfig $ testEnv arch opsys buildConfig
    
    845 864
     
    
    846 865
         jobTags = tags arch opsys buildConfig
    
    847 866
     
    
    848 867
         jobDockerImage = dockerImage arch opsys
    
    849 868
     
    
    850
    -    jobScript
    
    869
    +    jobTestScript
    
    870
    +      | Windows <- opsys
    
    871
    +      = [ "bash .gitlab/ci.sh setup"
    
    872
    +        , "bash .gitlab/ci.sh configure" -- configure needs to be run because hadrian gets its config like that
    
    873
    +        , "bash .gitlab/ci.sh test_hadrian" ]
    
    874
    +      | otherwise
    
    875
    +      = [ "sudo chown ghc:ghc -R ." | Linux {} <- [opsys]] ++
    
    876
    +        [ ".gitlab/ci.sh setup"
    
    877
    +        , ".gitlab/ci.sh configure"
    
    878
    +        , ".gitlab/ci.sh test_hadrian" ]
    
    879
    +
    
    880
    +    jobBuildScript
    
    851 881
           | Windows <- opsys
    
    852 882
           = [ "bash .gitlab/ci.sh setup"
    
    853 883
             , "bash .gitlab/ci.sh configure"
    
    854 884
             , "bash .gitlab/ci.sh build_hadrian"
    
    855
    -        , "bash .gitlab/ci.sh test_hadrian"
    
    885
    +        , "bash .gitlab/ci.sh test_hadrian_stage1"
    
    856 886
             ]
    
    857 887
           | otherwise
    
    858 888
           = [ "find libraries -name config.sub -exec cp config.sub {} \\;" | Darwin == opsys ] ++
    
    ... ... @@ -860,7 +890,7 @@ job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} }
    860 890
             [ ".gitlab/ci.sh setup"
    
    861 891
             , ".gitlab/ci.sh configure"
    
    862 892
             , ".gitlab/ci.sh build_hadrian"
    
    863
    -        , ".gitlab/ci.sh test_hadrian"
    
    893
    +        , ".gitlab/ci.sh test_hadrian_stage1"
    
    864 894
             ]
    
    865 895
     
    
    866 896
         jobAfterScript
    
    ... ... @@ -878,7 +908,6 @@ job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} }
    878 908
     
    
    879 909
         jobFlavour = mkJobFlavour buildConfig
    
    880 910
     
    
    881
    -    jobDependencies = []
    
    882 911
         jobVariables = mconcat
    
    883 912
           [ opsysVariables arch opsys
    
    884 913
           , "TEST_ENV" =: testEnv arch opsys buildConfig
    
    ... ... @@ -915,7 +944,6 @@ job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} }
    915 944
                     | validateNonmovingGc buildConfig
    
    916 945
                     ]
    
    917 946
             in "RUNTEST_ARGS" =: (trim . unwords) runtestArgs
    
    918
    -      , if testsuiteUsePerf buildConfig then "RUNTEST_ARGS" =: "--config perf_path=perf" else mempty
    
    919 947
           , "TEST_WAYS" =: unwords (testsuiteWays buildConfig)
    
    920 948
           ]
    
    921 949
     
    
    ... ... @@ -924,7 +952,7 @@ job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} }
    924 952
     
    
    925 953
         -- Keep in sync with the exclude list in `function clean()` in
    
    926 954
         -- `.gitlab/ci.sh`!
    
    927
    -    jobArtifacts = Artifacts
    
    955
    +    buildJobArtifacts = Artifacts
    
    928 956
           { junitReport = "junit.xml"
    
    929 957
           , expireIn = "2 weeks"
    
    930 958
           , artifactPaths = [binDistName arch opsys buildConfig ++ ".tar.xz"
    
    ... ... @@ -933,6 +961,15 @@ job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} }
    933 961
           , artifactsWhen = ArtifactsAlways
    
    934 962
           }
    
    935 963
     
    
    964
    +    -- don't reupload the bindist from the testsuite run
    
    965
    +    testJobArtifacts = Artifacts
    
    966
    +      { junitReport = "junit.xml"
    
    967
    +      , expireIn = "2 weeks"
    
    968
    +      , artifactPaths = ["junit.xml"
    
    969
    +                        ,"unexpected-test-output.tar.gz"]
    
    970
    +      , artifactsWhen = ArtifactsAlways
    
    971
    +      }
    
    972
    +
    
    936 973
         jobCache
    
    937 974
             -- N.B. We have temporarily disabled cabal-install store caching on
    
    938 975
             -- Windows due to #21347.
    
    ... ... @@ -945,8 +982,6 @@ job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} }
    945 982
               }
    
    946 983
     
    
    947 984
         jobAllowFailure = False
    
    948
    -    jobStage = "full-build"
    
    949
    -    jobNeeds = ["hadrian-ghc-in-ghci"]
    
    950 985
     
    
    951 986
     ---------------------------------------------------------------------------
    
    952 987
     -- Job Modifiers
    
    ... ... @@ -997,7 +1032,7 @@ delVariable k j = j { jobVariables = MonoidalMap $ Map.delete k $ unMonoidalMap
    997 1032
     ---------------------------------------------------------------------
    
    998 1033
     
    
    999 1034
     -- | Make a normal validate CI job
    
    1000
    -validate :: Arch -> Opsys -> BuildConfig -> NamedJob Job
    
    1035
    +validate :: Arch -> Opsys -> BuildConfig -> BuildAndTestJob Job
    
    1001 1036
     validate = job
    
    1002 1037
     
    
    1003 1038
     -- Nightly and release apply the FastCI configuration to all jobs so that they all run in
    
    ... ... @@ -1009,25 +1044,28 @@ releaseRule :: Job -> Job
    1009 1044
     releaseRule = setJobRule ReleaseOnly
    
    1010 1045
     
    
    1011 1046
     -- | Make a normal nightly CI job
    
    1012
    -nightly :: Arch -> Opsys -> BuildConfig -> NamedJob Job
    
    1047
    +nightly :: Arch -> Opsys -> BuildConfig -> BuildAndTestJob Job
    
    1013 1048
     nightly arch opsys bc =
    
    1014
    -  let NamedJob n j = job arch opsys bc
    
    1015
    -  in NamedJob { name = "nightly-" ++ n
    
    1049
    +  let MkBuildAndTestJob {buildJob, testJobs} = job arch opsys bc { extendName = ("nightly-" <>) . bc.extendName }
    
    1050
    +      mkJob NamedJob {name, jobInfo}
    
    1051
    +             = NamedJob { name
    
    1016 1052
                   , jobInfo = nightlyRule
    
    1017 1053
                             . keepArtifacts "8 weeks"
    
    1018
    -                        . highCompression $ j
    
    1054
    +                        . highCompression $ jobInfo
    
    1019 1055
                   }
    
    1056
    +      in MkBuildAndTestJob { buildJob = mkJob buildJob, testJobs = map mkJob testJobs}
    
    1020 1057
     
    
    1021 1058
     -- | Make a normal release CI job
    
    1022
    -release :: Arch -> Opsys -> BuildConfig -> NamedJob Job
    
    1059
    +release :: Arch -> Opsys -> BuildConfig -> BuildAndTestJob Job
    
    1023 1060
     release arch opsys bc =
    
    1024
    -  let NamedJob n j = job arch opsys (bc { buildFlavour = Release })
    
    1025
    -  in NamedJob { name = "release-" ++ n
    
    1061
    +  let MkBuildAndTestJob {buildJob, testJobs} = job arch opsys (bc { buildFlavour = Release, extendName = ("release-" <>) . bc.extendName })
    
    1062
    +      mkJob NamedJob {name, jobInfo} = NamedJob { name
    
    1026 1063
                   , jobInfo = releaseRule
    
    1027 1064
                             . keepArtifacts "1 year"
    
    1028 1065
                             . ignorePerfFailures
    
    1029
    -                        . highCompression $ j
    
    1066
    +                        . highCompression $ jobInfo
    
    1030 1067
                   }
    
    1068
    +   in MkBuildAndTestJob {buildJob = mkJob buildJob, testJobs = map mkJob testJobs}
    
    1031 1069
     ---------------------------------------------------------------------
    
    1032 1070
     -- Specific job modification functions
    
    1033 1071
     ---------------------------------------------------------------------
    
    ... ... @@ -1053,11 +1091,6 @@ ignorePerfFailures = addVariable "IGNORE_PERF_FAILURES" "all"
    1053 1091
     highCompression :: Job -> Job
    
    1054 1092
     highCompression = addVariable "XZ_OPT" "-9"
    
    1055 1093
     
    
    1056
    --- | Change the tag of the job to make sure the job is scheduled on a
    
    1057
    --- runner that has the necessary capabilties to run the job with 'perf'
    
    1058
    --- profiling counters.
    
    1059
    -perfProfilingJobTag :: Arch -> Opsys -> Job -> Job
    
    1060
    -perfProfilingJobTag arch opsys j = j { jobTags = [ runnerPerfTag arch opsys ] }
    
    1061 1094
     
    
    1062 1095
     -- | Mark the validate job to run in fast-ci mode
    
    1063 1096
     -- This is default way, to enable all jobs you have to apply the `full-ci` label.
    
    ... ... @@ -1090,8 +1123,8 @@ disableValidate = modifyValidateJobs (removeValidateJobRule FastCI . removeValid
    1090 1123
     
    
    1091 1124
     data NamedJob a = NamedJob { name :: String, jobInfo :: a } deriving (Show, Functor)
    
    1092 1125
     
    
    1093
    -renameJob :: (String -> String) -> NamedJob a -> NamedJob a
    
    1094
    -renameJob f (NamedJob n i) = NamedJob (f n) i
    
    1126
    +data BuildAndTestJob a = MkBuildAndTestJob { buildJob :: NamedJob a, testJobs :: [NamedJob a]}
    
    1127
    +  deriving stock (Show, Functor)
    
    1095 1128
     
    
    1096 1129
     instance ToJSON a => ToJSON (NamedJob a) where
    
    1097 1130
       toJSON nj = object
    
    ... ... @@ -1105,21 +1138,21 @@ instance ToJSON a => ToJSON (NamedJob a) where
    1105 1138
     -- Jobs are grouped into either triples or pairs depending on whether the
    
    1106 1139
     -- job is just validate and nightly, or also release.
    
    1107 1140
     data JobGroup a
    
    1108
    -  = StandardTriple { v :: Maybe (NamedJob a)
    
    1109
    -                   , n :: Maybe (NamedJob a)
    
    1110
    -                   , r :: Maybe (NamedJob a)
    
    1141
    +  = StandardTriple { v :: Maybe (BuildAndTestJob a)
    
    1142
    +                   , n :: Maybe (BuildAndTestJob a)
    
    1143
    +                   , r :: Maybe (BuildAndTestJob a)
    
    1111 1144
                        }
    
    1112 1145
       deriving (Functor, Show)
    
    1113 1146
     
    
    1114 1147
     instance ToJSON a => ToJSON (JobGroup a) where
    
    1115 1148
       toJSON StandardTriple{..} = object
    
    1116
    -    [ "v" A..= v
    
    1117
    -    , "n" A..= n
    
    1118
    -    , "r" A..= r
    
    1119
    -    ]
    
    1149
    +    [ "v" .= v
    
    1150
    +    , "n" .= n
    
    1151
    +    , "r" .= r ]
    
    1120 1152
     
    
    1121
    -rename :: (String -> String) -> JobGroup a -> JobGroup a
    
    1122
    -rename f (StandardTriple nv nn nr) = StandardTriple (renameJob f <$> nv) (renameJob f <$> nn) (renameJob f <$> nr)
    
    1153
    +instance ToJSON a => ToJSON (BuildAndTestJob a) where
    
    1154
    +    -- the test job is not relevant for the job metadata output
    
    1155
    +  toJSON MkBuildAndTestJob {buildJob} = toJSON buildJob
    
    1123 1156
     
    
    1124 1157
     -- | Construct a 'JobGroup' which consists of a validate, nightly and release build with
    
    1125 1158
     -- a specific config.
    
    ... ... @@ -1142,10 +1175,10 @@ validateBuilds a op bc = StandardTriple { v = Just (validate a op bc)
    1142 1175
                                             , r = Nothing }
    
    1143 1176
     
    
    1144 1177
     flattenJobGroup :: JobGroup a -> [(String, a)]
    
    1145
    -flattenJobGroup (StandardTriple a b c) = map flattenNamedJob (catMaybes [a,b,c])
    
    1178
    +flattenJobGroup (StandardTriple a b c) = concatMap flattenNamedJob (catMaybes [a,b,c])
    
    1146 1179
     
    
    1147
    -flattenNamedJob :: NamedJob a -> (String, a)
    
    1148
    -flattenNamedJob (NamedJob n i) = (n, i)
    
    1180
    +flattenNamedJob :: BuildAndTestJob a -> [(String, a)]
    
    1181
    +flattenNamedJob MkBuildAndTestJob {buildJob, testJobs} = (buildJob.name, buildJob.jobInfo) :  map (\NamedJob {name, jobInfo} -> (name, jobInfo)) testJobs
    
    1149 1182
     
    
    1150 1183
     -- | Specification for all the jobs we want to build.
    
    1151 1184
     jobs :: Map String Job
    
    ... ... @@ -1172,8 +1205,9 @@ debian_x86 =
    1172 1205
       , modifyNightlyJobs allowFailure (modifyValidateJobs (allowFailure . manual) tsan_jobs)
    
    1173 1206
       , -- Nightly allowed to fail: #22343
    
    1174 1207
         modifyNightlyJobs allowFailure (modifyValidateJobs manual (validateBuilds Amd64 (Linux validate_debian) noTntc))
    
    1208
    +
    
    1175 1209
         -- Run the 'perf' profiling nightly job in the release config.
    
    1176
    -  , perfProfilingJob Amd64 (Linux Debian13) releaseConfig
    
    1210
    +  , disableValidate (validateBuilds Amd64 (Linux validate_debian) (usePerfProfilingTestsuite releaseConfig))
    
    1177 1211
     
    
    1178 1212
       , onlyRule LLVMBackend (validateBuilds Amd64 (Linux validate_debian) llvm)
    
    1179 1213
       , addValidateRule TestPrimops (standardBuilds Amd64 (Linux validate_debian))
    
    ... ... @@ -1184,12 +1218,6 @@ debian_x86 =
    1184 1218
       where
    
    1185 1219
         validate_debian = Debian13
    
    1186 1220
     
    
    1187
    -    perfProfilingJob arch sys buildConfig =
    
    1188
    -        -- Rename the job to avoid conflicts
    
    1189
    -        rename (<> "-perf")
    
    1190
    -          $ modifyJobs (perfProfilingJobTag arch sys)
    
    1191
    -          $ disableValidate (validateBuilds arch sys $ usePerfProfilingTestsuite buildConfig)
    
    1192
    -
    
    1193 1221
         tsan_jobs =
    
    1194 1222
           modifyJobs
    
    1195 1223
             ( addVariable "TSAN_OPTIONS" "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions"
    
    ... ... @@ -1231,7 +1259,7 @@ fedora_x86 =
    1231 1259
         -- validate pipeline which is built with perf.
    
    1232 1260
         fastCI (standardBuildsWithConfig Amd64 (Linux Fedora43) releaseConfig)
    
    1233 1261
         -- This job is only for generating head.hackage docs
    
    1234
    -  , hackage_doc_job (disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora43) releaseConfig))
    
    1262
    +  , hackage_doc_job
    
    1235 1263
       , disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora43) dwarf)
    
    1236 1264
       , disableValidate (standardBuilds Amd64 (Linux Fedora43))
    
    1237 1265
         -- For UBSan jobs, only enable for validate/nightly pipelines.
    
    ... ... @@ -1245,7 +1273,10 @@ fedora_x86 =
    1245 1273
           $ validateBuilds Amd64 (Linux Fedora43) enableUBSan
    
    1246 1274
       ]
    
    1247 1275
       where
    
    1248
    -    hackage_doc_job = rename (<> "-hackage") . modifyJobs (addVariable "HADRIAN_ARGS" "--haddock-for-hackage")
    
    1276
    +    hackage_doc_job
    
    1277
    +      = modifyJobs (addVariable "HADRIAN_ARGS" "--haddock-for-hackage") $
    
    1278
    +        disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora43)
    
    1279
    +        releaseConfig { extendName = (<> "-hackage") . releaseConfig.extendName })
    
    1249 1280
     
    
    1250 1281
     windows_x86 :: [JobGroup Job]
    
    1251 1282
     windows_x86 =
    
    ... ... @@ -1438,7 +1469,10 @@ platform_mapping = Map.map go combined_result
    1438 1469
     
    
    1439 1470
         process sel =
    
    1440 1471
           Map.fromListWith combine
    
    1441
    -      [ (uncurry mkPlatform (jobPlatform (jobInfo j)), j)
    
    1472
    +      -- for now we only support buildJob platform equals testjob platform
    
    1473
    +      -- if this restriction were to be lifted, we just had to indicate that the
    
    1474
    +      -- specific testjob runs on a different platform
    
    1475
    +      [ (uncurry mkPlatform (jobPlatform (jobInfo (buildJob j))), j)
    
    1442 1476
           | (sel -> Just j) <- job_groups
    
    1443 1477
           ]
    
    1444 1478
     
    
    ... ... @@ -1457,15 +1491,15 @@ platform_mapping = Map.map go combined_result
    1457 1491
           | platform <- S.toList all_platforms
    
    1458 1492
           ]
    
    1459 1493
     
    
    1460
    -    combine a b
    
    1494
    +    combine bta@MkBuildAndTestJob {buildJob = a} btb@MkBuildAndTestJob {buildJob = b}
    
    1461 1495
           | name a `elem` whitelist
    
    1462 1496
           , name b `elem` whitelist
    
    1463 1497
           , name a /= name b = error $ unlines
    
    1464 1498
             [ "both selected, can only select one job for a specific key: "
    
    1465 1499
             , show (name a)
    
    1466 1500
             , show (name b) ] -- Explicitly selected
    
    1467
    -      | name a `elem` whitelist = a -- Explicitly selected
    
    1468
    -      | name b `elem` whitelist = b
    
    1501
    +      | name a `elem` whitelist = bta -- Explicitly selected
    
    1502
    +      | name b `elem` whitelist = btb
    
    1469 1503
           | otherwise = error (show (name a) ++ show (name b))
    
    1470 1504
     
    
    1471 1505
         go = fmap (BindistInfo . unwords . fromJust . mmlookup "BIN_DIST_NAME" . jobVariables)
    

  • .gitlab/jobs.yaml The diff for this file was not included because it is too large.
  • hadrian/doc/cross-compile.md
    1
    +**This is severely outdated. And is here merely for historical interest**
    
    2
    +
    
    1 3
     ## Build a cross-compiling GHC
    
    2 4
     
    
    3 5
     In this example, our host machine is "Ubuntu 16.04.2 LTS, Linux ubuntu 4.4.0-79-generic 86_64".
    

  • hadrian/src/Base.hs
    ... ... @@ -5,6 +5,7 @@
    5 5
     {-# LANGUAGE StandaloneDeriving #-}
    
    6 6
     {-# LANGUAGE StandaloneKindSignatures #-}
    
    7 7
     {-# LANGUAGE TypeOperators #-}
    
    8
    +{-# LANGUAGE MultiWayIf #-}
    
    8 9
     
    
    9 10
     module Base (
    
    10 11
         -- * General utilities
    
    ... ... @@ -22,6 +23,7 @@ module Base (
    22 23
         module Development.Shake.Util,
    
    23 24
     
    
    24 25
         Vec(..), (&%>),
    
    26
    +    exe,
    
    25 27
     
    
    26 28
         -- * Basic data types
    
    27 29
         module Hadrian.Package,
    
    ... ... @@ -57,7 +59,7 @@ import Development.Shake hiding (unit, (&%>), (*>), Normal, cmd, cmd_)
    57 59
     #endif
    
    58 60
     import qualified Development.Shake as Shake
    
    59 61
     import Development.Shake.Classes
    
    60
    -import Development.Shake.FilePath
    
    62
    +import Development.Shake.FilePath hiding (exe)
    
    61 63
     import Development.Shake.Util
    
    62 64
     import Hadrian.Oracles.DirectoryContents
    
    63 65
     import Hadrian.Utilities
    
    ... ... @@ -67,6 +69,13 @@ import GHC.Stack ( HasCallStack )
    67 69
     
    
    68 70
     import Stage
    
    69 71
     import Way
    
    72
    +import GHC.Platform.ArchOS (ArchOS(..), Arch (..), OS (..))
    
    73
    +
    
    74
    +exe :: ArchOS -> FilePath
    
    75
    +exe arch
    
    76
    +  | ArchWasm32 <- archOS_arch arch = "wasm"
    
    77
    +  | OSMinGW32 <- archOS_OS arch = "exe"
    
    78
    +  | otherwise = ""
    
    70 79
     
    
    71 80
     -- | Hadrian lives in the 'hadrianPath' directory of the GHC tree.
    
    72 81
     hadrianPath :: FilePath
    

  • hadrian/src/Builder.hs
    ... ... @@ -15,7 +15,6 @@ import Control.Exception.Extra (Partial)
    15 15
     import qualified Data.ByteString.Lazy.Char8 as BSL
    
    16 16
     import Development.Shake.Classes
    
    17 17
     import Development.Shake.Command
    
    18
    -import Development.Shake.FilePath
    
    19 18
     import GHC.Generics
    
    20 19
     import GHC.Platform.ArchOS (ArchOS(..), Arch(..), OS(..))
    
    21 20
     import qualified Hadrian.Builder as H
    
    ... ... @@ -467,7 +466,7 @@ systemBuilderPath builder = case builder of
    467 466
     
    
    468 467
         -- Get program from a certain stage's target configuration
    
    469 468
         fromStageTC stage keyname key = do
    
    470
    -        path <- prgPath . key <$> targetStage stage
    
    469
    +        path <- prgPath . key <$> perStageTarget stage
    
    471 470
             validate keyname path
    
    472 471
     
    
    473 472
         validate keyname path = do
    
    ... ... @@ -494,7 +493,7 @@ systemBuilderPath builder = case builder of
    494 493
                 case (windowsHost, hasExtension fullPath) of
    
    495 494
                     (False, _    ) -> return path
    
    496 495
                     (True , True ) -> return $ unifyPath fullPath
    
    497
    -                (True , False) -> return $ unifyPath fullPath <.> exe
    
    496
    +                (True , False) -> return $ unifyPath fullPath <.> exe (tgtArchOs target)
    
    498 497
     
    
    499 498
         -- Without this function, on Windows we can observe a bad builder path
    
    500 499
         -- for 'autoreconf'. If the relevant system.config field is set to
    

  • hadrian/src/Context.hs
    ... ... @@ -51,7 +51,7 @@ getWay = way <$> getContext
    51 51
     
    
    52 52
     -- | Get the 'Target' configuration of the current stage
    
    53 53
     getStagedTarget :: Expr Context b Target
    
    54
    -getStagedTarget = expr . targetStage =<< getStage
    
    54
    +getStagedTarget = expr . perStageTarget =<< getStage
    
    55 55
     
    
    56 56
     -- | Path to the directory containing the final artifact in a given 'Context'.
    
    57 57
     libPath :: Context -> Action FilePath
    

  • hadrian/src/Flavour.hs
    ... ... @@ -170,7 +170,7 @@ werror = addArgs $ do
    170 170
                 -- TODO: get rid of EFF_ altogether (#14647) and make sure
    
    171 171
                 -- unregisterised backend emits clean C without needing
    
    172 172
                 -- these hacks.
    
    173
    -          , queryTargetTarget stage tgtUnregisterised ? arg "-optc-Wno-error"
    
    173
    +          , queryPerStageTargetSpec stage tgtUnregisterised ? arg "-optc-Wno-error"
    
    174 174
               ]
    
    175 175
           -- N.B. We currently don't build the boot libraries' C sources with -Werror
    
    176 176
           -- as this tends to be a portability nightmare.
    

  • hadrian/src/Hadrian/Haskell/Hash.hs
    ... ... @@ -125,7 +125,7 @@ pkgHashOracle = void $ addOracleCache $ \(PkgHashKey (stag, pkg)) -> do
    125 125
       flav <- flavour
    
    126 126
       let flavourArgs = extraArgs flav
    
    127 127
     
    
    128
    -  targetOs       <- queryTargetTarget stag queryOS
    
    128
    +  targetOs       <- queryPerStageTargetSpec stag queryOS
    
    129 129
       projectVersion <- setting ProjectVersion
    
    130 130
       let pkgHashCompilerId = "ghc-" ++ projectVersion
    
    131 131
           pkgHashPlatform = targetOs
    

  • hadrian/src/Hadrian/Package.hs
    ... ... @@ -23,7 +23,7 @@ module Hadrian.Package (
    23 23
         ) where
    
    24 24
     
    
    25 25
     import Development.Shake.Classes
    
    26
    -import Development.Shake.FilePath
    
    26
    +import Development.Shake.FilePath ((<.>))
    
    27 27
     import GHC.Generics
    
    28 28
     
    
    29 29
     import Hadrian.Utilities
    

  • hadrian/src/Oracles/Flag.hs
    ... ... @@ -77,13 +77,13 @@ getFlag = expr . flag
    77 77
     
    
    78 78
     targetRTSLinkerOnlySupportsSharedLibs :: Stage -> Action Bool
    
    79 79
     targetRTSLinkerOnlySupportsSharedLibs s =
    
    80
    -  queryTargetTarget s Toolchain.tgtRTSLinkerOnlySupportsSharedLibs
    
    80
    +  queryPerStageTargetSpec s Toolchain.tgtRTSLinkerOnlySupportsSharedLibs
    
    81 81
     
    
    82 82
     arSupportsDashL :: Stage -> Action Bool
    
    83
    -arSupportsDashL stage = Toolchain.arSupportsDashL . tgtAr <$> targetStage stage
    
    83
    +arSupportsDashL stage = Toolchain.arSupportsDashL . tgtAr <$> perStageTarget stage
    
    84 84
     
    
    85 85
     arSupportsAtFile :: Stage -> Action Bool
    
    86
    -arSupportsAtFile stage = Toolchain.arSupportsAtFile . tgtAr <$> targetStage stage
    
    86
    +arSupportsAtFile stage = Toolchain.arSupportsAtFile . tgtAr <$> perStageTarget stage
    
    87 87
     
    
    88 88
     targetSupportsSharedLibs :: Stage -> Action Bool
    
    89 89
     targetSupportsSharedLibs stage = do
    
    ... ... @@ -101,10 +101,10 @@ targetSupportsThreadedRts stage = do
    101 101
     
    
    102 102
     -- | Does the target support the -N RTS flag?
    
    103 103
     targetSupportsSMP :: Stage -> Action Bool
    
    104
    -targetSupportsSMP stage = queryTargetTarget stage Toolchain.tgtSupportsSMP
    
    104
    +targetSupportsSMP stage = queryPerStageTargetSpec stage Toolchain.tgtSupportsSMP
    
    105 105
     
    
    106 106
     targetUseLibffiForAdjustors :: Stage -> Action Bool
    
    107
    -targetUseLibffiForAdjustors stage = queryTargetTarget stage tgtUseLibffiForAdjustors
    
    107
    +targetUseLibffiForAdjustors stage = queryPerStageTargetSpec stage tgtUseLibffiForAdjustors
    
    108 108
     
    
    109 109
     useLibdw :: Stage -> Action Bool
    
    110
    -useLibdw stage = queryTargetTarget stage (isJust . tgtRTSWithLibdw)
    110
    +useLibdw stage = queryPerStageTargetSpec stage (isJust . tgtRTSWithLibdw)

  • hadrian/src/Oracles/Setting.hs
    ... ... @@ -6,7 +6,7 @@ module Oracles.Setting (
    6 6
     
    
    7 7
         -- * Helpers
    
    8 8
         ghcCanonVersion, cmdLineLengthLimit, targetSupportsRPaths, topDirectory,
    
    9
    -    libsuf, ghcVersionStage, shPath, targetStage, crossStage, queryTarget, queryTargetTarget,
    
    9
    +    libsuf, ghcVersionStage, shPath, perStageTarget, crossStage, queryTarget, queryPerStageTargetSpec,
    
    10 10
         isHostStage,
    
    11 11
     
    
    12 12
         -- ** Target platform things
    
    ... ... @@ -152,7 +152,7 @@ isOsxTarget :: Stage -> Action Bool
    152 152
     isOsxTarget stage = anyTargetOs stage [OSDarwin]
    
    153 153
     
    
    154 154
     isArmTarget :: Stage -> Action Bool
    
    155
    -isArmTarget stage = queryTargetTarget stage (isARM . archOS_arch . tgtArchOs)
    
    155
    +isArmTarget stage = queryPerStageTargetSpec stage (isARM . archOS_arch . tgtArchOs)
    
    156 156
     
    
    157 157
     -- | Check whether the host OS setting matches one of the given strings.
    
    158 158
     anyHostOs :: [OS] -> Action Bool
    
    ... ... @@ -161,15 +161,15 @@ anyHostOs oss = (`elem` oss) <$> queryHostTarget (archOS_OS . tgtArchOs)
    161 161
     -- | Check whether the target architecture setting matches one of the given
    
    162 162
     -- strings.
    
    163 163
     anyTargetArch :: Stage -> [Arch] -> Action Bool
    
    164
    -anyTargetArch stage archs = (`elem` archs) <$> queryTargetTarget stage (archOS_arch . tgtArchOs)
    
    164
    +anyTargetArch stage archs = (`elem` archs) <$> queryPerStageTargetSpec stage (archOS_arch . tgtArchOs)
    
    165 165
     
    
    166 166
     -- | Check whether the target OS setting matches one of the given strings.
    
    167 167
     anyTargetOs :: Stage -> [OS] -> Action Bool
    
    168
    -anyTargetOs stage oss = (`elem` oss) <$> queryTargetTarget stage (archOS_OS . tgtArchOs)
    
    168
    +anyTargetOs stage oss = (`elem` oss) <$> queryPerStageTargetSpec stage (archOS_OS . tgtArchOs)
    
    169 169
     
    
    170 170
     -- | Check whether the target OS uses the ELF object format.
    
    171 171
     isElfTarget :: Stage -> Action Bool
    
    172
    -isElfTarget stage = queryTargetTarget stage (osElfTarget . archOS_OS . tgtArchOs)
    
    172
    +isElfTarget stage = queryPerStageTargetSpec stage (osElfTarget . archOS_OS . tgtArchOs)
    
    173 173
     
    
    174 174
     -- | Check whether the target OS supports the @-rpath@ linker option when
    
    175 175
     -- using dynamic linking.
    
    ... ... @@ -179,7 +179,7 @@ isElfTarget stage = queryTargetTarget stage (osElfTarget . archOS_OS . tgtArchOs
    179 179
     -- TODO: Windows supports lazy binding (but GHC doesn't currently support
    
    180 180
     --       dynamic way on Windows anyways).
    
    181 181
     targetSupportsRPaths :: Stage -> Action Bool
    
    182
    -targetSupportsRPaths stage = queryTargetTarget stage
    
    182
    +targetSupportsRPaths stage = queryPerStageTargetSpec stage
    
    183 183
                                     (\t -> let os = archOS_OS (tgtArchOs t)
    
    184 184
                                            in osElfTarget os || osMachOTarget os)
    
    185 185
     
    
    ... ... @@ -187,7 +187,7 @@ targetSupportsRPaths stage = queryTargetTarget stage
    187 187
     -- ARM)?
    
    188 188
     targetArmVersion :: Stage -> Action (Maybe ArmISA)
    
    189 189
     targetArmVersion stage = runMaybeT $ do
    
    190
    -    ArchARM isa _ _ <- lift $ queryTargetTarget stage (archOS_arch . tgtArchOs)
    
    190
    +    ArchARM isa _ _ <- lift $ queryPerStageTargetSpec stage (archOS_arch . tgtArchOs)
    
    191 191
         return isa
    
    192 192
     
    
    193 193
     -- | Canonicalised GHC version number, used for integer version comparisons. We
    
    ... ... @@ -231,33 +231,34 @@ libsuf st way
    231 231
             let suffix = waySuffix (removeWayUnit Dynamic way)
    
    232 232
             return (suffix ++ "-ghc" ++ version ++ extension)
    
    233 233
     
    
    234
    --- | Build libraries for this `Stage` targetting this `Target`
    
    234
    +-- | Determine the 'Target' that this 'Stage' is supposed to build libraries for.
    
    235 235
     --
    
    236
    --- For example, we want to build RTS with stage1 for the host target as we
    
    236
    +-- For example, we want to build RTS with stage1 for the host as we
    
    237 237
     -- produce a host executable with stage1 (which cross-compiles to stage2).
    
    238
    -targetStage :: Stage -> Action Target
    
    239
    -targetStage Stage0 {} = getHostTarget
    
    240
    -targetStage stage | isHostStage stage = do
    
    238
    +perStageTarget :: Stage -> Action Target
    
    239
    +perStageTarget Stage0 {} = getHostTarget
    
    240
    +perStageTarget stage | isHostStage stage = do
    
    241 241
        ht <- getHostTarget
    
    242 242
        tt <- getTargetTarget
    
    243 243
        if targetPlatformTriple ht == targetPlatformTriple tt
    
    244 244
          then return tt
    
    245 245
          else return ht
    
    246
    -targetStage _ = getTargetTarget
    
    246
    +perStageTarget _ = getTargetTarget
    
    247 247
     
    
    248 248
     isHostStage :: Stage -> Bool
    
    249 249
     isHostStage stage | stage <= Stage1 = True
    
    250 250
     isHostStage _ = False
    
    251 251
     
    
    252
    -queryTarget :: Stage -> (Target -> a) -> (Expr c b a)
    
    253
    -queryTarget s f = expr (f <$> targetStage s)
    
    252
    +queryTarget :: Stage -> (Target -> a) -> Expr c b a
    
    253
    +queryTarget s f = expr (f <$> perStageTarget s)
    
    254 254
     
    
    255
    -queryTargetTarget :: Stage -> (Target -> a) -> Action a
    
    256
    -queryTargetTarget s f = f <$> targetStage s
    
    255
    +-- | get the conentents of the .target file for the specified stage
    
    256
    +queryPerStageTargetSpec :: Stage -> (Target -> a) -> Action a
    
    257
    +queryPerStageTargetSpec s f = f <$> perStageTarget s
    
    257 258
     
    
    258 259
     -- | A 'Stage' is a cross-stage if the produced compiler is a cross-compiler.
    
    259 260
     crossStage :: Stage -> Action Bool
    
    260 261
     crossStage st = do
    
    261
    -  st_target <- targetStage (succStage st)
    
    262
    -  st_host   <- targetStage st
    
    262
    +  st_target <- perStageTarget (succStage st)
    
    263
    +  st_host   <- perStageTarget st
    
    263 264
       return (targetPlatformTriple st_target /= targetPlatformTriple st_host)

  • hadrian/src/Oracles/TestSettings.hs
    ... ... @@ -13,6 +13,7 @@ import Hadrian.Oracles.TextFile
    13 13
     import Oracles.Setting (topDirectory, setting, ProjectSetting(..), crossStage)
    
    14 14
     import Packages
    
    15 15
     import Settings.Program (programContext)
    
    16
    +import GHC.Toolchain (Target(tgtArchOs))
    
    16 17
     
    
    17 18
     testConfigFile :: Action FilePath
    
    18 19
     testConfigFile = buildRoot <&> (-/- "test/ghcconfig")
    
    ... ... @@ -153,7 +154,8 @@ getTestExePath testGhc pkg = do
    153 154
          bindir <- getBinaryDirectory testGhc
    
    154 155
          compiler_path <- getCompilerPath testGhc
    
    155 156
          cross <- getBooleanSetting TestCrossCompiling
    
    157
    +     tgt <- getHostTarget -- FIXME: is this right -- ask rodrigo about the targettarget and query/get versions of this function
    
    156 158
          let cross_prefix = if cross then dropWhileEnd ((/=) '-') (takeFileName compiler_path) else ""
    
    157 159
          -- get relative path for the given program in the given stage
    
    158
    -     liftIO $ makeAbsolute (bindir </> (cross_prefix ++ programBasename pkg) <.> exe)
    
    160
    +     liftIO $ makeAbsolute (bindir </> (cross_prefix ++ programBasename pkg) <.> exe (tgtArchOs tgt))
    
    159 161
         -- get relative path for the given program in the given stage

  • hadrian/src/Packages.hs
    ... ... @@ -24,6 +24,8 @@ import Hadrian.Utilities
    24 24
     import Base
    
    25 25
     import Context.Type
    
    26 26
     import Oracles.Setting
    
    27
    +import GHC.Toolchain (tgtArchOs)
    
    28
    +import qualified Development.Shake.FilePath as Shake
    
    27 29
     
    
    28 30
     -- | These are all GHC packages we know about. Build rules will be generated for
    
    29 31
     -- all of them. However, not all of these packages will be built. For example,
    
    ... ... @@ -196,12 +198,13 @@ programPath :: Context -> Action FilePath
    196 198
     programPath context@Context {..} = do
    
    197 199
         name <- programName context
    
    198 200
         path <- stageBinPath stage
    
    199
    -    return $ path -/- name <.> exe
    
    201
    +    arch <- queryPerStageTargetSpec stage tgtArchOs
    
    202
    +    return $ path -/- name <.> exe arch
    
    200 203
     
    
    201 204
     -- TODO: Move @timeout@ to the @util@ directory and build in a more standard
    
    202 205
     -- location like other programs used only by the testsuite.
    
    203 206
     timeoutPath :: FilePath
    
    204
    -timeoutPath = "testsuite/timeout/install-inplace/bin/timeout" <.> exe
    
    207
    +timeoutPath = "testsuite/timeout/install-inplace/bin/timeout" <.> Shake.exe
    
    205 208
     
    
    206 209
     -- TODO: Can we extract this information from Cabal files?
    
    207 210
     -- | Some program packages should not be linked with Haskell main function.
    

  • hadrian/src/Rules/Generate.hs
    ... ... @@ -277,7 +277,7 @@ generateRules = do
    277 277
                           else prefix
    
    278 278
                     relPkgDb = makeRelativeNoSysLink libTopDir pkgDb
    
    279 279
                 go (generateSettings libStage out True relPkgDb) out
    
    280
    -        (prefix -/- "targets" -/- "default.target") %> \out -> go (show <$> expr (targetStage (succStage stage))) out
    
    280
    +        (prefix -/- "targets" -/- "default.target") %> \out -> go (show <$> expr (perStageTarget (succStage stage))) out
    
    281 281
     
    
    282 282
       where
    
    283 283
         file <~+ gen = file %> \out -> generate out emptyTarget gen >> makeExecutable out
    
    ... ... @@ -450,7 +450,7 @@ bindistRules = do
    450 450
         , interpolateVar "TargetWordBigEndian" $ getTarget isBigEndian
    
    451 451
         , interpolateVar "TargetWordSize" $ getTarget wordSize
    
    452 452
         , interpolateVar "Unregisterised" $ yesNo <$> getTarget tgtUnregisterised
    
    453
    -    , interpolateVar "UseLibdw" $ fmap yesNo $ interp $ staged (fmap (isJust . tgtRTSWithLibdw) . targetStage)
    
    453
    +    , interpolateVar "UseLibdw" $ fmap yesNo $ interp $ staged (fmap (isJust . tgtRTSWithLibdw) . perStageTarget)
    
    454 454
         , interpolateVar "UseLibffiForAdjustors" $ yesNo <$> getTarget tgtUseLibffiForAdjustors
    
    455 455
         , interpolateVar "BaseUnitId" $ bindistUnitId base
    
    456 456
         , interpolateVar "GhcUnitId" $ bindistUnitId compiler
    
    ... ... @@ -546,7 +546,7 @@ generateConfigHs :: Expr String
    546 546
     generateConfigHs = do
    
    547 547
         stage <- getStage
    
    548 548
         let chooseSetting x y = case stage of { Stage0 {} -> x; _ -> y }
    
    549
    -    let queryTarget f = f <$> expr (targetStage stage)
    
    549
    +    let queryTarget f = f <$> expr (perStageTarget stage)
    
    550 550
         -- Not right for stage3
    
    551 551
         buildPlatform <- chooseSetting (queryBuild targetPlatformTriple) (queryHost targetPlatformTriple)
    
    552 552
         hostPlatform <- queryTarget targetPlatformTriple
    

  • hadrian/src/Rules/Program.hs
    ... ... @@ -9,7 +9,7 @@ import Base
    9 9
     import Context
    
    10 10
     import Expression hiding (stage, way)
    
    11 11
     import Oracles.ModuleFiles
    
    12
    -import Oracles.Setting (topDirectory)
    
    12
    +import Oracles.Setting (topDirectory, perStageTarget)
    
    13 13
     import Packages
    
    14 14
     import Settings
    
    15 15
     import Settings.Default
    
    ... ... @@ -18,6 +18,7 @@ import Target
    18 18
     import Utilities
    
    19 19
     import Rules.Library
    
    20 20
     import Rules.Register
    
    21
    +import GHC.Toolchain (Target(tgtArchOs))
    
    21 22
     
    
    22 23
     -- | TODO: Drop code duplication
    
    23 24
     buildProgramRules :: [(Resource, Int)] -> Rules ()
    
    ... ... @@ -49,13 +50,14 @@ getProgramContexts stage = do
    49 50
       -- 'Rules', because it is an 'Action' depending on an oracle.
    
    50 51
       sPackages <- filter isProgram <$> stagePackages stage
    
    51 52
       tPackages <- testsuitePackages
    
    53
    +  tgt <- perStageTarget stage
    
    52 54
       -- TODO: Shall we use Stage2 for testsuite packages instead?
    
    53 55
       let allPackages = sPackages
    
    54 56
                      ++ tPackages
    
    55 57
       forM allPackages $ \pkg -> do
    
    56 58
         ctx <- programContext stage pkg -- TODO: see todo on programContext.
    
    57 59
         name <- programName ctx
    
    58
    -    return (name <.> exe, ctx)
    
    60
    +    return (name <.> exe (tgtArchOs tgt), ctx)
    
    59 61
     
    
    60 62
     lookupProgramContext :: FilePath -> [(FilePath, Context)] -> Maybe Context
    
    61 63
     lookupProgramContext wholePath progs = lookup (takeFileName wholePath) progs
    

  • hadrian/src/Rules/Test.hs
    1
    +{-# LANGUAGE OverloadedRecordDot #-}
    
    1 2
     {-# OPTIONS_GHC -Wno-unused-top-binds #-}
    
    2 3
     module Rules.Test (testRules) where
    
    3 4
     
    
    ... ... @@ -20,58 +21,71 @@ import qualified System.Directory as IO
    20 21
     
    
    21 22
     import GHC.Toolchain as Toolchain
    
    22 23
     import GHC.Toolchain.Program as Toolchain
    
    24
    +import Hadrian.Oracles.TextFile (getHostTarget, getTargetTarget)
    
    25
    +import GHC.Platform.ArchOS (ArchOS (..), Arch (..), OS (..))
    
    23 26
     
    
    24
    -checkPprProgPath, checkPprSourcePath :: FilePath
    
    25
    -checkPprProgPath = "test/bin/check-ppr" <.> exe
    
    27
    +checkPprProgPath :: ArchOS -> FilePath
    
    28
    +checkPprProgPath archos = "test/bin/check-ppr" <.> exe archos
    
    29
    +checkPprSourcePath :: FilePath
    
    26 30
     checkPprSourcePath = "utils/check-ppr/Main.hs"
    
    27 31
     checkPprExtra :: [String]
    
    28 32
     checkPprExtra = []
    
    29 33
     
    
    30
    -checkExactProgPath, checkExactSourcePath :: FilePath
    
    31
    -checkExactProgPath = "test/bin/check-exact" <.> exe
    
    34
    +checkExactProgPath :: ArchOS -> FilePath
    
    35
    +checkExactProgPath archos = "test/bin/check-exact" <.> exe archos
    
    36
    +checkExactSourcePath :: FilePath
    
    32 37
     checkExactSourcePath = "utils/check-exact/Main.hs"
    
    33 38
     checkExactExtra :: [String]
    
    34 39
     checkExactExtra = ["-iutils/check-exact"]
    
    35 40
     
    
    36
    -countDepsProgPath, countDepsSourcePath :: FilePath
    
    37
    -countDepsProgPath = "test/bin/count-deps" <.> exe
    
    41
    +countDepsProgPath :: ArchOS -> FilePath
    
    42
    +countDepsProgPath archos = "test/bin/count-deps" <.> exe archos
    
    43
    +countDepsSourcePath :: FilePath
    
    38 44
     countDepsSourcePath = "utils/count-deps/Main.hs"
    
    39 45
     countDepsExtra :: [String]
    
    40 46
     countDepsExtra = ["-iutils/count-deps"]
    
    41 47
     
    
    42
    -dumpDeclsProgPath, dumpDeclsSourcePath :: FilePath
    
    43
    -dumpDeclsProgPath = "test/bin/dump-decls" <.> exe
    
    48
    +dumpDeclsProgPath :: ArchOS -> FilePath
    
    49
    +dumpDeclsProgPath archos = "test/bin/dump-decls" <.> exe archos
    
    50
    +dumpDeclsSourcePath :: FilePath
    
    44 51
     dumpDeclsSourcePath = "utils/dump-decls/Main.hs"
    
    45 52
     dumpDeclsExtra :: [String]
    
    46 53
     dumpDeclsExtra = []
    
    47 54
     
    
    48
    -noteLinterProgPath, noteLinterSourcePath :: FilePath
    
    49
    -noteLinterProgPath = "test/bin/lint-notes" <.> exe
    
    55
    +noteLinterProgPath :: ArchOS -> FilePath
    
    56
    +noteLinterProgPath archos = "test/bin/lint-notes" <.> exe archos
    
    57
    +noteLinterSourcePath :: FilePath
    
    50 58
     noteLinterSourcePath = "linters/lint-notes/Main.hs"
    
    51 59
     noteLinterExtra :: [String]
    
    52 60
     noteLinterExtra = ["-ilinters/lint-notes"]
    
    53 61
     
    
    54
    -codeLinterProgPath, codeLinterSourcePath :: FilePath
    
    55
    -codeLinterProgPath = "test/bin/lint-codes" <.> exe
    
    62
    +codeLinterProgPath :: ArchOS -> FilePath
    
    63
    +codeLinterProgPath archos = "test/bin/lint-codes" <.> exe archos
    
    64
    +codeLinterSourcePath :: FilePath
    
    56 65
     codeLinterSourcePath = "linters/lint-codes/Main.hs"
    
    57 66
     codeLinterExtra :: [String]
    
    58 67
     codeLinterExtra = ["-ilinters/lint-codes"]
    
    59 68
     
    
    60
    -whitespaceLinterProgPath, whitespaceLinterSourcePath :: FilePath
    
    61
    -whitespaceLinterProgPath = "test/bin/lint-whitespace" <.> exe
    
    69
    +whitespaceLinterProgPath :: ArchOS -> FilePath
    
    70
    +whitespaceLinterProgPath archos = "test/bin/lint-whitespace" <.> exe archos
    
    71
    +whitespaceLinterSourcePath :: FilePath
    
    62 72
     whitespaceLinterSourcePath = "linters/lint-whitespace/Main.hs"
    
    63 73
     whitespaceLinterExtra :: [String]
    
    64 74
     whitespaceLinterExtra = ["-ilinters/lint-whitespace", "-ilinters/linters-common"]
    
    65 75
     
    
    66
    -changelogDProgPath, changelogDSourcePath :: FilePath
    
    67
    -changelogDProgPath = "test/bin/changelog-d" <.> exe
    
    76
    +changelogDProgPath :: ArchOS -> FilePath
    
    77
    +changelogDProgPath archos = "test/bin/changelog-d" <.> exe archos
    
    78
    +changelogDSourcePath :: FilePath
    
    68 79
     changelogDSourcePath = "utils/changelog-d/ChangelogD.hs"
    
    69 80
     changelogDExtra :: [String]
    
    70 81
     changelogDExtra = ["-iutils/changelog-d"]
    
    71 82
     
    
    72 83
     data CheckProgram =
    
    73 84
             CheckProgram { cp_target :: String -- ^ Name for the hadrian target
    
    74
    -                     , cp_exe_path :: FilePath -- ^ Path to resulting executable
    
    85
    +                     , cp_exe_path :: ArchOS -> FilePattern
    
    86
    +                        -- ^ Path to resulting executable.
    
    87
    +                        -- This depends on the taret the program is built for,
    
    88
    +                        -- not the host that hadrian is built on
    
    75 89
                          , cp_src_path :: FilePath -- ^ Source to the Main.hs for the executable
    
    76 90
                          , cp_extra_args :: [String] -- ^ Any extra arguments to use when compiling Main.hs
    
    77 91
                          , cp_hadrian_pkg :: Package -- ^ How to build the executable when using in-tree compiler.
    
    ... ... @@ -81,16 +95,16 @@ data CheckProgram =
    81 95
     
    
    82 96
     checkPrograms :: [CheckProgram]
    
    83 97
     checkPrograms =
    
    84
    -    [ CheckProgram "test:check-ppr" checkPprProgPath checkPprSourcePath checkPprExtra checkPpr id id
    
    85
    -    , CheckProgram "test:check-exact" checkExactProgPath checkExactSourcePath checkExactExtra checkExact id id
    
    86
    -    , CheckProgram "test:count-deps" countDepsProgPath countDepsSourcePath countDepsExtra countDeps id id
    
    87
    -    , CheckProgram "test:dump-decls" dumpDeclsProgPath dumpDeclsSourcePath dumpDeclsExtra dumpDecls id id
    
    88
    -    , CheckProgram "lint:notes" noteLinterProgPath  noteLinterSourcePath  noteLinterExtra  lintNotes  (const stage0Boot)  id
    
    89
    -    , CheckProgram "lint:codes" codeLinterProgPath  codeLinterSourcePath  codeLinterExtra  lintCodes  id id
    
    90
    -    , CheckProgram "lint:whitespace"  whitespaceLinterProgPath  whitespaceLinterSourcePath  whitespaceLinterExtra  lintWhitespace  (const stage0Boot)  (filter (/= lintersCommon))
    
    98
    +    [ CheckProgram { cp_target = "test:check-ppr", cp_exe_path = checkPprProgPath, cp_src_path = checkPprSourcePath, cp_extra_args = checkPprExtra, cp_hadrian_pkg = checkPpr, cp_modify_stage = id, cp_modify_deps = id }
    
    99
    +    , CheckProgram { cp_target = "test:check-exact", cp_exe_path = checkExactProgPath, cp_src_path = checkExactSourcePath, cp_extra_args = checkExactExtra, cp_hadrian_pkg = checkExact, cp_modify_stage = id, cp_modify_deps = id }
    
    100
    +    , CheckProgram { cp_target = "test:count-deps", cp_exe_path = countDepsProgPath, cp_src_path = countDepsSourcePath, cp_extra_args = countDepsExtra, cp_hadrian_pkg = countDeps, cp_modify_stage = id, cp_modify_deps = id }
    
    101
    +    , CheckProgram { cp_target = "test:dump-decls", cp_exe_path = dumpDeclsProgPath, cp_src_path = dumpDeclsSourcePath, cp_extra_args = dumpDeclsExtra, cp_hadrian_pkg = dumpDecls, cp_modify_stage = id, cp_modify_deps = id }
    
    102
    +    , CheckProgram { cp_target = "lint:notes", cp_exe_path = noteLinterProgPath, cp_src_path = noteLinterSourcePath, cp_extra_args = noteLinterExtra, cp_hadrian_pkg = lintNotes, cp_modify_stage = (const stage0Boot), cp_modify_deps = id }
    
    103
    +    , CheckProgram { cp_target = "lint:codes", cp_exe_path = codeLinterProgPath, cp_src_path = codeLinterSourcePath, cp_extra_args = codeLinterExtra, cp_hadrian_pkg = lintCodes, cp_modify_stage = id, cp_modify_deps = id }
    
    104
    +    , CheckProgram { cp_target = "lint:whitespace", cp_exe_path = whitespaceLinterProgPath, cp_src_path = whitespaceLinterSourcePath, cp_extra_args = whitespaceLinterExtra, cp_hadrian_pkg = lintWhitespace, cp_modify_stage = (const stage0Boot), cp_modify_deps = (filter (/= lintersCommon)) }
    
    91 105
         -- N.B. The lint:changelog build is replicated by lint_changelog in
    
    92 106
         -- .gitlab/ci.sh. Keep its package dependencies in sync with this target.
    
    93
    -    , CheckProgram "lint:changelog"  changelogDProgPath  changelogDSourcePath  changelogDExtra  changelogD  (const stage0Boot)  id
    
    107
    +    , CheckProgram { cp_target = "lint:changelog", cp_exe_path = changelogDProgPath, cp_src_path = changelogDSourcePath, cp_extra_args = changelogDExtra, cp_hadrian_pkg = changelogD, cp_modify_stage = (const stage0Boot), cp_modify_deps = id }
    
    94 108
         ]
    
    95 109
     
    
    96 110
     inTreeOutTree :: (Stage -> Action b) -> Action b -> Action b
    
    ... ... @@ -134,12 +148,23 @@ testRules = do
    134 148
     
    
    135 149
         testsuiteDeps
    
    136 150
     
    
    151
    +    -- the test targets will all be compiled by the test comppiler which is going
    
    152
    +    -- to produce artifacts for its target
    
    153
    +
    
    137 154
         -- Rules for building check-ppr, check-exact and
    
    138 155
         -- check-ppr-annotations with the compiler we are going to test
    
    139 156
         -- (in-tree or out-of-tree).
    
    140
    -    forM_ checkPrograms $ \(CheckProgram name progPath sourcePath mextra progPkg mod_stage mod_pkgs) -> do
    
    141
    -        name ~> need [root -/- progPath]
    
    142
    -        root -/- progPath %> \path -> do
    
    157
    +    forM_ checkPrograms $ \(CheckProgram name progPathForArch sourcePath mextra progPkg mod_stage mod_pkgs) -> do
    
    158
    +        name ~> do
    
    159
    +          tt <- getTargetTarget
    
    160
    +          need [root -/- progPathForArch (tgtArchOs tt)]
    
    161
    +
    
    162
    +        -- HACK: we don't have a program path here and just a pattern
    
    163
    +        -- because we can't query the target before declaring the rule.
    
    164
    +        -- we specify target arch linux (no extension), then append a pattern
    
    165
    +        -- for any extension
    
    166
    +        let filePat = progPathForArch ArchOS { archOS_arch = ArchUnknown, archOS_OS = OSLinux } <> "*"
    
    167
    +        root -/- filePat %> \path -> do
    
    143 168
                 need [ sourcePath ]
    
    144 169
                 testGhc <- testCompiler <$> userSetting defaultTestArgs
    
    145 170
     
    
    ... ... @@ -158,8 +183,14 @@ testRules = do
    158 183
                     depsPkgs <- mod_pkgs . packageDependencies <$> readPackageData progPkg
    
    159 184
                     bindir <- getBinaryDirectory testGhc
    
    160 185
                     test_args <- outOfTreeCompilerArgs
    
    186
    +                ht <- getHostTarget
    
    187
    +                tt <- getTargetTarget
    
    188
    +                targetPlatform <- setting TargetPlatformFull
    
    189
    +                let mkGhcProg prog
    
    190
    +                     | targetPlatformTriple ht /= targetPlatformTriple tt = targetPlatform ++ "-" ++ prog
    
    191
    +                     | otherwise = prog
    
    161 192
                     let dynPrograms = hasDynamic test_args
    
    162
    -                ghcProg <- exeSpawnPath (bindir </> "ghc" <.> exe)
    
    193
    +                ghcProg <- exeSpawnPath (bindir </> mkGhcProg "ghc" <.> exe (tgtArchOs ht)) -- FIXME: needs proper prefix!
    
    163 194
                     cmdExe ghcProg $
    
    164 195
                         concatMap (\p -> ["-package", pkgName p]) depsPkgs ++
    
    165 196
                         ["-o", top -/- path, top -/- sourcePath] ++
    
    ... ... @@ -237,8 +268,12 @@ testEnv stg = do
    237 268
         top             <- topDirectory
    
    238 269
         pythonPath      <- builderPath Python
    
    239 270
         -- MP: TODO wrong, should use the ccPath and ccFlags from the bindist we are testing.
    
    240
    -    ccPath          <- queryTargetTarget stg (Toolchain.prgPath . Toolchain.ccProgram . Toolchain.tgtCCompiler)
    
    241
    -    ccFlags         <- queryTargetTarget stg (unwords . Toolchain.prgFlags . Toolchain.ccProgram . Toolchain.tgtCCompiler)
    
    271
    +    tgt <- queryPerStageTargetSpec stg id
    
    272
    +    let ccPath = tgt.tgtCCompiler.ccProgram.prgPath
    
    273
    +    let ccFlags = unwords tgt.tgtCCompiler.ccProgram.prgFlags
    
    274
    +    let archos = tgt.tgtArchOs
    
    275
    +    let mkProgPath k = top -/- root -/- k archos
    
    276
    +
    
    242 277
         ghcFlags        <- runTestGhcFlags stg
    
    243 278
         let ghciFlags = ghcFlags ++ unwords
    
    244 279
               [ "--interactive", "-v0", "-ignore-dot-ghci"
    
    ... ... @@ -256,14 +291,14 @@ testEnv stg = do
    256 291
           , "TEST_HC_OPTS_INTERACTIVE" .= ghciFlags
    
    257 292
           , "TEST_CC" .= ccPath
    
    258 293
           , "TEST_CC_OPTS" .= ccFlags
    
    259
    -      , "CHECK_PPR" .= (top -/- root -/- checkPprProgPath)
    
    260
    -      , "CHECK_EXACT" .= (top -/- root -/- checkExactProgPath)
    
    261
    -      , "DUMP_DECLS" .= (top -/- root -/- dumpDeclsProgPath)
    
    262
    -      , "COUNT_DEPS" .= (top -/- root -/- countDepsProgPath)
    
    263
    -      , "LINT_NOTES" .= (top -/- root -/- noteLinterProgPath)
    
    264
    -      , "LINT_CODES" .= (top -/- root -/- codeLinterProgPath)
    
    265
    -      , "LINT_WHITESPACE" .= (top -/- root -/- whitespaceLinterProgPath)
    
    266
    -      , "CHANGELOG_D" .= (top -/- root -/- changelogDProgPath)
    
    294
    +      , "CHECK_PPR" .= mkProgPath checkPprProgPath
    
    295
    +      , "CHECK_EXACT" .= mkProgPath checkExactProgPath
    
    296
    +      , "DUMP_DECLS" .= mkProgPath dumpDeclsProgPath
    
    297
    +      , "COUNT_DEPS" .= mkProgPath countDepsProgPath
    
    298
    +      , "LINT_NOTES" .= mkProgPath noteLinterProgPath
    
    299
    +      , "LINT_CODES" .= mkProgPath codeLinterProgPath
    
    300
    +      , "LINT_WHITESPACE" .= mkProgPath whitespaceLinterProgPath
    
    301
    +      , "CHANGELOG_D" .= mkProgPath changelogDProgPath
    
    267 302
           -- This lets us bypass the need to generate a config
    
    268 303
           -- through Make, which happens in testsuite/mk/boilerplate.mk
    
    269 304
           -- which is in turn included by all test 'Makefile's.
    
    ... ... @@ -301,12 +336,13 @@ absolutePathStage s p =
    301 336
     -- We can always build a target with an intree compiler But we can only build
    
    302 337
     -- targets with special support (checkPrograms) with arbitrary compilers.
    
    303 338
     --
    
    304
    --- We need to build the dependencies if --test-have-intree-files is set.
    
    305
    --- We should have built them already by this point, but
    
    339
    +-- If @--test-have-intree-files@ is set, we would be build all dependencies of
    
    340
    +-- 'isOkToBuild' targets. However, this flag doesn't mean that we have a
    
    341
    +-- /_build/ directory available., so we mustn't add it as one of the sufficient
    
    342
    +-- conditions.
    
    306 343
     isOkToBuild :: TestArgs -> String -> Bool
    
    307 344
     isOkToBuild args target
    
    308 345
        = isInTreeCompiler (testCompiler args)
    
    309
    -  || testHasInTreeFiles args
    
    310 346
       || target `elem` map cp_target checkPrograms
    
    311 347
     
    
    312 348
     -- | Build the timeout program.
    

  • hadrian/src/Settings/Builders/DeriveConstants.hs
    ... ... @@ -42,8 +42,8 @@ includeCcArgs = do
    42 42
         stage <- getStage
    
    43 43
         rtsPath <- expr $ rtsBuildPath stage
    
    44 44
         mconcat [ cWarnings
    
    45
    -            , prgFlags . ccProgram . tgtCCompiler <$> expr (targetStage stage)
    
    46
    -            , queryTargetTarget stage tgtUnregisterised ? arg "-DUSE_MINIINTERPRETER"
    
    45
    +            , prgFlags . ccProgram . tgtCCompiler <$> expr (perStageTarget stage)
    
    46
    +            , queryPerStageTargetSpec stage tgtUnregisterised ? arg "-DUSE_MINIINTERPRETER"
    
    47 47
                 , arg "-Irts"
    
    48 48
                 , arg "-Irts/include"
    
    49 49
                 , arg $ "-I" ++ rtsPath </> "include"
    

  • hadrian/src/Settings/Builders/RunTest.hs
    1 1
     {-# LANGUAGE TypeApplications #-}
    
    2
    +{-# LANGUAGE NamedFieldPuns #-}
    
    2 3
     module Settings.Builders.RunTest (runTestBuilderArgs
    
    3 4
                                      , runTestGhcFlags
    
    4 5
                                      , assertSameCompilerArgs
    
    ... ... @@ -27,7 +28,7 @@ import GHC.Toolchain.Target
    27 28
     -- | Extra flags to send to the Haskell compiler to run tests.
    
    28 29
     runTestGhcFlags :: Stage -> Action String
    
    29 30
     runTestGhcFlags stage = do
    
    30
    -    unregisterised <- queryTargetTarget stage tgtUnregisterised
    
    31
    +    unregisterised <- queryPerStageTargetSpec stage tgtUnregisterised
    
    31 32
     
    
    32 33
         let ifMinGhcVer ver opt = do v <- ghcCanonVersion
    
    33 34
                                      if ver <= v then pure opt
    
    ... ... @@ -112,10 +113,10 @@ inTreeCompilerArgs stg = do
    112 113
           ways <- interpretInContext (vanillaContext ghcStage rts) getRtsWays
    
    113 114
           return (dynamic `elem` ways, threaded `elem` ways)
    
    114 115
         hasDynamic          <- (wayUnit Dynamic) . Context.Type.way <$> (programContext stg ghc)
    
    115
    -    leadingUnderscore   <- queryTargetTarget ghcStage tgtSymbolsHaveLeadingUnderscore
    
    116
    +    leadingUnderscore   <- queryPerStageTargetSpec ghcStage tgtSymbolsHaveLeadingUnderscore
    
    116 117
         withInterpreter     <- ghcWithInterpreter ghcStage
    
    117
    -    unregisterised      <- queryTargetTarget ghcStage tgtUnregisterised
    
    118
    -    tables_next_to_code <- queryTargetTarget ghcStage tgtTablesNextToCode
    
    118
    +    unregisterised      <- queryPerStageTargetSpec ghcStage tgtUnregisterised
    
    119
    +    tables_next_to_code <- queryPerStageTargetSpec ghcStage tgtTablesNextToCode
    
    119 120
         targetWithSMP       <- targetSupportsSMP ghcStage
    
    120 121
         interpForceDyn      <- targetRTSLinkerOnlySupportsSharedLibs ghcStage
    
    121 122
     
    
    ... ... @@ -124,17 +125,17 @@ inTreeCompilerArgs stg = do
    124 125
         profiled            <- ghcProfiled        <$> flavour <*> pure ghcStage
    
    125 126
     
    
    126 127
         os          <- queryHostTarget queryOS
    
    127
    -    arch        <- queryTargetTarget ghcStage queryArch
    
    128
    +    arch        <- queryPerStageTargetSpec ghcStage queryArch
    
    128 129
         let codegen_arches = ["x86_64", "i386", "powerpc", "powerpc64", "powerpc64le", "aarch64", "wasm32", "riscv64", "loongarch64"]
    
    129 130
         let withNativeCodeGen
    
    130 131
               | unregisterised = False
    
    131 132
               | arch `elem` codegen_arches = True
    
    132 133
               | otherwise = False
    
    133
    -    platform    <- queryTargetTarget ghcStage targetPlatformTriple
    
    134
    -    wordsize    <- show @Int . (*8) <$> queryTargetTarget ghcStage (wordSize2Bytes . tgtWordSize)
    
    134
    +    platform    <- queryPerStageTargetSpec ghcStage targetPlatformTriple
    
    135
    +    wordsize    <- show @Int . (*8) <$> queryPerStageTargetSpec ghcStage (wordSize2Bytes . tgtWordSize)
    
    135 136
     
    
    136
    -    llc_cmd   <- queryTargetTarget ghcStage tgtLlc
    
    137
    -    llvm_as_cmd <- queryTargetTarget ghcStage tgtLlvmAs
    
    137
    +    llc_cmd   <- queryPerStageTargetSpec ghcStage tgtLlc
    
    138
    +    llvm_as_cmd <- queryPerStageTargetSpec ghcStage tgtLlvmAs
    
    138 139
         let have_llvm = allowHaveLLVM arch && all isJust [llc_cmd, llvm_as_cmd]
    
    139 140
     
    
    140 141
         top         <- topDirectory
    
    ... ... @@ -231,6 +232,8 @@ runTestBuilderArgs = builder Testsuite ? do
    231 232
     
    
    232 233
         keepFiles <- expr (testKeepFiles <$> userSetting defaultTestArgs)
    
    233 234
     
    
    235
    +    tgtArchOs <- expr $ queryPerStageTargetSpec stage tgtArchOs
    
    236
    +
    
    234 237
         accept <- expr (testAccept <$> userSetting defaultTestArgs)
    
    235 238
         (acceptPlatform, acceptOS) <- expr . liftIO $
    
    236 239
             (,) <$> (maybe False (=="YES") <$> lookupEnv "PLATFORM")
    
    ... ... @@ -266,7 +269,7 @@ runTestBuilderArgs = builder Testsuite ? do
    266 269
                 , arg "-e", arg $ "config.accept=" ++ show accept
    
    267 270
                 , arg "-e", arg $ "config.accept_platform=" ++ show acceptPlatform
    
    268 271
                 , arg "-e", arg $ "config.accept_os=" ++ show acceptOS
    
    269
    -            , arg "-e", arg $ "config.exeext=" ++ quote (if null exe then "" else "."<>exe)
    
    272
    +            , arg "-e", arg $ "config.exeext=" ++ quote ("" <.> exe tgtArchOs)
    
    270 273
                 , arg "-e", arg $ "config.compiler_debugged=" ++ show debugAssertions
    
    271 274
                 , arg "-e", arg $ "config.debug_rts=" ++ show debugged
    
    272 275
     
    

  • hadrian/src/Settings/Packages.hs
    ... ... @@ -295,8 +295,8 @@ rtsPackageArgs = package rts ? do
    295 295
         path           <- getBuildPath
    
    296 296
         top            <- expr topDirectory
    
    297 297
         useSystemFfi   <- succStaged (buildFlag UseSystemFfi)
    
    298
    -    libdwIncludeDir   <- staged (\s -> queryTargetTarget s (Lib.includePath <=< tgtRTSWithLibdw))
    
    299
    -    libdwLibraryDir   <- staged (\s -> queryTargetTarget s (Lib.libraryPath <=< tgtRTSWithLibdw))
    
    298
    +    libdwIncludeDir   <- staged (\s -> queryPerStageTargetSpec s (Lib.includePath <=< tgtRTSWithLibdw))
    
    299
    +    libdwLibraryDir   <- staged (\s -> queryPerStageTargetSpec s (Lib.libraryPath <=< tgtRTSWithLibdw))
    
    300 300
         libnumaIncludeDir <- staged (buildSetting LibnumaIncludeDir)
    
    301 301
         libnumaLibraryDir <- staged (buildSetting LibnumaLibDir)
    
    302 302
         libzstdIncludeDir <- staged (buildSetting LibZstdIncludeDir)
    
    ... ... @@ -412,7 +412,7 @@ rtsPackageArgs = package rts ? do
    412 412
               , buildFlag UseLibnuma stage        `cabalFlag` "libnuma"
    
    413 413
               , buildFlag UseLibzstd stage        `cabalFlag` "libzstd"
    
    414 414
               , buildFlag StaticLibzstd stage     `cabalFlag` "static-libzstd"
    
    415
    -          , queryTargetTarget stage tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore"
    
    415
    +          , queryPerStageTargetSpec stage tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore"
    
    416 416
               , ghcUnreg                          `cabalFlag` "unregisterised"
    
    417 417
               , ghcEnableTNC                      `cabalFlag` "tables-next-to-code"
    
    418 418
               ]
    

  • testsuite/driver/testlib.py
    ... ... @@ -1697,11 +1697,6 @@ async def test_common_work(name: TestName, opts,
    1697 1697
                 do_ways = []
    
    1698 1698
                 config.hadrian_deps |= getTestOpts().hadrian_deps
    
    1699 1699
     
    
    1700
    -        # Skip tests which require hadrian dependencies if we are testing
    
    1701
    -        # an out-of-tree compiler as Hadrian is unavailable. See #13897.
    
    1702
    -        if not config.in_tree_compiler and getTestOpts().hadrian_deps - {'test:ghc'}:
    
    1703
    -            do_ways = []
    
    1704
    -
    
    1705 1700
             # Run the required tests...
    
    1706 1701
             for way in do_ways:
    
    1707 1702
                 if stopping():