-
Notifications
You must be signed in to change notification settings - Fork 730
Pass *-options to GHC when compiling ordinary Haskell sources #10969
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,19 +10,20 @@ import Control.Monad | |
| import Data.Foldable | ||
| import Distribution.Simple.Flag | ||
| import qualified Distribution.Simple.GHC.Internal as Internal | ||
| import Distribution.Simple.Program | ||
| import Distribution.Simple.Program.GHC | ||
| import Distribution.Simple.Utils | ||
| import Distribution.Utils.NubList | ||
|
|
||
| import Distribution.Types.BuildInfo | ||
| import Distribution.Types.Component | ||
| import Distribution.Types.TargetInfo | ||
| import Distribution.Types.Version | ||
|
|
||
| import Distribution.Simple.Build.Inputs | ||
| import Distribution.Simple.GHC.Build.Modules | ||
| import Distribution.Simple.BuildWay | ||
| import Distribution.Simple.GHC.Build.Utils | ||
| import Distribution.Simple.LocalBuildInfo | ||
| import Distribution.Simple.Program.Types | ||
| import Distribution.Simple.Setup.Common (commonSetupTempFileOptions) | ||
| import Distribution.System (Arch (JavaScript), Platform (..)) | ||
| import Distribution.Types.ComponentLocalBuildInfo | ||
|
|
@@ -77,7 +78,23 @@ buildCSources | |
| buildCSources mbMainFile = | ||
| buildExtraSources | ||
| "C Sources" | ||
| Internal.componentCcGhcOptions | ||
| ( \verbosity lbi bi clbi odir filename -> | ||
| (Internal.sourcesGhcOptions verbosity lbi bi clbi odir filename) | ||
| { -- C++ compiler options: GHC >= 8.10 requires -optcxx, older requires -optc | ||
| -- we want to be able to support cxx-options and cc-options separately | ||
| -- https://gitlab.haskell.org/ghc/ghc/-/issues/16477 | ||
| -- see example in cabal-testsuite/PackageTests/FFI/ForeignOptsC | ||
| ghcOptCxxOptions = | ||
|
zlonast marked this conversation as resolved.
|
||
| Internal.separateGhcOptions | ||
| (mkVersion [8, 10]) | ||
| (compiler lbi) | ||
| (Internal.optimizationCFlags lbi ++ cxxOptions bi) | ||
| , -- there are problems with linking with versions below 9.4, | ||
| -- that's why we need this replacement for linkGhcOptions | ||
| -- https://github.com/haskell/cabal/issues/11712 | ||
| ghcOptCcProgram = maybeToFlag $ programPath <$> lookupProgram gccProgram (withPrograms lbi) | ||
| } | ||
| ) | ||
| ( \c -> do | ||
| let cFiles = cSources (componentBuildInfo c) | ||
| case c of | ||
|
|
@@ -90,7 +107,23 @@ buildCSources mbMainFile = | |
| buildCxxSources mbMainFile = | ||
| buildExtraSources | ||
| "C++ Sources" | ||
| Internal.componentCxxGhcOptions | ||
| ( \verbosity lbi bi clbi odir filename -> | ||
| (Internal.sourcesGhcOptions verbosity lbi bi clbi odir filename) | ||
| { -- C++ compiler options: GHC >= 8.10 requires -optcxx, older requires -optc | ||
| -- we want to be able to support cxx-options and cc-options separately | ||
| -- https://gitlab.haskell.org/ghc/ghc/-/issues/16477 | ||
| -- see example in cabal-testsuite/PackageTests/FFI/ForeignOptsCxx | ||
| ghcOptCcOptions = | ||
| Internal.separateGhcOptions | ||
| (mkVersion [8, 10]) | ||
| (compiler lbi) | ||
| (Internal.optimizationCFlags lbi ++ ccOptions bi) | ||
| , -- there are problems with linking with versions below 9.4, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What "problems with linking" and what exact issue does this solve? It's quite mysterious at the moment.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, these kinds of comments should include links to GHC issues This is not https://gitlab.haskell.org/ghc/ghc/-/issues/17919, as that one is pre GHC-8.10
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if only i knew... i need to look at all pull requests for 9.4.*
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't know where it was fixed, my search methods were weak. I only know that it happened with the release 9.4.*
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't know the answer to this question
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| -- that's why we need this replacement for linkGhcOptions | ||
| -- https://github.com/haskell/cabal/issues/11712 | ||
| ghcOptCcProgram = maybeToFlag $ programPath <$> lookupProgram gccProgram (withPrograms lbi) | ||
| } | ||
| ) | ||
| ( \c -> do | ||
| let cxxFiles = cxxSources (componentBuildInfo c) | ||
| case c of | ||
|
|
@@ -105,7 +138,7 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays verbHandles = do | |
| let hasJsSupport = hostArch == JavaScript | ||
| buildExtraSources | ||
| "JS Sources" | ||
| Internal.componentJsGhcOptions | ||
| Internal.sourcesGhcOptions | ||
| ( \c -> | ||
| if hasJsSupport | ||
| then -- JS files are C-like with GHC's JS backend: they are | ||
|
|
@@ -122,12 +155,12 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays verbHandles = do | |
| buildAsmSources _mbMainFile = | ||
| buildExtraSources | ||
| "Assembler Sources" | ||
| Internal.componentAsmGhcOptions | ||
| Internal.sourcesGhcOptions | ||
| (asmSources . componentBuildInfo) | ||
| buildCmmSources _mbMainFile = | ||
| buildExtraSources | ||
| "C-- Sources" | ||
| Internal.componentCmmGhcOptions | ||
| Internal.sourcesGhcOptions | ||
| (cmmSources . componentBuildInfo) | ||
|
|
||
| -- | Create 'PreBuildComponentRules' for a given type of extra build sources | ||
|
|
@@ -145,9 +178,7 @@ buildExtraSources | |
| -> GhcOptions | ||
| ) | ||
| -- ^ Function to determine the @'GhcOptions'@ for the | ||
| -- invocation of GHC when compiling these extra sources (e.g. | ||
| -- @'Internal.componentCxxGhcOptions'@, | ||
| -- @'Internal.componentCmmGhcOptions'@) | ||
| -- invocation of GHC when compiling these extra sources | ||
| -> (Component -> [SymbolicPath Pkg File]) | ||
| -- ^ View the extra sources of a component, typically from | ||
| -- the build info (e.g. @'asmSources'@, @'cSources'@). | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.