Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Cabal/src/Distribution/Simple/GHC/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ splitCandCxxOptions
-> LocalBuildInfo
-> BuildInfo
-> ComponentLocalBuildInfo
-> SymbolicPathX 'AllowAbsolute Pkg (Dir Artifacts)
-> SymbolicPathX 'AllowAbsolute Pkg File
-> SymbolicPath Pkg (Dir Artifacts)
-> SymbolicPath Pkg File

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's typo from rebase

-> GhcOptions
splitCandCxxOptions source verbosity lbi bi clbi odir filename = case source of
CxxProgram ->
Expand Down Expand Up @@ -453,6 +453,9 @@ sourcesGhcOptions verbosity lbi bi clbi odir filename =
, ghcOptInputFiles = toNubListR [filename]
, ghcOptObjDir = toFlag odir
, ghcOptPackages = toNubListR $ mkGhcOptPackages (promisedPkgs lbi) clbi
, -- cpp-options apply only to .hs files; GHC ignores -optP for non-Haskell
-- files (and since 9.10 this behavior is explicit/enforced)
ghcOptCppOptions = []
}

optimizationCFlags :: LocalBuildInfo -> [String]
Expand Down
5 changes: 5 additions & 0 deletions cabal-testsuite/PackageTests/FFI/CppOptionsOnlyForHs/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Main where

main :: IO ()
main = do
putStrLn "The secret is 11"
10 changes: 10 additions & 0 deletions cabal-testsuite/PackageTests/FFI/CppOptionsOnlyForHs/cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# cabal v2-build
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- cpp-options-only-for-hs-0.1 (exe:cpp-options-only-for-hs-exe) (first run)
Configuring executable 'cpp-options-only-for-hs-exe' for cpp-options-only-for-hs-0.1...
Preprocessing executable 'cpp-options-only-for-hs-exe' for cpp-options-only-for-hs-0.1...
Building executable 'cpp-options-only-for-hs-exe' for cpp-options-only-for-hs-0.1...
# cpp-options-only-for-hs cpp-options-only-for-hs-exe
The secret is 11
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: .
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Test.Cabal.Prelude
main = cabalTest $ do
cabal "v2-build" ["cpp-options-only-for-hs-exe"]
withPlan $ runPlanExe "cpp-options-only-for-hs" "cpp-options-only-for-hs-exe" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifdef SUPPORT_SSE
#error "cpp-options should not be applied to C sources"
#else
#endif

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cabal-version: 2.2
name: cpp-options-only-for-hs
version: 0.1
build-type: Simple

executable cpp-options-only-for-hs-exe
main-is: Main.hs
build-depends: base
default-language: Haskell2010
c-sources: cbits/clib.c
cpp-options: -DSUPPORT_SSE
9 changes: 9 additions & 0 deletions changelog.d/11997.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
synopsis: cpp-options apply only to .hs files
packages: [Cabal]
prs: 11997
issues: 11992
---

cpp-options apply only to .hs files; GHC ignores -optP for non-Haskell
files (and since 9.10 this behavior is explicit/enforced)
Loading