From 5c6f6700d686fb6c27f3210579440707f7d38cb5 Mon Sep 17 00:00:00 2001 From: Artem Pelenitsyn Date: Tue, 28 May 2024 21:05:56 -0400 Subject: [PATCH 1/2] CI: add GHC 9.10 (#9914) * CI: add GHC 9.10 * GHC 9.10 compat in testsuite: CPP symbols don't get passed to CC as eagearly Discussion: https://github.com/haskell/cabal/pull/9914#issuecomment-2077439625 Related GHC issue: https://gitlab.haskell.org/ghc/ghc/-/issues/21291 * GHC 9.10 compat in tests: disable tests regressing due to #9940 (cherry picked from commit 3a8c69cb142e27caae5d754ac400636b3417b198) --- .github/workflows/validate.yml | 3 ++- .../src/Distribution/Client/TargetSelector.hs | 7 ++++++- cabal-install/tests/IntegrationTests2.hs | 6 ++++-- .../Distribution/Client/Init/NonInteractive.hs | 3 +++ .../PackageTests/CCompilerOverride/foo.c | 8 -------- .../PackageTests/CCompilerOverride/my.cabal | 2 +- .../CCompilerOverride/setup.cabal.out | 1 - .../PackageTests/CCompilerOverride/setup.out | 1 - .../PackageTests/CCompilerOverride/setup.test.hs | 8 +++++--- project-cabal/ghc-latest.config | 16 ++++++++++++++-- 10 files changed, 35 insertions(+), 20 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 509c9694298..5d597314ea2 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -70,7 +70,7 @@ jobs: # If you remove something from here, then add it to the old-ghcs job. # Also a removed GHC from here means that we are actually dropping # support, so the PR *must* have a changelog entry. - ghc: ['9.8.2', '9.6.4', '9.4.8', '9.2.8', '9.0.2', '8.10.7', '8.8.4', '8.6.5'] + ghc: ['9.10.1', '9.8.2', '9.6.4', '9.4.8', '9.2.8', '9.0.2', '8.10.7', '8.8.4', '8.6.5'] exclude: # corrupts GHA cache or the fabric of reality itself, see https://github.com/haskell/cabal/issues/8356 - os: windows-latest @@ -104,6 +104,7 @@ jobs: with: ghc-version: ${{ matrix.ghc }} cabal-version: latest # latest is mandatory for cabal-testsuite, see https://github.com/haskell/cabal/issues/8133 + ghcup-release-channel: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml # See the following link for a breakdown of the following step # https://github.com/haskell/actions/issues/7#issuecomment-745697160 diff --git a/cabal-install/src/Distribution/Client/TargetSelector.hs b/cabal-install/src/Distribution/Client/TargetSelector.hs index d29413642de..1c01b3e5d88 100644 --- a/cabal-install/src/Distribution/Client/TargetSelector.hs +++ b/cabal-install/src/Distribution/Client/TargetSelector.hs @@ -101,6 +101,11 @@ import Control.Arrow ((&&&)) import Control.Monad hiding ( mfilter ) +#if MIN_VERSION_base(4,20,0) +import Data.Functor as UZ (unzip) +#else +import qualified Data.List.NonEmpty as UZ (unzip) +#endif import Data.List ( stripPrefix ) @@ -581,7 +586,7 @@ resolveTargetSelector knowntargets@KnownTargets{..} mfilter targetStrStatus = classifyMatchErrors errs | Just expectedNE <- NE.nonEmpty expected = - let (things, got :| _) = NE.unzip expectedNE + let (things, got :| _) = UZ.unzip expectedNE in TargetSelectorExpected targetStr (NE.toList things) got | not (null nosuch) = TargetSelectorNoSuch targetStr nosuch diff --git a/cabal-install/tests/IntegrationTests2.hs b/cabal-install/tests/IntegrationTests2.hs index 55ea3747b9f..94cd89f6381 100644 --- a/cabal-install/tests/IntegrationTests2.hs +++ b/cabal-install/tests/IntegrationTests2.hs @@ -1436,9 +1436,11 @@ testSetupScriptStyles config reportSubCase = do let isOSX (Platform _ OSX) = True isOSX _ = False + compilerVer = compilerVersion (pkgConfigCompiler sharedConfig) -- Skip the Custom tests when the shipped Cabal library is buggy - unless (isOSX (pkgConfigPlatform sharedConfig) - && compilerVersion (pkgConfigCompiler sharedConfig) < mkVersion [7,10]) $ do + unless ((isOSX (pkgConfigPlatform sharedConfig) && (compilerVer < mkVersion [7,10])) + -- 9.10 ships Cabal 3.12.0.0 affected by #9940 + || (mkVersion [9,10] <= compilerVer && compilerVer < mkVersion [9,11])) $ do (plan1, res1) <- executePlan plan0 pkg1 <- expectPackageInstalled plan1 res1 pkgidA diff --git a/cabal-install/tests/UnitTests/Distribution/Client/Init/NonInteractive.hs b/cabal-install/tests/UnitTests/Distribution/Client/Init/NonInteractive.hs index d35ab35a659..cd618622201 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/Init/NonInteractive.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/Init/NonInteractive.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} module UnitTests.Distribution.Client.Init.NonInteractive @@ -12,7 +13,9 @@ import UnitTests.Distribution.Client.Init.Utils import qualified Data.List.NonEmpty as NEL import qualified Distribution.SPDX as SPDX +#if !MIN_VERSION_base(4,20,0) import Data.List (foldl') +#endif import qualified Data.Set as Set import Distribution.CabalSpecVersion import Distribution.Client.Init.Defaults diff --git a/cabal-testsuite/PackageTests/CCompilerOverride/foo.c b/cabal-testsuite/PackageTests/CCompilerOverride/foo.c index 30892bef07e..03ddd01e14b 100644 --- a/cabal-testsuite/PackageTests/CCompilerOverride/foo.c +++ b/cabal-testsuite/PackageTests/CCompilerOverride/foo.c @@ -1,16 +1,8 @@ -#ifndef NOERROR1 -#error "NOERROR1 was not passed" -#endif - #ifndef NOERROR2 #error "NOERROR2 was not passed" #endif -#ifndef NOERROR3 -#error "NOERROR3 was not passed" -#endif - #ifndef NOERROR4 #error "NOERROR4 was not passed" #endif diff --git a/cabal-testsuite/PackageTests/CCompilerOverride/my.cabal b/cabal-testsuite/PackageTests/CCompilerOverride/my.cabal index 31a79f93a60..14772f3894f 100644 --- a/cabal-testsuite/PackageTests/CCompilerOverride/my.cabal +++ b/cabal-testsuite/PackageTests/CCompilerOverride/my.cabal @@ -9,5 +9,5 @@ executable foo main-is: Main.hs c-sources: foo.c build-depends: base - ghc-options: -DNOERROR4 + ghc-options: -optc=-DNOERROR4 cc-options: -DNOERROR5 -march=native diff --git a/cabal-testsuite/PackageTests/CCompilerOverride/setup.cabal.out b/cabal-testsuite/PackageTests/CCompilerOverride/setup.cabal.out index 21981fd9b76..6d0c3265de9 100644 --- a/cabal-testsuite/PackageTests/CCompilerOverride/setup.cabal.out +++ b/cabal-testsuite/PackageTests/CCompilerOverride/setup.cabal.out @@ -1,4 +1,3 @@ # Setup configure Configuring my-0.1... -Warning: [misplaced-c-opt] Instead of 'ghc-options: -DNOERROR4' use 'cpp-options: -DNOERROR4' # Setup build diff --git a/cabal-testsuite/PackageTests/CCompilerOverride/setup.out b/cabal-testsuite/PackageTests/CCompilerOverride/setup.out index 21981fd9b76..6d0c3265de9 100644 --- a/cabal-testsuite/PackageTests/CCompilerOverride/setup.out +++ b/cabal-testsuite/PackageTests/CCompilerOverride/setup.out @@ -1,4 +1,3 @@ # Setup configure Configuring my-0.1... -Warning: [misplaced-c-opt] Instead of 'ghc-options: -DNOERROR4' use 'cpp-options: -DNOERROR4' # Setup build diff --git a/cabal-testsuite/PackageTests/CCompilerOverride/setup.test.hs b/cabal-testsuite/PackageTests/CCompilerOverride/setup.test.hs index 5843cb2b7df..b4f7f04ddb1 100644 --- a/cabal-testsuite/PackageTests/CCompilerOverride/setup.test.hs +++ b/cabal-testsuite/PackageTests/CCompilerOverride/setup.test.hs @@ -3,6 +3,10 @@ import Test.Cabal.Prelude -- Test that all the respective defines -DNOERROR... specified in various ways -- all end up routed to the C compiler. Otherwise the C file we depend on will -- not compile. +-- +-- This has been largely gutted, as ghc 9.10 no longer passes through most +-- of the defines we were testing; see +-- https://gitlab.haskell.org/ghc/ghc/-/commit/8ff3134ed4aa323b0199ad683f72165e51a59ab6 main = setupAndCabalTest $ do skipUnlessGhcVersion ">= 8.8" isWin <- isWindows @@ -14,9 +18,7 @@ main = setupAndCabalTest $ do pwd ++ "/custom-cc" ++ if isWin then win_suffix else "" setup "configure" - [ "--ghc-option=-DNOERROR1" - , "--ghc-option=-optc=-DNOERROR2" - , "--ghc-option=-optP=-DNOERROR3" + [ "--ghc-option=-optc=-DNOERROR2" , "--with-gcc=" ++ customCC ] setup "build" ["-v2"] diff --git a/project-cabal/ghc-latest.config b/project-cabal/ghc-latest.config index bff5d80c241..5f8d40290db 100644 --- a/project-cabal/ghc-latest.config +++ b/project-cabal/ghc-latest.config @@ -8,5 +8,17 @@ -- NOTE: don't forget to update the compiler version in the conditional -- when upgrading to a newer GHC -if impl(ghc >= 9.8.1) - -- allow-newer: windns:* +if impl(ghc >= 9.10.0) + allow-newer: + --windns:*, rere:*, tree-diff:*, uuid-types:*, these:*, hashable:*, assoc:*, semialign:*, indexed-traversable-instances:*, indexed-traversable:*, OneTuple:*, scientific:*, time-compat:*, text-short:*, integer-conversion:*, generically:*, data-fix:*, binary:* + -- Artem, 2024-04-21: I started and then gave up... + *:base, *:template-haskell, text-short, *:deepseq, *:bytestring, *:ghc-prim + + repository head.hackage.ghc.haskell.org + url: https://ghc.gitlab.haskell.org/head.hackage/ + secure: True + key-threshold: 3 + root-keys: + 26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329 + 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d + f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89 From 808ef46dbf1a920db23445a5299034563a27a3e0 Mon Sep 17 00:00:00 2001 From: Artem Pelenitsyn Date: Mon, 3 Jun 2024 13:50:11 +0000 Subject: [PATCH 2/2] testsuite: exclude tests failing due to the number of dots boot cabal prints --- .../PackageTests/CustomTestCoverage/cabal.out | 12 ++++++------ .../PackageTests/CustomTestCoverage/cabal.test.hs | 1 + .../PackageTests/Regression/T9640/cabal.out | 4 ++-- .../PackageTests/Regression/T9640/cabal.test.hs | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cabal-testsuite/PackageTests/CustomTestCoverage/cabal.out b/cabal-testsuite/PackageTests/CustomTestCoverage/cabal.out index a650ce81c42..8597dcc94df 100644 --- a/cabal-testsuite/PackageTests/CustomTestCoverage/cabal.out +++ b/cabal-testsuite/PackageTests/CustomTestCoverage/cabal.out @@ -4,14 +4,14 @@ Build profile: -w ghc- -O1 In order, the following will be built: - plain-0.1.0.0 *test (first run) Configuring plain-0.1.0.0... -Preprocessing library for plain-0.1.0.0.. -Building library for plain-0.1.0.0.. -Preprocessing test suite 'test' for plain-0.1.0.0.. -Building test suite 'test' for plain-0.1.0.0.. +Preprocessing library for plain-0.1.0.0... +Building library for plain-0.1.0.0... +Preprocessing test suite 'test' for plain-0.1.0.0... +Building test suite 'test' for plain-0.1.0.0... Running 1 test suites... Test suite test: RUNNING... Test suite test: PASS Test suite logged to: /cabal.dist/work/./dist/build//ghc-/plain-0.1.0.0/test/plain-0.1.0.0-test.log -Test coverage report written to /cabal.dist/work/./dist/build//ghc-/plain-0.1.0.0/hpc/vanilla/html/test/hpc_index.html +Package coverage report written to /cabal.dist/work/./dist/build//ghc-/plain-0.1.0.0/hpc/vanilla/html/hpc_index.html 1 of 1 test suites (1 of 1 test cases) passed. -Package coverage report written to /cabal.dist/work/./dist/build//ghc-/plain-0.1.0.0/hpc/vanilla/html/plain-0.1.0.0/hpc_index.html +Package coverage report written to /cabal.dist/work/./dist/build//ghc-/plain-0.1.0.0/hpc/vanilla/html/hpc_index.html diff --git a/cabal-testsuite/PackageTests/CustomTestCoverage/cabal.test.hs b/cabal-testsuite/PackageTests/CustomTestCoverage/cabal.test.hs index 6f3f5586c62..382bb0fcb24 100644 --- a/cabal-testsuite/PackageTests/CustomTestCoverage/cabal.test.hs +++ b/cabal-testsuite/PackageTests/CustomTestCoverage/cabal.test.hs @@ -1,3 +1,4 @@ import Test.Cabal.Prelude main = cabalTest $ do + skipUnlessGhcVersion ">= 9.10" cabal "test" ["--enable-coverage"] diff --git a/cabal-testsuite/PackageTests/Regression/T9640/cabal.out b/cabal-testsuite/PackageTests/Regression/T9640/cabal.out index 8ec3628aadb..4c0f119823f 100644 --- a/cabal-testsuite/PackageTests/Regression/T9640/cabal.out +++ b/cabal-testsuite/PackageTests/Regression/T9640/cabal.out @@ -7,8 +7,8 @@ In order, the following will be built: - one-custom-0.1.0.0 (lib:one-custom) (requires build) - depend-on-custom-with-exe-0.1.0.0 (lib) (first run) Configuring one-custom-0.1.0.0... -Preprocessing library for one-custom-0.1.0.0.. -Building library for one-custom-0.1.0.0.. +Preprocessing library for one-custom-0.1.0.0... +Building library for one-custom-0.1.0.0... Installing library in Warning: depend-on-custom-with-exe.cabal:16:1: Ignoring trailing fields after sections: "ghc-options" Configuring library for depend-on-custom-with-exe-0.1.0.0... diff --git a/cabal-testsuite/PackageTests/Regression/T9640/cabal.test.hs b/cabal-testsuite/PackageTests/Regression/T9640/cabal.test.hs index 628de12e9b8..9e10ba79055 100644 --- a/cabal-testsuite/PackageTests/Regression/T9640/cabal.test.hs +++ b/cabal-testsuite/PackageTests/Regression/T9640/cabal.test.hs @@ -1,4 +1,4 @@ import Test.Cabal.Prelude main = cabalTest $ withRepo "repo" $ do - skipUnlessGhcVersion ">= 8.8" + skipUnlessGhcVersion ">= 9.10" cabal "build" ["depend-on-custom-with-exe"]