Skip to content

Commit

Permalink
Merge pull request #2264 from khanage/593_override_gcc_path
Browse files Browse the repository at this point in the history
Add a config option to override gcc path
  • Loading branch information
sjakobi committed Jul 10, 2016
2 parents 919f0b2 + 416af62 commit 93c5ffe
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Other enhancements:
* Stack/Nix: Sets `LD_LIBRARY_PATH` so packages using C libs for Template Haskell can work
(See _e.g._ [this HaskellR issue](https://github.com/tweag/HaskellR/issues/253))

* Add the ability to explictly specify a gcc executable.
[#593](https://github.com/commercialhaskell/stack/issues/593)

Bug fixes:

* Support most executable extensions on Windows
Expand Down
8 changes: 8 additions & 0 deletions doc/yaml_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@ extra-lib-dirs:
- /opt/foo/lib
```

### with-ghc

Specify a path to gcc explicitly, rather than relying on the normal path resolution.

```yaml
with-gcc: /usr/local/bin/gcc-5
```

### compiler-check

(Since 0.1.4)
Expand Down
1 change: 1 addition & 0 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ configFromConfigMonoid configStackRoot configUserConfigPath mresolver mproject C

configExtraIncludeDirs = configMonoidExtraIncludeDirs
configExtraLibDirs = configMonoidExtraLibDirs
configOverrideGccPath = getFirst configMonoidOverrideGccPath

-- Only place in the codebase where platform is hard-coded. In theory
-- in the future, allow it to be configured.
Expand Down
9 changes: 8 additions & 1 deletion src/Stack/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ cleanOptsParser = CleanShallow <$> packages <|> doFullClean
-- | Command-line arguments parser for configuration.
configOptsParser :: GlobalOptsContext -> Parser ConfigMonoid
configOptsParser hide0 =
(\stackRoot workDir buildOpts dockerOpts nixOpts systemGHC installGHC arch os ghcVariant jobs includes libs skipGHCCheck skipMsys localBin modifyCodePage allowDifferentUser -> mempty
(\stackRoot workDir buildOpts dockerOpts nixOpts systemGHC installGHC arch os ghcVariant jobs includes libs overrideGccPath skipGHCCheck skipMsys localBin modifyCodePage allowDifferentUser -> mempty
{ configMonoidStackRoot = stackRoot
, configMonoidWorkDir = workDir
, configMonoidBuildOpts = buildOpts
Expand All @@ -218,6 +218,7 @@ configOptsParser hide0 =
, configMonoidJobs = jobs
, configMonoidExtraIncludeDirs = includes
, configMonoidExtraLibDirs = libs
, configMonoidOverrideGccPath = overrideGccPath
, configMonoidSkipMsys = skipMsys
, configMonoidLocalBinPath = localBin
, configMonoidModifyCodePage = modifyCodePage
Expand Down Expand Up @@ -279,6 +280,12 @@ configOptsParser hide0 =
<> help "Extra directories to check for libraries"
<> hide
)))
<*> optionalFirst (textOption
( long "with-gcc"
<> metavar "PATH-TO-GCC"
<> help "Use gcc found at PATH-TO-GCC"
<> hide
))
<*> firstBoolFlags
"skip-ghc-check"
"skipping the GHC version and architecture check"
Expand Down
1 change: 1 addition & 0 deletions src/Stack/Types/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ configureOptsNoDir econfig bco deps isLocal package = concat
, concatMap (\x -> ["--ghc-options", T.unpack x]) (packageGhcOptions package)
, map (("--extra-include-dirs=" ++) . T.unpack) (Set.toList (configExtraIncludeDirs config))
, map (("--extra-lib-dirs=" ++) . T.unpack) (Set.toList (configExtraLibDirs config))
, maybe [] (\customGcc -> ["--with-gcc=" ++ T.unpack customGcc]) (configOverrideGccPath config)
, if whichCompiler (envConfigCompilerVersion econfig) == Ghcjs
then ["--ghcjs"]
else []
Expand Down
8 changes: 8 additions & 0 deletions src/Stack/Types/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ data Config =
-- ^ Require a version of stack within this range.
,configJobs :: !Int
-- ^ How many concurrent jobs to run, defaults to number of capabilities
,configOverrideGccPath :: !(Maybe Text)
-- ^ Optional gcc override path
,configExtraIncludeDirs :: !(Set Text)
-- ^ --extra-include-dirs arguments
,configExtraLibDirs :: !(Set Text)
Expand Down Expand Up @@ -843,6 +845,8 @@ data ConfigMonoid =
-- ^ See: 'configExtraIncludeDirs'
,configMonoidExtraLibDirs :: !(Set Text)
-- ^ See: 'configExtraLibDirs'
, configMonoidOverrideGccPath :: !(First Text)
-- ^ Allow users to override the path to gcc
,configMonoidConcurrentTests :: !(First Bool)
-- ^ See: 'configConcurrentTests'
,configMonoidLocalBinPath :: !(First FilePath)
Expand Down Expand Up @@ -916,6 +920,7 @@ parseConfigMonoidJSON obj = do
configMonoidJobs <- First <$> obj ..:? configMonoidJobsName
configMonoidExtraIncludeDirs <- obj ..:? configMonoidExtraIncludeDirsName ..!= Set.empty
configMonoidExtraLibDirs <- obj ..:? configMonoidExtraLibDirsName ..!= Set.empty
configMonoidOverrideGccPath <- First <$> obj ..:? configMonoidOverrideGccPathName
configMonoidConcurrentTests <- First <$> obj ..:? configMonoidConcurrentTestsName
configMonoidLocalBinPath <- First <$> obj ..:? configMonoidLocalBinPathName
configMonoidImageOpts <- jsonSubWarnings (obj ..:? configMonoidImageOptsName ..!= mempty)
Expand Down Expand Up @@ -1020,6 +1025,9 @@ configMonoidExtraIncludeDirsName = "extra-include-dirs"
configMonoidExtraLibDirsName :: Text
configMonoidExtraLibDirsName = "extra-lib-dirs"

configMonoidOverrideGccPathName :: Text
configMonoidOverrideGccPathName = "with-gcc"

configMonoidConcurrentTestsName :: Text
configMonoidConcurrentTestsName = "concurrent-tests"

Expand Down

0 comments on commit 93c5ffe

Please sign in to comment.