Skip to content
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

Add a config option to override gcc path #2264

Merged
merged 3 commits into from
Jul 10, 2016
Merged
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
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Other enhancements:
custom `shell.nix` is used
See [#2243](https://github.com/commercialhaskell/stack/issues/2243)

* 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 @@ -282,6 +282,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 @@ -840,6 +842,8 @@ data ConfigMonoid =
-- ^ See: 'configExtraIncludeDirs'
,configMonoidExtraLibDirs :: !(Set Text)
-- ^ See: 'configExtraLibDirs'
, configMonoidOverrideGccPath :: !(First Text)
Copy link
Member

@sjakobi sjakobi Jun 13, 2016

Choose a reason for hiding this comment

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

Personally, I'd prefer a First (Path Abs File) here.

The main advantage I'd expect from that, would be better error messages than those that we currently relay from cabal or ghc.

I also think that this should be done "categorically", so for configMonoidExtraIncludeDirs, configMonoidExtraLibDirs, configMonoidWorkDir and configMonoidLocalBinPath too. (Not necessarily in this PR though)

Options.Applicative.Builder.eitherReader would probably be a useful helper function for this.

Copy link
Member

Choose a reason for hiding this comment

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

I have opened #2267 with regard to the overly permissive types.

Given that it's a rather tangential point, feel free to change configMonoidOverrideGccPath to First (Path Abs File) or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just had a quick play with this - there's a slight problem with there being no FromJSON instance for Path Abs File etc. I'd rather fix that as part of #2267 (as it is a little tangential). I'm happy to pick that one up as well once this is done though :).

Copy link
Member

Choose a reason for hiding this comment

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

I've already started working on #2267 so you may want to choose a different issue next. ;)

-- ^ Allow users to override the path to gcc
,configMonoidConcurrentTests :: !(First Bool)
-- ^ See: 'configConcurrentTests'
,configMonoidLocalBinPath :: !(First FilePath)
Expand Down Expand Up @@ -913,6 +917,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 @@ -1017,6 +1022,9 @@ configMonoidExtraIncludeDirsName = "extra-include-dirs"
configMonoidExtraLibDirsName :: Text
configMonoidExtraLibDirsName = "extra-lib-dirs"

configMonoidOverrideGccPathName :: Text
configMonoidOverrideGccPathName = "with-gcc"

configMonoidConcurrentTestsName :: Text
configMonoidConcurrentTestsName = "concurrent-tests"

Expand Down