Skip to content

Respect ghc-options and with-gcc when compiling C sources #5440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions Cabal/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
([#5386](https://github.com/haskell/cabal/issues/5386)).
* `Distribution.PackageDescription.Check.checkPackageFiles` now
accepts a `Verbosity` argument.
* `ghc-options` and `--with-gcc` are now passed to GHC when compiling
C and C++ sources ([#4439](https://github.com/haskell/cabal/issues/4439)).

----

Expand Down
10 changes: 8 additions & 2 deletions Cabal/Distribution/Simple/GHC/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,10 @@ componentCcGhcOptions verbosity _implInfo lbi bi clbi odir filename =
NormalDebugInfo -> ["-g"]
MaximalDebugInfo -> ["-g3"]) ++
PD.ccOptions bi,
ghcOptObjDir = toFlag odir
ghcOptCcProgram = maybeToFlag $ programPath <$>
lookupProgram gccProgram (withPrograms lbi),
ghcOptObjDir = toFlag odir,
ghcOptExtra = hcOptions GHC bi
}


Expand Down Expand Up @@ -329,7 +332,10 @@ componentCxxGhcOptions verbosity _implInfo lbi bi clbi odir filename =
NormalDebugInfo -> ["-g"]
MaximalDebugInfo -> ["-g3"]) ++
PD.cxxOptions bi,
ghcOptObjDir = toFlag odir
ghcOptCcProgram = maybeToFlag $ programPath <$>
lookupProgram gccProgram (withPrograms lbi),
ghcOptObjDir = toFlag odir,
ghcOptExtra = hcOptions GHC bi
}


Expand Down
4 changes: 4 additions & 0 deletions Cabal/Distribution/Simple/Program/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ data GhcOptions = GhcOptions {
-- | Extra header files to include for old-style FFI; the @ghc -#include@ flag.
ghcOptFfiIncludes :: NubListR FilePath,

-- | Program to use for the C and C++ compiler; the @ghc -pgmc@ flag.
ghcOptCcProgram :: Flag FilePath,

----------------------------
-- Language and extensions

Expand Down Expand Up @@ -595,6 +598,7 @@ renderGhcOptions comp _platform@(Platform _arch os) opts
| inc <- flags ghcOptCppIncludes ]
, [ "-optc" ++ opt | opt <- ghcOptCcOptions opts]
, [ "-optc" ++ opt | opt <- ghcOptCxxOptions opts]
, concat [ ["-pgmc", cc] | cc <- flag ghcOptCcProgram ]

-----------------
-- Linker stuff
Expand Down