From 8d1cf1b6089ddc879ceef4eee843a7bfa81d7fd2 Mon Sep 17 00:00:00 2001 From: Artem Pelenitsyn Date: Thu, 25 Apr 2024 18:06:47 +0000 Subject: [PATCH] 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 --- cabal-testsuite/PackageTests/CCompilerOverride/foo.c | 8 -------- cabal-testsuite/PackageTests/CCompilerOverride/my.cabal | 2 +- .../PackageTests/CCompilerOverride/setup.cabal.out | 1 - cabal-testsuite/PackageTests/CCompilerOverride/setup.out | 1 - .../PackageTests/CCompilerOverride/setup.test.hs | 8 +++++--- 5 files changed, 6 insertions(+), 14 deletions(-) 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"]